@@ -4,14 +4,15 @@ use crate::group::{Fq, Fr};
44use  crate :: math:: Math ; 
55use  crate :: parameters:: poseidon_params; 
66use  crate :: poseidon_transcript:: { AppendToPoseidon ,  PoseidonTranscript } ; 
7- use  crate :: sqrt_pst:: PolyList ; 
7+ use  crate :: sqrt_pst:: Polynomial ; 
88use  crate :: sumcheck:: SumcheckInstanceProof ; 
99use  ark_bls12_377:: Bls12_377  as  I ; 
1010use  ark_bw6_761:: BW6_761  as  P ; 
1111use  ark_ec:: PairingEngine ; 
1212use  ark_poly:: MultilinearExtension ; 
1313use  ark_poly_commit:: multilinear_pc:: data_structures:: { Commitment ,  Proof } ; 
1414use  ark_poly_commit:: multilinear_pc:: MultilinearPC ; 
15+ use  snarkpack:: mipp:: MippProof ; 
1516
1617use  super :: commitments:: MultiCommitGens ; 
1718use  super :: dense_mlpoly:: { DensePolynomial ,  EqPolynomial ,  PolyCommitmentGens } ; 
@@ -45,6 +46,7 @@ pub struct R1CSProof {
4546  // The transcript state after the satisfiability proof was computed. 
4647  pub  transcript_sat_state :  Scalar , 
4748  pub  t :  <I  as  PairingEngine >:: Fqk , 
49+   pub  mipp_proof :  MippProof < I > , 
4850} 
4951#[ derive( Clone ) ]  
5052pub  struct  R1CSSumcheckGens  { 
@@ -146,12 +148,12 @@ impl R1CSProof {
146148
147149    // create the multilinear witness polynomial from the satisfying assiment 
148150    // expressed as the list of sqrt-sized polynomials 
149-     let  pl = PolyList :: new ( & vars. clone ( ) ) ; 
151+     let  mut   pl = Polynomial :: from_evaluations ( & vars. clone ( ) ) ; 
150152
151153    let  timer_commit = Timer :: new ( "polycommit" ) ; 
152154
153155    // commitment list to the satisfying witness polynomial list 
154-     let  ( comm_list,  t)  = PolyList :: commit ( & pl ,   & gens. gens_pc . ck ) ; 
156+     let  ( comm_list,  t)  = pl . commit ( & gens. gens_pc . ck ) ; 
155157
156158    let  mut  bytes = Vec :: new ( ) ; 
157159    t. serialize ( & mut  bytes) . unwrap ( ) ; 
@@ -237,31 +239,28 @@ impl R1CSProof {
237239      transcript, 
238240    ) ; 
239241    timer_sc_proof_phase2. stop ( ) ; 
242+     let  c = transcript. challenge_scalar ( ) ; 
243+     transcript. new_from_state ( & c) ; 
240244
241245    // TODO: modify the polynomial evaluation in Spartan to be consistent 
242246    // with the evaluation in ark-poly-commit so that reversing is not needed 
243247    // anymore 
244248    let  timmer_opening = Timer :: new ( "polyopening" ) ; 
245-     let  mut  dummy = ry[ 1 ..] . to_vec ( ) . clone ( ) ; 
246-     dummy. reverse ( ) ; 
247-     let  q = pl. get_q ( & dummy) ; 
249+     timer_prove. stop ( ) ; 
248250
249-     let  ( comm,  proof_eval_vars_at_ry)  = PolyList :: open_q ( comm_list,  & gens. gens_pc . ck ,  & q,  & dummy) ; 
251+     let  ( comm,  proof_eval_vars_at_ry,  mipp_proof)  =
252+       pl. open ( transcript,  comm_list,  & gens. gens_pc . ck ,  & ry[ 1 ..] ,  & t) ; 
250253    println ! ( 
251254      "proof size (no of quotients): {:?}" , 
252255      proof_eval_vars_at_ry. proofs. len( ) 
253256    ) ; 
254-      // comm.append_to_poseidon(transcript); 
257+ 
255258    timmer_opening. stop ( ) ; 
256259
257260    let  timer_polyeval = Timer :: new ( "polyeval" ) ; 
258-     let  eval_vars_at_ry = PolyList :: eval_q ( q . clone ( ) ,   & dummy ) ; 
261+     let  eval_vars_at_ry = pl . eval ( & ry [ 1 .. ] ) ; 
259262    timer_polyeval. stop ( ) ; 
260263
261-     timer_prove. stop ( ) ; 
262- 
263-     let  c = transcript. challenge_scalar ( ) ; 
264- 
265264    ( 
266265      R1CSProof  { 
267266        comm, 
@@ -273,7 +272,8 @@ impl R1CSProof {
273272        rx :  rx. clone ( ) , 
274273        ry :  ry. clone ( ) , 
275274        transcript_sat_state :  c, 
276-         t :  t, 
275+         t, 
276+         mipp_proof, 
277277      } , 
278278      rx, 
279279      ry, 
@@ -333,6 +333,7 @@ impl R1CSProof {
333333    let  dp1 = start. elapsed ( ) . as_millis ( ) ; 
334334    prove_inner. stop ( ) ; 
335335
336+     // this is universal, we don't measure it 
336337    let  start = Instant :: now ( ) ; 
337338    let  ( pk,  vk)  = Groth16 :: < P > :: setup ( circuit. clone ( ) ,  & mut  rng) . unwrap ( ) ; 
338339    let  ds = start. elapsed ( ) . as_millis ( ) ; 
@@ -344,24 +345,25 @@ impl R1CSProof {
344345    prove_outer. stop ( ) ; 
345346
346347    let  start = Instant :: now ( ) ; 
348+     let  verifier_time = Timer :: new ( "groth16_verification" ) ; 
347349    let  is_verified = Groth16 :: < P > :: verify ( & vk,  & [ ] ,  & proof) . unwrap ( ) ; 
348350    assert ! ( is_verified) ; 
351+     verifier_time. stop ( ) ; 
349352
350353    let  timer_verification = Timer :: new ( "commitverification" ) ; 
351-     let  mut  dummy = self . ry [ 1 ..] . to_vec ( ) ; 
352-     // TODO: ensure ark-poly-commit and Spartan produce consistent results 
353-     // when evaluating a polynomial at a given point so this reverse is not 
354-     // needed. 
355-     dummy. reverse ( ) ; 
354+     transcript. new_from_state ( & self . transcript_sat_state ) ; 
356355
357356    // Verifies the proof of opening against the result of evaluating the 
358357    // witness polynomial at point ry. 
359-     let  res = PolyList :: verify_q ( 
358+     let  res = Polynomial :: verify ( 
359+       transcript, 
360360      & gens. gens_pc . vk , 
361361      & self . comm , 
362-       & dummy , 
362+       & self . ry [ 1 .. ] , 
363363      self . eval_vars_at_ry , 
364364      & self . proof_eval_vars_at_ry , 
365+       & self . mipp_proof , 
366+       & self . t , 
365367    ) ; 
366368
367369    timer_verification. stop ( ) ; 
@@ -382,7 +384,10 @@ impl R1CSProof {
382384    transcript :  & mut  PoseidonTranscript , 
383385    gens :  & R1CSGens , 
384386  )  -> Result < usize ,  ProofVerifyError >  { 
385-     // self.comm.append_to_poseidon(transcript); 
387+     // serialise and add the IPP commitment to the transcript 
388+     let  mut  bytes = Vec :: new ( ) ; 
389+     self . t . serialize ( & mut  bytes) . unwrap ( ) ; 
390+     transcript. append_bytes ( & bytes) ; 
386391
387392    let  c = transcript. challenge_scalar ( ) ; 
388393
0 commit comments