@@ -8,10 +8,9 @@ use super::{
88 statement:: { Constraint , Statement , Weights } ,
99} ;
1010use crate :: {
11- crypto:: proof_of_work,
1211 poly_utils:: { coeffs:: CoefficientList , multilinear:: MultilinearPoint } ,
13- sumcheck:: SumcheckPolynomial ,
14- transcript:: { codecs:: U64 , ProverMessage , VerifierMessage , VerifierState } ,
12+ sumcheck,
13+ transcript:: { codecs:: U64 , FieldConfig , ProverMessage , VerifierMessage , VerifierState } ,
1514 utils:: expand_randomness,
1615 whir:: { merkle, prover:: RootPath , utils:: get_challenge_stir_queries} ,
1716} ;
@@ -81,12 +80,17 @@ where
8180 round_constraints. push ( ( combination_randomness, constraints) ) ;
8281
8382 // Initial sumcheck
84- let folding_randomness = self . verify_sumcheck_rounds (
85- verifier_state,
86- & mut claimed_sum,
87- self . params . folding_factor . at_round ( 0 ) ,
88- self . params . starting_folding_pow_bits ,
89- ) ?;
83+ let config = sumcheck:: Config {
84+ field : FieldConfig :: new ( ) ,
85+ initial_size : 1 << self . params . folding_factor . at_round ( 0 ) , // Not used
86+ rounds : vec ! [
87+ sumcheck:: RoundConfig {
88+ pow: self . params. starting_folding_pow_bits
89+ } ;
90+ self . params. folding_factor. at_round( 0 )
91+ ] ,
92+ } ;
93+ let folding_randomness = config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
9094 round_folding_randomness. push ( folding_randomness) ;
9195 } else {
9296 assert_eq ! ( prev_commitment. ood_points. len( ) , 0 ) ;
@@ -136,12 +140,17 @@ where
136140 self . combine_constraints ( verifier_state, & mut claimed_sum, & constraints) ?;
137141 round_constraints. push ( ( combination_randomness. clone ( ) , constraints) ) ;
138142
139- let folding_randomness = self . verify_sumcheck_rounds (
140- verifier_state,
141- & mut claimed_sum,
142- self . params . folding_factor . at_round ( round_index + 1 ) ,
143- round_params. folding_pow_bits ,
144- ) ?;
143+ let config = sumcheck:: Config {
144+ field : FieldConfig :: new ( ) ,
145+ initial_size : 1 << self . params . folding_factor . at_round ( round_index + 1 ) , // Not used
146+ rounds : vec ! [
147+ sumcheck:: RoundConfig {
148+ pow: round_params. folding_pow_bits
149+ } ;
150+ self . params. folding_factor. at_round( round_index + 1 )
151+ ] ,
152+ } ;
153+ let folding_randomness = config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
145154 round_folding_randomness. push ( folding_randomness) ;
146155
147156 // Update round parameters
@@ -172,12 +181,18 @@ where
172181 return Err ( VerificationError ) ;
173182 }
174183
175- let final_sumcheck_randomness = self . verify_sumcheck_rounds (
176- verifier_state,
177- & mut claimed_sum,
178- self . params . final_sumcheck_rounds ,
179- self . params . final_folding_pow_bits ,
180- ) ?;
184+ let config = sumcheck:: Config {
185+ field : FieldConfig :: new ( ) ,
186+ initial_size : 1 << self . params . final_sumcheck_rounds , // Not used
187+ rounds : vec ! [
188+ sumcheck:: RoundConfig {
189+ pow: self . params. final_folding_pow_bits
190+ } ;
191+ self . params. final_sumcheck_rounds
192+ ] ,
193+ } ;
194+ let final_sumcheck_randomness =
195+ config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
181196 round_folding_randomness. push ( final_sumcheck_randomness. clone ( ) ) ;
182197
183198 // Compute folding randomness across all rounds.
@@ -302,12 +317,17 @@ where
302317 round_constraints. push ( ( combination_randomness, all_constraints) ) ;
303318
304319 // Initial sumcheck on the combined constraints
305- let folding_randomness = self . verify_sumcheck_rounds (
306- verifier_state,
307- & mut claimed_sum,
308- self . params . folding_factor . at_round ( 0 ) ,
309- self . params . starting_folding_pow_bits ,
310- ) ?;
320+ let config = sumcheck:: Config {
321+ field : FieldConfig :: new ( ) ,
322+ initial_size : 1 << self . params . folding_factor . at_round ( 0 ) , // Not used
323+ rounds : vec ! [
324+ sumcheck:: RoundConfig {
325+ pow: self . params. starting_folding_pow_bits
326+ } ;
327+ self . params. folding_factor. at_round( 0 )
328+ ] ,
329+ } ;
330+ let folding_randomness = config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
311331 round_folding_randomness. push ( folding_randomness) ;
312332 } else {
313333 for commitment in parsed_commitments {
@@ -423,12 +443,17 @@ where
423443 self . combine_constraints ( verifier_state, & mut claimed_sum, & constraints) ?;
424444 round_constraints. push ( ( combination_randomness, constraints) ) ;
425445
426- let folding_randomness = self . verify_sumcheck_rounds (
427- verifier_state,
428- & mut claimed_sum,
429- self . params . folding_factor . at_round ( 1 ) ,
430- round_params. folding_pow_bits ,
431- ) ?;
446+ let config = sumcheck:: Config {
447+ field : FieldConfig :: new ( ) ,
448+ initial_size : 1 << self . params . folding_factor . at_round ( 1 ) , // Not used
449+ rounds : vec ! [
450+ sumcheck:: RoundConfig {
451+ pow: round_params. folding_pow_bits
452+ } ;
453+ self . params. folding_factor. at_round( 1 )
454+ ] ,
455+ } ;
456+ let folding_randomness = config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
432457 round_folding_randomness. push ( folding_randomness) ;
433458
434459 // Rounds 1+: Standard WHIR verification on the single batched polynomial
@@ -460,12 +485,17 @@ where
460485 self . combine_constraints ( verifier_state, & mut claimed_sum, & constraints) ?;
461486 round_constraints. push ( ( combination_randomness. clone ( ) , constraints) ) ;
462487
463- let folding_randomness = self . verify_sumcheck_rounds (
464- verifier_state,
465- & mut claimed_sum,
466- self . params . folding_factor . at_round ( round_index + 1 ) ,
467- round_params. folding_pow_bits ,
468- ) ?;
488+ let config = sumcheck:: Config {
489+ field : FieldConfig :: new ( ) ,
490+ initial_size : 1 << self . params . folding_factor . at_round ( round_index + 1 ) , // Not used
491+ rounds : vec ! [
492+ sumcheck:: RoundConfig {
493+ pow: round_params. folding_pow_bits
494+ } ;
495+ self . params. folding_factor. at_round( round_index + 1 )
496+ ] ,
497+ } ;
498+ let folding_randomness = config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
469499 round_folding_randomness. push ( folding_randomness) ;
470500
471501 prev_commitment = new_commitment;
@@ -493,12 +523,18 @@ where
493523 return Err ( VerificationError ) ;
494524 }
495525
496- let final_sumcheck_randomness = self . verify_sumcheck_rounds (
497- verifier_state,
498- & mut claimed_sum,
499- self . params . final_sumcheck_rounds ,
500- self . params . final_folding_pow_bits ,
501- ) ?;
526+ let config = sumcheck:: Config {
527+ field : FieldConfig :: new ( ) ,
528+ initial_size : 1 << self . params . final_sumcheck_rounds , // Not used
529+ rounds : vec ! [
530+ sumcheck:: RoundConfig {
531+ pow: self . params. final_folding_pow_bits
532+ } ;
533+ self . params. final_sumcheck_rounds
534+ ] ,
535+ } ;
536+ let final_sumcheck_randomness =
537+ config. verify ( verifier_state. inner_mut ( ) , & mut claimed_sum) ?;
502538 round_folding_randomness. push ( final_sumcheck_randomness. clone ( ) ) ;
503539
504540 // Compute folding randomness across all rounds
@@ -552,52 +588,6 @@ where
552588 Ok ( combination_randomness)
553589 }
554590
555- /// Verify rounds of sumcheck updating the claimed_sum and returning the folding randomness.
556- pub fn verify_sumcheck_rounds < H > (
557- & self ,
558- verifier_state : & mut VerifierState < ' _ , H > ,
559- claimed_sum : & mut F ,
560- rounds : usize ,
561- proof_of_work : proof_of_work:: Config ,
562- ) -> VerificationResult < MultilinearPoint < F > >
563- where
564- H : DuplexSpongeInterface ,
565- F : Codec < [ H :: U ] > ,
566- u8 : Decoding < [ H :: U ] > ,
567- [ u8 ; 32 ] : Decoding < [ H :: U ] > ,
568- U64 : Codec < [ H :: U ] > ,
569- MerkleConfig :: InnerDigest : ProverMessage < [ H :: U ] > ,
570- {
571- let mut randomness = Vec :: with_capacity ( rounds) ;
572- for _ in 0 ..rounds {
573- // Receive this round's sumcheck polynomial
574- let mut sumcheck_poly_evals = [ F :: zero ( ) ; 3 ] ;
575- for eval in & mut sumcheck_poly_evals {
576- * eval = verifier_state. prover_message ( ) ?;
577- }
578-
579- let sumcheck_poly = SumcheckPolynomial :: new ( sumcheck_poly_evals. to_vec ( ) , 1 ) ;
580-
581- // Verify claimed sum is consistent with polynomial
582- if sumcheck_poly. sum_over_boolean_hypercube ( ) != * claimed_sum {
583- return Err ( VerificationError ) ;
584- }
585-
586- // Proof of work per round
587- proof_of_work. verify ( verifier_state. inner_mut ( ) ) ?;
588-
589- // Receive folding randomness
590- let folding_randomness_single: F = verifier_state. verifier_message ( ) ;
591- randomness. push ( folding_randomness_single) ;
592-
593- // Update claimed sum using folding randomness
594- * claimed_sum = sumcheck_poly. evaluate_at_point ( & folding_randomness_single. into ( ) ) ;
595- }
596-
597- randomness. reverse ( ) ;
598- Ok ( MultilinearPoint ( randomness) )
599- }
600-
601591 /// Verify a STIR challenges against a commitment and return the constraints.
602592 pub fn verify_stir_challenges < H > (
603593 & self ,
0 commit comments