@@ -10,10 +10,25 @@ use super::timer::Timer;
1010use super :: transcript:: ProofTranscript ;
1111use crate :: scalar:: SpartanExtensionField ;
1212use crate :: { ProverWitnessSecInfo , VerifierWitnessSecInfo } ;
13+ use ff_ext:: ExtensionField ;
14+ use goldilocks:: GoldilocksExt2 ;
1315use merlin:: Transcript ;
16+ use multilinear_extensions:: mle:: DenseMultilinearExtension ;
1417use serde:: { Deserialize , Serialize } ;
1518use std:: cmp:: min;
1619use std:: iter:: zip;
20+ use std:: sync:: Arc ;
21+ use multilinear_extensions:: {
22+ mle:: IntoMLE ,
23+ virtual_poly:: VPAuxInfo ,
24+ virtual_poly_v2:: { ArcMultilinearExtension , VirtualPolynomialV2 } ,
25+ } ;
26+ use std:: iter;
27+ use ceno_zkvm:: virtual_polys:: VirtualPolynomials ;
28+ use sumcheck:: structs:: { IOPProverStateV2 , IOPVerifierState } ;
29+ use ff:: Field ;
30+ use halo2curves:: serde:: SerdeObject ;
31+ use transcript:: BasicTranscript ;
1732
1833#[ derive( Serialize , Deserialize , Debug ) ]
1934pub struct R1CSProof < S : SpartanExtensionField > {
@@ -206,9 +221,9 @@ impl<S: SpartanExtensionField + Send + Sync> R1CSProof<S> {
206221 num_witness_secs. log_2 ( ) ,
207222 max_num_inputs. log_2 ( ) ,
208223 ) ;
209- let tau_p = transcript. challenge_vector ( b"challenge_tau_p" , num_rounds_p) ;
210- let tau_q = transcript. challenge_vector ( b"challenge_tau_q" , num_rounds_q) ;
211- let tau_x = transcript. challenge_vector ( b"challenge_tau_x" , num_rounds_x) ;
224+ let tau_p: Vec < S > = transcript. challenge_vector ( b"challenge_tau_p" , num_rounds_p) ;
225+ let tau_q: Vec < S > = transcript. challenge_vector ( b"challenge_tau_q" , num_rounds_q) ;
226+ let tau_x: Vec < S > = transcript. challenge_vector ( b"challenge_tau_x" , num_rounds_x) ;
212227
213228 // compute the initial evaluation table for R(\tau, x)
214229 let mut poly_tau_p = DensePolynomial :: new ( EqPolynomial :: new ( tau_p) . evals ( ) ) ;
@@ -226,6 +241,70 @@ impl<S: SpartanExtensionField + Send + Sync> R1CSProof<S> {
226241 ) ;
227242 timer_tmp. stop ( ) ;
228243
244+ // == test: ceno_verifier_bench ==
245+ let B = poly_Az. to_dense_poly ( ) ;
246+ let C = poly_Bz. to_dense_poly ( ) ;
247+ let D = poly_Cz. to_dense_poly ( ) ;
248+
249+ let z_len = B . Z . len ( ) ;
250+ let tau_pqx_len = poly_tau_p. Z . len ( ) + poly_tau_q. Z . len ( ) + poly_tau_x. Z . len ( ) ;
251+ let A = DensePolynomial :: new (
252+ poly_tau_p. clone ( ) . Z
253+ . into_iter ( )
254+ . chain ( poly_tau_q. clone ( ) . Z )
255+ . chain ( poly_tau_x. clone ( ) . Z )
256+ . chain ( iter:: repeat ( S :: field_zero ( ) ) . take ( z_len - tau_pqx_len) )
257+ . collect ( )
258+ ) ;
259+
260+ let arc_A: ArcMultilinearExtension < ' _ , GoldilocksExt2 > = Arc :: new (
261+ A . Z . iter ( ) . cloned ( ) . map ( |s|
262+ GoldilocksExt2 :: from_raw_bytes_unchecked ( & s. inner ( ) . to_raw_bytes ( ) )
263+ )
264+ . collect :: < Vec < GoldilocksExt2 > > ( )
265+ . into_mle ( )
266+ ) ;
267+ let arc_B: ArcMultilinearExtension < ' _ , GoldilocksExt2 > = Arc :: new (
268+ B . Z . iter ( ) . cloned ( ) . map ( |s|
269+ GoldilocksExt2 :: from_raw_bytes_unchecked ( & s. inner ( ) . to_raw_bytes ( ) )
270+ )
271+ . collect :: < Vec < GoldilocksExt2 > > ( )
272+ . into_mle ( )
273+ ) ;
274+ let arc_C: ArcMultilinearExtension < ' _ , GoldilocksExt2 > = Arc :: new (
275+ C . Z . iter ( ) . cloned ( ) . map ( |s|
276+ GoldilocksExt2 :: from_raw_bytes_unchecked ( & s. inner ( ) . to_raw_bytes ( ) )
277+ )
278+ . collect :: < Vec < GoldilocksExt2 > > ( )
279+ . into_mle ( )
280+ ) ;
281+ let arc_D: ArcMultilinearExtension < ' _ , GoldilocksExt2 > = Arc :: new (
282+ D . Z . iter ( ) . cloned ( ) . map ( |s|
283+ GoldilocksExt2 :: from_raw_bytes_unchecked ( & s. inner ( ) . to_raw_bytes ( ) )
284+ )
285+ . collect :: < Vec < GoldilocksExt2 > > ( )
286+ . into_mle ( )
287+ ) ;
288+
289+ let max_num_vars = 22 ;
290+ let num_threads = 8 ;
291+ let virtual_polys: VirtualPolynomialV2 < ' _ , GoldilocksExt2 > = VirtualPolynomialV2 :: new ( max_num_vars) ;
292+
293+ let mut virtual_polys = VirtualPolynomials :: < GoldilocksExt2 > :: new ( num_threads, max_num_vars) ;
294+ virtual_polys. add_mle_list ( vec ! [ & arc_A, & arc_B, & arc_C] , GoldilocksExt2 :: ONE ) ;
295+ virtual_polys. add_mle_list ( vec ! [ & arc_A, & arc_D] , GoldilocksExt2 :: ZERO - GoldilocksExt2 :: ONE ) ;
296+
297+ let mut ceno_transcript = BasicTranscript :: new ( b"test" ) ;
298+
299+ let timer_tmp = Timer :: new ( "=> prove_sum_check with ceno: IOPProverStateV2::prove_batch_polys" ) ;
300+ let ( sumcheck_proofs, _) = IOPProverStateV2 :: prove_batch_polys (
301+ num_threads,
302+ virtual_polys. get_batched_polys ( ) ,
303+ & mut ceno_transcript,
304+ ) ;
305+ timer_tmp. stop ( ) ;
306+ // == test: ceno_verifier_bench ==
307+
229308 // Sumcheck 1: (Az * Bz - Cz) * eq(x, q, p) = 0
230309 let timer_tmp = Timer :: new ( "prove_sum_check" ) ;
231310 let ( sc_proof_phase1, rx, _claims_phase1) = R1CSProof :: prove_phase_one (
0 commit comments