@@ -6,7 +6,6 @@ use crate::scalar::SpartanExtensionField;
66
77use super :: dense_mlpoly:: DensePolynomial ;
88use super :: errors:: ProofVerifyError ;
9- use super :: nizk:: DotProductProof ;
109use super :: random:: RandomTape ;
1110use super :: transcript:: { AppendToTranscript , ProofTranscript } ;
1211use super :: unipoly:: { CompressedUniPoly , UniPoly } ;
@@ -70,67 +69,6 @@ impl<S: SpartanExtensionField> SumcheckInstanceProof<S> {
7069 }
7170}
7271
73- #[ derive( Serialize , Deserialize , Debug ) ]
74- pub struct R1CSSumcheckInstanceProof < S : SpartanExtensionField > {
75- proofs : Vec < DotProductProof < S > > ,
76- }
77-
78- impl < S : SpartanExtensionField > R1CSSumcheckInstanceProof < S > {
79- pub fn new ( proofs : Vec < DotProductProof < S > > ) -> Self {
80- R1CSSumcheckInstanceProof { proofs }
81- }
82-
83- pub fn verify (
84- & self ,
85- num_rounds : usize ,
86- degree_bound : usize ,
87- transcript : & mut Transcript ,
88- ) -> Result < Vec < S > , ProofVerifyError > {
89- let mut r: Vec < S > = Vec :: new ( ) ;
90-
91- for i in 0 ..num_rounds {
92- // derive the verifier's challenge for the next round
93- let r_i = transcript. challenge_scalar ( b"challenge_nextround" ) ;
94-
95- // verify the proof of sum-check and evals
96- let _res = {
97- // produce two weights
98- let w: Vec < S > = transcript. challenge_vector ( b"combine_two_claims_to_one" , 2 ) ;
99-
100- let a = {
101- // the vector to use to decommit for sum-check test
102- let a_sc = {
103- let mut a = vec ! [ S :: field_one( ) ; degree_bound + 1 ] ;
104- a[ 0 ] = a[ 0 ] + S :: field_one ( ) ;
105- a
106- } ;
107-
108- // the vector to use to decommit for evaluation
109- let a_eval = {
110- let mut a = vec ! [ S :: field_one( ) ; degree_bound + 1 ] ;
111- for j in 1 ..a. len ( ) {
112- a[ j] = a[ j - 1 ] * r_i;
113- }
114- a
115- } ;
116-
117- // take weighted sum of the two vectors using w
118- assert_eq ! ( a_sc. len( ) , a_eval. len( ) ) ;
119- ( 0 ..a_sc. len ( ) )
120- . map ( |i| w[ 0 ] * a_sc[ i] + w[ 1 ] * a_eval[ i] )
121- . collect :: < Vec < S > > ( )
122- } ;
123-
124- self . proofs [ i] . verify ( transcript, & a) . is_ok ( )
125- } ;
126-
127- r. push ( r_i) ;
128- }
129-
130- Ok ( r)
131- }
132- }
133-
13472impl < S : SpartanExtensionField > SumcheckInstanceProof < S > {
13573 pub fn prove_cubic < F > (
13674 claim : & S ,
@@ -379,9 +317,7 @@ impl<S: SpartanExtensionField> SumcheckInstanceProof<S> {
379317 claims_dotp,
380318 )
381319 }
382- }
383320
384- impl < S : SpartanExtensionField > R1CSSumcheckInstanceProof < S > {
385321 pub fn prove_cubic_disjoint_rounds < F > (
386322 claim : & S ,
387323 num_rounds : usize ,
@@ -396,7 +332,6 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
396332 poly_C : & mut DensePolynomialPqx < S > ,
397333 comb_func : F ,
398334 transcript : & mut Transcript ,
399- random_tape : & mut RandomTape < S > ,
400335 ) -> ( Self , Vec < S > , Vec < S > )
401336 where
402337 F : Fn ( & S , & S , & S ) -> S ,
@@ -410,7 +345,7 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
410345 let mut claim_per_round = * claim;
411346
412347 let mut r: Vec < S > = Vec :: new ( ) ;
413- let mut proofs : Vec < DotProductProof < S > > = Vec :: new ( ) ;
348+ let mut cubic_polys : Vec < CompressedUniPoly < S > > = Vec :: new ( ) ;
414349
415350 let mut inputs_len = num_rounds_y_max. pow2 ( ) ;
416351 let mut witness_secs_len = num_rounds_w. pow2 ( ) ;
@@ -540,8 +475,12 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
540475 poly
541476 } ;
542477
478+ // append the prover's message to the transcript
479+ poly. append_to_transcript ( b"poly" , transcript) ;
480+
543481 //derive the verifier's challenge for the next round
544482 let r_j = transcript. challenge_scalar ( b"challenge_nextround" ) ;
483+ r. push ( r_j) ;
545484
546485 // bound all tables to the verifier's challenege
547486 if mode == MODE_P {
@@ -552,61 +491,12 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
552491 }
553492 poly_C. bound_poly ( & r_j, mode) ;
554493
555- // produce a proof of sum-check and of evaluation
556- let ( proof, claim_next_round) = {
557- let eval = poly. evaluate ( & r_j) ;
558-
559- // we need to prove the following under homomorphic commitments:
560- // (1) poly(0) + poly(1) = claim_per_round
561- // (2) poly(r_j) = eval
562-
563- // Our technique is to leverage dot product proofs:
564- // (1) we can prove: <poly_in_coeffs_form, (2, 1, 1, 1)> = claim_per_round
565- // (2) we can prove: <poly_in_coeffs_form, (1, r_j, r^2_j, ..) = eval
566- // for efficiency we batch them using random weights
567-
568- // produce two weights
569- let w: Vec < S > = transcript. challenge_vector ( b"combine_two_claims_to_one" , 2 ) ;
570-
571- // compute a weighted sum of the RHS
572- let target = w[ 0 ] * claim_per_round + w[ 1 ] * eval;
573-
574- let a = {
575- // the vector to use to decommit for sum-check test
576- let a_sc = {
577- let mut a = vec ! [ S :: field_one( ) ; poly. degree( ) + 1 ] ;
578- a[ 0 ] = a[ 0 ] + S :: field_one ( ) ;
579- a
580- } ;
581-
582- // the vector to use to decommit for evaluation
583- let a_eval = {
584- let mut a = vec ! [ S :: field_one( ) ; poly. degree( ) + 1 ] ;
585- for j in 1 ..a. len ( ) {
586- a[ j] = a[ j - 1 ] * r_j;
587- }
588- a
589- } ;
590-
591- // take weighted sum of the two vectors using w
592- assert_eq ! ( a_sc. len( ) , a_eval. len( ) ) ;
593- ( 0 ..a_sc. len ( ) )
594- . map ( |i| w[ 0 ] * a_sc[ i] + w[ 1 ] * a_eval[ i] )
595- . collect :: < Vec < S > > ( )
596- } ;
597-
598- let proof = DotProductProof :: prove ( transcript, random_tape, & poly. as_vec ( ) , & a, & target) ;
599-
600- ( proof, eval)
601- } ;
602-
603- proofs. push ( proof) ;
604- claim_per_round = claim_next_round;
605- r. push ( r_j) ;
494+ claim_per_round = poly. evaluate ( & r_j) ;
495+ cubic_polys. push ( poly. compress ( ) ) ;
606496 }
607497
608498 (
609- R1CSSumcheckInstanceProof :: new ( proofs ) ,
499+ SumcheckInstanceProof :: new ( cubic_polys ) ,
610500 r,
611501 vec ! [
612502 poly_A[ 0 ] ,
@@ -653,7 +543,7 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
653543 let mut claim_per_round = * claim;
654544
655545 let mut r: Vec < S > = Vec :: new ( ) ;
656- let mut proofs : Vec < DotProductProof < S > > = Vec :: new ( ) ;
546+ let mut cubic_polys : Vec < CompressedUniPoly < S > > = Vec :: new ( ) ;
657547
658548 let mut cons_len = num_rounds_x_max. pow2 ( ) ;
659549 let mut proof_len = num_rounds_q_max. pow2 ( ) ;
@@ -798,8 +688,12 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
798688 poly
799689 } ;
800690
691+ // append the prover's message to the transcript
692+ poly. append_to_transcript ( b"poly" , transcript) ;
693+
801694 //derive the verifier's challenge for the next round
802695 let r_j = transcript. challenge_scalar ( b"challenge_nextround" ) ;
696+ r. push ( r_j) ;
803697
804698 // bound all tables to the verifier's challenege
805699 if mode == 1 {
@@ -813,60 +707,12 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
813707 poly_C. bound_poly ( & r_j, mode) ;
814708 poly_D. bound_poly ( & r_j, mode) ;
815709
816- let ( proof, claim_next_round) = {
817- let eval = poly. evaluate ( & r_j) ;
818-
819- // we need to prove the following under homomorphic commitments:
820- // (1) poly(0) + poly(1) = claim_per_round
821- // (2) poly(r_j) = eval
822-
823- // Our technique is to leverage dot product proofs:
824- // (1) we can prove: <poly_in_coeffs_form, (2, 1, 1, 1)> = claim_per_round
825- // (2) we can prove: <poly_in_coeffs_form, (1, r_j, r^2_j, ..) = eval
826- // for efficiency we batch them using random weights
827-
828- // produce two weights
829- let w: Vec < S > = transcript. challenge_vector ( b"combine_two_claims_to_one" , 2 ) ;
830-
831- // compute a weighted sum of the RHS
832- let target = w[ 0 ] * claim_per_round + w[ 1 ] * eval;
833-
834- let a = {
835- // the vector to use to decommit for sum-check test
836- let a_sc = {
837- let mut a = vec ! [ S :: field_one( ) ; poly. degree( ) + 1 ] ;
838- a[ 0 ] = a[ 0 ] + S :: field_one ( ) ;
839- a
840- } ;
841-
842- // the vector to use to decommit for evaluation
843- let a_eval = {
844- let mut a = vec ! [ S :: field_one( ) ; poly. degree( ) + 1 ] ;
845- for j in 1 ..a. len ( ) {
846- a[ j] = a[ j - 1 ] * r_j;
847- }
848- a
849- } ;
850-
851- // take weighted sum of the two vectors using w
852- assert_eq ! ( a_sc. len( ) , a_eval. len( ) ) ;
853- ( 0 ..a_sc. len ( ) )
854- . map ( |i| w[ 0 ] * a_sc[ i] + w[ 1 ] * a_eval[ i] )
855- . collect :: < Vec < S > > ( )
856- } ;
857-
858- let proof = DotProductProof :: prove ( transcript, random_tape, & poly. as_vec ( ) , & a, & target) ;
859-
860- ( proof, eval)
861- } ;
862-
863- proofs. push ( proof) ;
864- claim_per_round = claim_next_round;
865- r. push ( r_j) ;
710+ claim_per_round = poly. evaluate ( & r_j) ;
711+ cubic_polys. push ( poly. compress ( ) ) ;
866712 }
867713
868714 (
869- R1CSSumcheckInstanceProof :: new ( proofs ) ,
715+ SumcheckInstanceProof :: new ( cubic_polys ) ,
870716 r,
871717 vec ! [
872718 poly_Ap[ 0 ] * poly_Aq[ 0 ] * poly_Ax[ 0 ] ,
@@ -876,4 +722,4 @@ impl<S: SpartanExtensionField> R1CSSumcheckInstanceProof<S> {
876722 ] ,
877723 )
878724 }
879- }
725+ }
0 commit comments