@@ -8,9 +8,7 @@ use ff_ext::{Instrumented, PoseidonField};
88use super :: { ZKVMChipProof , ZKVMProof } ;
99use crate :: {
1010 error:: ZKVMError ,
11- instructions:: riscv:: constants:: {
12- END_PC_IDX , GLOBAL_RW_SUM_IDX , INIT_CYCLE_IDX , INIT_PC_IDX , SHARD_ID_IDX ,
13- } ,
11+ instructions:: riscv:: constants:: { END_PC_IDX , INIT_CYCLE_IDX , INIT_PC_IDX , SHARD_ID_IDX } ,
1412 scheme:: {
1513 constants:: { NUM_FANIN , SEPTIC_EXTENSION_DEGREE } ,
1614 septic_curve:: { SepticExtension , SepticPoint } ,
@@ -20,6 +18,7 @@ use crate::{
2018 ZKVMVerifyingKey ,
2119 } ,
2220} ;
21+ use ceno_emul:: Tracer ;
2322use gkr_iop:: {
2423 self ,
2524 selector:: { SelectorContext , SelectorType } ,
@@ -65,7 +64,7 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMVerifier<E, PCS>
6564 self . verify_proof_halt ( vm_proof, transcript, true )
6665 }
6766
68- #[ tracing:: instrument( skip_all, name = "verify_proof " ) ]
67+ #[ tracing:: instrument( skip_all, name = "verify_proofs " ) ]
6968 pub fn verify_proofs (
7069 & self ,
7170 vm_proofs : Vec < ZKVMProof < E , PCS > > ,
@@ -110,8 +109,9 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMVerifier<E, PCS>
110109 . into ( ) ,
111110 ) ) ;
112111 }
113- // check init cycle = 4
114- assert_eq ! ( vm_proof. pi_evals[ INIT_CYCLE_IDX ] , E :: from_canonical_usize( 4 ) ) ;
112+ // each shard set init cycle = Tracer::SUBCYCLES_PER_INSN
113+ // to satisfy initial reads for all prev_cycle = 0 < init_cycle
114+ assert_eq ! ( vm_proof. pi_evals[ INIT_CYCLE_IDX ] , E :: from_canonical_u64( Tracer :: SUBCYCLES_PER_INSN ) ) ;
115115 // check init_pc match prev end_pc
116116 if let Some ( prev_pc) = prev_pc {
117117 assert_eq ! ( vm_proof. pi_evals[ INIT_PC_IDX ] , prev_pc) ;
@@ -502,7 +502,7 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMVerifier<E, PCS>
502502 assert ! ( proof. ecc_proof. is_some( ) ) ;
503503 let ecc_proof = proof. ecc_proof . as_ref ( ) . unwrap ( ) ;
504504
505- let xy = cs
505+ let expected_septic_xy = cs
506506 . ec_final_sum
507507 . iter ( )
508508 . map ( |expr| {
@@ -512,30 +512,17 @@ impl<E: ExtensionField, PCS: PolynomialCommitmentScheme<E>> ZKVMVerifier<E, PCS>
512512 . unwrap ( )
513513 } )
514514 . collect_vec ( ) ;
515- let x: SepticExtension < E :: BaseField > = xy[ 0 ..SEPTIC_EXTENSION_DEGREE ] . into ( ) ;
516- let y: SepticExtension < E :: BaseField > = xy[ SEPTIC_EXTENSION_DEGREE ..] . into ( ) ;
515+ let expected_septic_x: SepticExtension < E :: BaseField > =
516+ expected_septic_xy[ 0 ..SEPTIC_EXTENSION_DEGREE ] . into ( ) ;
517+ let expected_septic_y: SepticExtension < E :: BaseField > =
518+ expected_septic_xy[ SEPTIC_EXTENSION_DEGREE ..] . into ( ) ;
517519
518- assert_eq ! ( & ecc_proof. sum. x, & x ) ;
519- assert_eq ! ( & ecc_proof. sum. y, & y ) ;
520+ assert_eq ! ( & ecc_proof. sum. x, & expected_septic_x ) ;
521+ assert_eq ! ( & ecc_proof. sum. y, & expected_septic_y ) ;
520522 assert ! ( !ecc_proof. sum. is_infinity) ;
521- // assert ec sum in public input matches that in ecc proof
522- let global_ec_sum = raw_pi
523- . iter ( )
524- . skip ( GLOBAL_RW_SUM_IDX )
525- . take ( SEPTIC_EXTENSION_DEGREE * 2 )
526- . flatten ( )
527- . copied ( )
528- . collect_vec ( ) ;
529- assert_eq ! ( global_ec_sum. len( ) , SEPTIC_EXTENSION_DEGREE * 2 ) ;
530- for ( f, expected_f) in global_ec_sum. iter ( ) . zip_eq ( x. 0 . iter ( ) . chain ( y. 0 . iter ( ) ) ) {
531- assert_eq ! ( f, expected_f)
532- }
533523 EccVerifier :: verify_ecc_proof ( ecc_proof, transcript) ?;
534524 tracing:: debug!( "ecc proof verified." ) ;
535- Some ( SepticPoint :: from_affine (
536- SepticExtension :: from ( & global_ec_sum[ 0 ..SEPTIC_EXTENSION_DEGREE ] ) ,
537- SepticExtension :: from ( & global_ec_sum[ SEPTIC_EXTENSION_DEGREE ..] ) ,
538- ) )
525+ Some ( ecc_proof. sum . clone ( ) )
539526 } else {
540527 None
541528 } ;
0 commit comments