Skip to main content

p3_miden_lifted_stark/
lib.rs

1//! Lifted STARK prover and verifier (LMCS-based).
2//!
3//! This crate is the main facade for the lifted STARK protocol. It re-exports types from
4//! sub-crates under namespaced modules so consumers can depend on just this crate.
5//!
6//! # Modules
7//!
8//! - [`proof`]: [`proof::StarkProof`], [`proof::StarkDigest`], [`proof::StarkOutput`], [`proof::StarkTranscript`]
9//! - [`air`]: AIR traits, instance/witness types, and upstream `p3-air` re-exports
10//! - [`prover`]: [`prover::prove_single`] / [`prover::prove_multi`] entry points
11//! - [`verifier`]: [`verifier::verify_single`] / [`verifier::verify_multi`] entry points
12//! - [`fri`]: PCS parameters, transcript types, and error types (DEEP + FRI)
13//! - [`lmcs`]: LMCS configuration, proof types, and MMCS compatibility
14//! - [`transcript`]: Fiat-Shamir channels and transcript data
15//! - [`hasher`]: Stateful hasher primitives for LMCS construction
16//!
17//! # AIR Trust Model
18//!
19//! The lifted STARK has three trust domains:
20//!
21//! 1. **AIR = trusted** — [`air::LiftedAir`] implementations are
22//!    correct application code. It is the AIR implementer's responsibility to satisfy the
23//!    contract below. [`air::LiftedAir::validate`]
24//!    checks the statically-verifiable subset.
25//!
26//! 2. **Instance = validated** — The prover validates that its witness matches the AIR spec.
27//!    The verifier validates instance metadata.
28//!    Both return structured errors.
29//!
30//! 3. **Proof = untrusted** — Transcript data is verified cryptographically (PCS errors,
31//!    constraint mismatch, etc.).
32//!
33//! ## Validated properties
34//!
35//! These are checked by [`air::LiftedAir::validate`]
36//! and [`air::AirInstance::validate`], and enforced
37//! by both prover and verifier before proceeding:
38//!
39//! - **No preprocessed trace** — the lifted protocol does not support them.
40//! - **Positive aux width** — every AIR must have an auxiliary trace.
41//! - **Periodic columns** — each has positive, power-of-two length ≤ trace height.
42//! - **Constraint degree** — `log_quotient_degree() ≤ log_blowup`.
43//! - **Instance dimensions** — trace width, public values length, var-len public
44//!   inputs count, and trace height (power of two) all match the AIR specification.
45//!
46//! ## Unchecked trust assumptions
47//!
48//! These cannot be verified statically and are the AIR implementer's responsibility:
49//!
50//! 1. **Window size** — Only transition window size 2.
51//! 2. **Deterministic constraints** — `eval()` emits the same number and types of
52//!    constraints regardless of builder implementation.
53//! 3. **Consistent aux builder** — `AuxBuilder::build_aux_trace` returns
54//!    width = `aux_width()`, height = main trace height, and exactly
55//!    `num_aux_values()` values. (The prover asserts these at runtime as a
56//!    defense-in-depth sanity check.)
57//! 4. **Sound `reduced_aux_values`** — Returns correct bus contributions for valid inputs.
58
59#![no_std]
60
61extern crate alloc;
62
63mod config;
64/// Domain/coset operations for lifted traces.
65pub mod coset;
66/// Debug constraint checker for lifted AIRs.
67pub mod debug;
68pub(crate) mod selectors;
69
70pub use config::*;
71
72pub mod proof;
73pub mod prover;
74pub mod verifier;
75
76// ============================================================================
77// Namespaced re-exports from sub-crates
78// ============================================================================
79
80/// AIR traits, instance/witness types, and upstream `p3-air` re-exports.
81///
82/// This module re-exports items from [`p3_miden_lifted_air`], which in turn
83/// re-exports `p3-air` types. Consumers should never need to depend on `p3-air`
84/// directly.
85pub mod air {
86    pub use p3_miden_lifted_air::{
87        // Upstream p3-air re-exports
88        Air,
89        AirBuilder,
90        AirBuilderWithContext,
91        // Lifted AIR types
92        AirInstance,
93        AirValidationError,
94        AirWitness,
95        AuxBuilder,
96        BaseAir,
97        EmptyWindow,
98        ExtensionBuilder,
99        FilteredAirBuilder,
100        LiftedAir,
101        LiftedAirBuilder,
102        PeriodicAirBuilder,
103        PermutationAirBuilder,
104        ReducedAuxValues,
105        ReductionError,
106        RowWindow,
107        TracePart,
108        VarLenPublicInputs,
109        WindowAccess,
110        log2_strict_u8,
111        validate_instances,
112    };
113
114    /// Symbolic constraint analysis types from upstream p3-air.
115    pub mod symbolic {
116        pub use p3_miden_lifted_air::symbolic::*;
117    }
118
119    /// Auxiliary trace types (builder, cross-AIR identity checking).
120    pub mod auxiliary {
121        pub use p3_miden_lifted_air::auxiliary::*;
122    }
123
124    /// AIR constraint utility functions from upstream p3-air.
125    pub mod utils {
126        pub use p3_miden_lifted_air::utils::*;
127    }
128}
129
130/// PCS parameter types, transcript views, and error types for DEEP + FRI.
131pub mod fri {
132    pub use p3_miden_lifted_fri::{
133        OpenedValues, PcsError, PcsParams, PcsParamsError, PcsTranscript,
134        deep::{DeepError, DeepTranscript},
135        fri::{FriError, FriRoundTranscript, FriTranscript},
136    };
137}
138
139/// LMCS configuration, tree types, and proof structures.
140pub mod lmcs {
141    pub use p3_miden_lmcs::{
142        HidingLmcsConfig, LiftedMerkleTree, Lmcs, LmcsConfig, LmcsError, LmcsTree, OpenedRows,
143        proof::{BatchProof, LeafOpening, Proof},
144        utils::RowList,
145    };
146}
147
148/// Fiat-Shamir transcript channels and data types.
149pub mod transcript {
150    pub use p3_miden_transcript::{TranscriptChallenger, TranscriptData, TranscriptError};
151}
152
153/// Stateful hasher primitives for LMCS construction.
154pub mod hasher {
155    pub use p3_miden_stateful_hasher::{
156        Alignable, ChainingHasher, SerializingStatefulSponge, StatefulHasher, StatefulSponge,
157    };
158}