mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 08:13:11 +00:00
Fix num_permutation_zs
This commit is contained in:
parent
f9e929a0a9
commit
a38c19f952
@ -4,6 +4,7 @@ use plonky2::field::extension_field::{Extendable, FieldExtension};
|
|||||||
use plonky2::field::packed_field::PackedField;
|
use plonky2::field::packed_field::PackedField;
|
||||||
use plonky2::hash::hash_types::RichField;
|
use plonky2::hash::hash_types::RichField;
|
||||||
|
|
||||||
|
use crate::config::StarkConfig;
|
||||||
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
|
use crate::constraint_consumer::{ConstraintConsumer, RecursiveConstraintConsumer};
|
||||||
use crate::cross_table_lookup::CrossTableLookup;
|
use crate::cross_table_lookup::CrossTableLookup;
|
||||||
use crate::stark::Stark;
|
use crate::stark::Stark;
|
||||||
@ -16,6 +17,15 @@ pub struct AllStark<F: RichField + Extendable<D>, const D: usize> {
|
|||||||
pub cross_table_lookups: Vec<CrossTableLookup>,
|
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)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct CpuStark<F, const D: usize> {
|
pub struct CpuStark<F, const D: usize> {
|
||||||
num_rows: usize,
|
num_rows: usize,
|
||||||
|
|||||||
@ -152,11 +152,13 @@ impl<'a, F: RichField + Extendable<D>, const D: usize>
|
|||||||
proofs: &[&StarkProofWithPublicInputs<F, C, D>],
|
proofs: &[&StarkProofWithPublicInputs<F, C, D>],
|
||||||
cross_table_lookups: &'a [CrossTableLookup],
|
cross_table_lookups: &'a [CrossTableLookup],
|
||||||
ctl_challenges: &'a GrandProductChallengeSet<F>,
|
ctl_challenges: &'a GrandProductChallengeSet<F>,
|
||||||
num_permutation_zs: usize,
|
num_permutation_zs: &[usize],
|
||||||
) -> Vec<Vec<Self>> {
|
) -> Vec<Vec<Self>> {
|
||||||
|
debug_assert_eq!(proofs.len(), num_permutation_zs.len());
|
||||||
let mut ctl_zs = proofs
|
let mut ctl_zs = proofs
|
||||||
.iter()
|
.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() {
|
if p.proof.openings.permutation_lookup_zs.is_some() {
|
||||||
Box::new(
|
Box::new(
|
||||||
p.proof
|
p.proof
|
||||||
@ -165,7 +167,7 @@ impl<'a, F: RichField + Extendable<D>, const D: usize>
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.skip(num_permutation_zs)
|
.skip(num_permutation)
|
||||||
.zip(
|
.zip(
|
||||||
p.proof
|
p.proof
|
||||||
.openings
|
.openings
|
||||||
@ -173,7 +175,7 @@ impl<'a, F: RichField + Extendable<D>, const D: usize>
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.iter()
|
.iter()
|
||||||
.skip(num_permutation_zs),
|
.skip(num_permutation),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -38,6 +38,8 @@ where
|
|||||||
ctl_challenges,
|
ctl_challenges,
|
||||||
} = all_proof.get_challenges(&all_stark, config);
|
} = all_proof.get_challenges(&all_stark, config);
|
||||||
|
|
||||||
|
let nums_permutation_zs = all_stark.nums_permutation_zs(config);
|
||||||
|
|
||||||
let AllStark {
|
let AllStark {
|
||||||
cpu_stark,
|
cpu_stark,
|
||||||
keccak_stark,
|
keccak_stark,
|
||||||
@ -48,7 +50,7 @@ where
|
|||||||
&all_proof.proofs(),
|
&all_proof.proofs(),
|
||||||
&cross_table_lookups,
|
&cross_table_lookups,
|
||||||
&ctl_challenges,
|
&ctl_challenges,
|
||||||
0, // TODO: Fix 0
|
&nums_permutation_zs,
|
||||||
);
|
);
|
||||||
|
|
||||||
verify_stark_proof_with_challenges(
|
verify_stark_proof_with_challenges(
|
||||||
@ -150,9 +152,10 @@ where
|
|||||||
l_1,
|
l_1,
|
||||||
l_last,
|
l_last,
|
||||||
);
|
);
|
||||||
|
let num_permutation_zs = stark.num_permutation_batches(config);
|
||||||
let permutation_data = stark.uses_permutation_args().then(|| PermutationCheckVars {
|
let permutation_data = stark.uses_permutation_args().then(|| PermutationCheckVars {
|
||||||
local_zs: permutation_lookup_zs.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().clone(),
|
next_zs: permutation_lookup_zs_right.as_ref().unwrap()[..num_permutation_zs].to_vec(),
|
||||||
permutation_challenge_sets: challenges.permutation_challenge_sets.unwrap(),
|
permutation_challenge_sets: challenges.permutation_challenge_sets.unwrap(),
|
||||||
});
|
});
|
||||||
eval_vanishing_poly::<F, F::Extension, F::Extension, C, S, D, D>(
|
eval_vanishing_poly::<F, F::Extension, F::Extension, C, S, D, D>(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user