@@ -18,8 +18,7 @@ use circuits_stark_verifier::proof_from_stark_proof::{
1818use itertools:: chain;
1919use num_traits:: Zero ;
2020use stwo:: core:: air:: Component ;
21- use stwo:: core:: channel:: Blake2sM31Channel ;
22- use stwo:: core:: channel:: Channel ;
21+ use stwo:: core:: channel:: { Channel , MerkleChannel } ;
2322use stwo:: core:: fields:: qm31:: QM31 ;
2423use stwo:: core:: pcs:: PcsConfig ;
2524use stwo:: core:: poly:: circle:: CanonicCoset ;
@@ -28,6 +27,7 @@ use stwo::core::proof_of_work::GrindOps;
2827use stwo:: core:: utils:: MaybeOwned ;
2928use stwo:: core:: vcs_lifted:: blake2_merkle:: Blake2sM31MerkleChannel ;
3029use stwo:: core:: vcs_lifted:: blake2_merkle:: Blake2sM31MerkleHasher ;
30+ use stwo:: core:: vcs_lifted:: merkle_hasher:: MerkleHasherLifted ;
3131use stwo:: prover:: CommitmentSchemeProver ;
3232use stwo:: prover:: CommitmentTreeProver ;
3333use stwo:: prover:: ComponentProver ;
@@ -39,13 +39,13 @@ use stwo::prover::{ProvingError, prove_ex};
3939
4040const COMPOSITION_POLYNOMIAL_LOG_DEGREE_BOUND : u32 = 1 ;
4141
42- pub struct CircuitProof {
42+ pub struct CircuitProof < H : MerkleHasherLifted > {
4343 pub pcs_config : PcsConfig ,
4444 pub claim : CircuitClaim ,
4545 pub interaction_pow_nonce : u64 ,
4646 pub interaction_claim : CircuitInteractionClaim ,
4747 pub components : Vec < Box < dyn Component > > ,
48- pub stark_proof : Result < ExtendedStarkProof < Blake2sM31MerkleHasher > , ProvingError > ,
48+ pub stark_proof : Result < ExtendedStarkProof < H > , ProvingError > ,
4949 pub channel_salt : u32 ,
5050}
5151
@@ -82,7 +82,25 @@ pub fn prove_circuit_assignment(
8282 preprocessed_circuit : & PreprocessedCircuit ,
8383 base_column_pool : & BaseColumnPool < SimdBackend > ,
8484 pcs_config : PcsConfig ,
85- ) -> CircuitProof {
85+ ) -> CircuitProof < Blake2sM31MerkleHasher > {
86+ prove_circuit_assignment_with_channel :: < Blake2sM31MerkleChannel > (
87+ values,
88+ preprocessed_circuit,
89+ base_column_pool,
90+ pcs_config,
91+ )
92+ }
93+
94+ pub fn prove_circuit_assignment_with_channel < MC > (
95+ values : & [ QM31 ] ,
96+ preprocessed_circuit : & PreprocessedCircuit ,
97+ base_column_pool : & BaseColumnPool < SimdBackend > ,
98+ pcs_config : PcsConfig ,
99+ ) -> CircuitProof < MC :: H >
100+ where
101+ MC : MerkleChannel ,
102+ SimdBackend : stwo:: prover:: backend:: BackendForChannel < MC > ,
103+ {
86104 let trace_log_size = preprocessed_circuit. params . trace_log_size ;
87105 let lifting_log_size = trace_log_size + pcs_config. fri_config . log_blowup_factor ;
88106 let pcs_config = PcsConfig { lifting_log_size : Some ( lifting_log_size) , ..pcs_config } ;
@@ -106,7 +124,7 @@ pub fn prove_circuit_assignment(
106124 let preprocessed_trace_polys = SimdBackend :: interpolate_columns ( preprocessed_trace, & twiddles) ;
107125
108126 let store_polynomials_coefficients = true ;
109- let preprocessed_tree = CommitmentTreeProver :: < SimdBackend , Blake2sM31MerkleChannel > :: new (
127+ let preprocessed_tree = CommitmentTreeProver :: < SimdBackend , MC > :: new (
110128 preprocessed_trace_polys,
111129 pcs_config. fri_config . log_blowup_factor ,
112130 & twiddles,
@@ -115,7 +133,7 @@ pub fn prove_circuit_assignment(
115133 base_column_pool,
116134 ) ;
117135
118- prove_circuit_with_precompute (
136+ prove_circuit_with_precompute :: < MC > (
119137 base_column_pool,
120138 & twiddles,
121139 preprocessed_circuit,
@@ -125,14 +143,18 @@ pub fn prove_circuit_assignment(
125143 )
126144}
127145
128- pub fn prove_circuit_with_precompute < ' a > (
146+ pub fn prove_circuit_with_precompute < ' a , MC > (
129147 base_column_pool : & BaseColumnPool < SimdBackend > ,
130148 twiddles : & TwiddleTree < SimdBackend > ,
131149 preprocessed_circuit : & PreprocessedCircuit ,
132- preprocessed_tree : MaybeOwned < ' a , CommitmentTreeProver < SimdBackend , Blake2sM31MerkleChannel > > ,
150+ preprocessed_tree : MaybeOwned < ' a , CommitmentTreeProver < SimdBackend , MC > > ,
133151 values : & [ QM31 ] ,
134152 pcs_config : PcsConfig ,
135- ) -> CircuitProof {
153+ ) -> CircuitProof < MC :: H >
154+ where
155+ MC : MerkleChannel ,
156+ SimdBackend : stwo:: prover:: backend:: BackendForChannel < MC > ,
157+ {
136158 let PreprocessedCircuit { preprocessed_trace, params } = preprocessed_circuit;
137159 let CircuitParams { first_permutation_row, n_blake_gates, output_addresses, .. } = params;
138160 let trace_generator = TraceGenerator {
@@ -142,18 +164,17 @@ pub fn prove_circuit_with_precompute<'a>(
142164 } ;
143165
144166 // Setup protocol.
145- let channel = & mut Blake2sM31Channel :: default ( ) ;
167+ let channel = & mut MC :: C :: default ( ) ;
146168
147169 // Mix channel salt. Note that we first reduce it modulo `M31::P`, then cast it as QM31.
148170 let channel_salt = 0_u32 ;
149171 channel. mix_felts ( & [ channel_salt. into ( ) ] ) ;
150172 pcs_config. mix_into ( channel) ;
151- let mut commitment_scheme =
152- CommitmentSchemeProver :: < SimdBackend , Blake2sM31MerkleChannel > :: with_memory_pool (
153- pcs_config,
154- twiddles,
155- base_column_pool,
156- ) ;
173+ let mut commitment_scheme = CommitmentSchemeProver :: < SimdBackend , MC > :: with_memory_pool (
174+ pcs_config,
175+ twiddles,
176+ base_column_pool,
177+ ) ;
157178
158179 commitment_scheme. set_store_polynomials_coefficients ( ) ;
159180
@@ -225,7 +246,7 @@ pub fn prove_circuit_with_precompute<'a>(
225246}
226247
227248pub fn prepare_circuit_proof_for_circuit_verifier (
228- circuit_proof : CircuitProof ,
249+ circuit_proof : CircuitProof < Blake2sM31MerkleHasher > ,
229250 proof_config : & ProofConfig ,
230251) -> ( Proof < QM31 > , CircuitPublicData ) {
231252 let CircuitProof {
0 commit comments