diff --git a/starky2/src/all_stark.rs b/starky2/src/all_stark.rs index 7542d3bf..89eff627 100644 --- a/starky2/src/all_stark.rs +++ b/starky2/src/all_stark.rs @@ -4,6 +4,7 @@ use plonky2::field::extension_field::{Extendable, FieldExtension}; use plonky2::field::packed_field::PackedField; use plonky2::hash::hash_types::RichField; +use crate::config::StarkConfig; use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer}; use crate::cross_table_lookup::CrossTableLookup; use crate::stark::Stark; @@ -16,6 +17,15 @@ pub struct AllStark, const D: usize> { pub cross_table_lookups: Vec, } +impl, const D: usize> AllStark { + pub(crate) fn nums_permutation_zs(&self, config: &StarkConfig) -> Vec { + vec![ + self.cpu_stark.num_permutation_batches(config), + self.keccak_stark.num_permutation_batches(config), + ] + } +} + #[derive(Copy, Clone)] pub struct CpuStark { num_rows: usize, diff --git a/starky2/src/cross_table_lookup.rs b/starky2/src/cross_table_lookup.rs index fc0e6f33..8072a6c9 100644 --- a/starky2/src/cross_table_lookup.rs +++ b/starky2/src/cross_table_lookup.rs @@ -152,11 +152,13 @@ impl<'a, F: RichField + Extendable, const D: usize> proofs: &[&StarkProofWithPublicInputs], cross_table_lookups: &'a [CrossTableLookup], ctl_challenges: &'a GrandProductChallengeSet, - num_permutation_zs: usize, + num_permutation_zs: &[usize], ) -> Vec> { + debug_assert_eq!(proofs.len(), num_permutation_zs.len()); let mut ctl_zs = proofs .iter() - .map(|p| -> Box> { + .zip(num_permutation_zs) + .map(|(p, &num_permutation)| -> Box> { if p.proof.openings.permutation_lookup_zs.is_some() { Box::new( p.proof @@ -165,7 +167,7 @@ impl<'a, F: RichField + Extendable, const D: usize> .as_ref() .unwrap() .iter() - .skip(num_permutation_zs) + .skip(num_permutation) .zip( p.proof .openings @@ -173,7 +175,7 @@ impl<'a, F: RichField + Extendable, const D: usize> .as_ref() .unwrap() .iter() - .skip(num_permutation_zs), + .skip(num_permutation), ), ) } else { diff --git a/starky2/src/verifier.rs b/starky2/src/verifier.rs index 2c4a7fba..78763fd2 100644 --- a/starky2/src/verifier.rs +++ b/starky2/src/verifier.rs @@ -38,6 +38,8 @@ where ctl_challenges, } = all_proof.get_challenges(&all_stark, config); + let nums_permutation_zs = all_stark.nums_permutation_zs(config); + let AllStark { cpu_stark, keccak_stark, @@ -48,7 +50,7 @@ where &all_proof.proofs(), &cross_table_lookups, &ctl_challenges, - 0, // TODO: Fix 0 + &nums_permutation_zs, ); verify_stark_proof_with_challenges( @@ -150,9 +152,10 @@ where l_1, l_last, ); + let num_permutation_zs = stark.num_permutation_batches(config); let permutation_data = stark.uses_permutation_args().then(|| PermutationCheckVars { - local_zs: permutation_lookup_zs.as_ref().unwrap().clone(), - next_zs: permutation_lookup_zs_right.as_ref().unwrap().clone(), + local_zs: permutation_lookup_zs.as_ref().unwrap()[..num_permutation_zs].to_vec(), + next_zs: permutation_lookup_zs_right.as_ref().unwrap()[..num_permutation_zs].to_vec(), permutation_challenge_sets: challenges.permutation_challenge_sets.unwrap(), }); eval_vanishing_poly::(