Fix num_permutation_zs

This commit is contained in:
wborgeaud 2022-05-13 10:48:56 +02:00
parent f9e929a0a9
commit a38c19f952
3 changed files with 22 additions and 7 deletions

View File

@ -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<F: RichField + Extendable<D>, const D: usize> {
pub cross_table_lookups: Vec<CrossTableLookup>,
}
impl<F: RichField + Extendable<D>, const D: usize> AllStark<F, D> {
pub(crate) fn nums_permutation_zs(&self, config: &StarkConfig) -> Vec<usize> {
vec![
self.cpu_stark.num_permutation_batches(config),
self.keccak_stark.num_permutation_batches(config),
]
}
}
#[derive(Copy, Clone)]
pub struct CpuStark<F, const D: usize> {
num_rows: usize,

View File

@ -152,11 +152,13 @@ impl<'a, F: RichField + Extendable<D>, const D: usize>
proofs: &[&StarkProofWithPublicInputs<F, C, D>],
cross_table_lookups: &'a [CrossTableLookup],
ctl_challenges: &'a GrandProductChallengeSet<F>,
num_permutation_zs: usize,
num_permutation_zs: &[usize],
) -> Vec<Vec<Self>> {
debug_assert_eq!(proofs.len(), num_permutation_zs.len());
let mut ctl_zs = proofs
.iter()
.map(|p| -> Box<dyn Iterator<Item = _>> {
.zip(num_permutation_zs)
.map(|(p, &num_permutation)| -> Box<dyn Iterator<Item = _>> {
if p.proof.openings.permutation_lookup_zs.is_some() {
Box::new(
p.proof
@ -165,7 +167,7 @@ impl<'a, F: RichField + Extendable<D>, 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<D>, const D: usize>
.as_ref()
.unwrap()
.iter()
.skip(num_permutation_zs),
.skip(num_permutation),
),
)
} else {

View File

@ -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::<F, F::Extension, F::Extension, C, S, D, D>(