diff --git a/starky2/src/cross_table_lookup.rs b/starky2/src/cross_table_lookup.rs index 6dfec2d2..da141a52 100644 --- a/starky2/src/cross_table_lookup.rs +++ b/starky2/src/cross_table_lookup.rs @@ -13,7 +13,7 @@ use crate::all_stark::Table; use crate::config::StarkConfig; use crate::constraint_consumer::ConstraintConsumer; use crate::permutation::{ - get_permutation_challenge_set, PermutationChallenge, PermutationChallengeSet, + get_grand_product_challenge_set, GrandProductChallenge, GrandProductChallengeSet, }; use crate::proof::StarkProofWithPublicInputs; use crate::stark::Stark; @@ -47,12 +47,12 @@ impl CrossTableLookup { /// Lookup data for one table. #[derive(Clone)] pub struct LookupData { - pub(crate) challenges: PermutationChallengeSet, + pub(crate) challenges: GrandProductChallengeSet, pub zs_columns: Vec<(PolynomialValues, Vec)>, } impl LookupData { - pub(crate) fn new(challenges: PermutationChallengeSet) -> Self { + pub(crate) fn new(challenges: GrandProductChallengeSet) -> Self { Self { challenges, zs_columns: vec![], @@ -78,7 +78,7 @@ pub fn cross_table_lookup_zs, const D: cross_table_lookups: &[CrossTableLookup], challenger: &mut Challenger, ) -> Vec> { - let challenges = get_permutation_challenge_set(challenger, config.num_challenges); + let challenges = get_grand_product_challenge_set(challenger, config.num_challenges); cross_table_lookups.iter().fold( vec![LookupData::new(challenges.clone()); trace_poly_values.len()], |mut acc, cross_table_lookup| { @@ -89,7 +89,7 @@ pub fn cross_table_lookup_zs, const D: looked_columns, } = cross_table_lookup; - for &PermutationChallenge { beta, gamma } in &challenges.challenges { + for &GrandProductChallenge { beta, gamma } in &challenges.challenges { let z_looking = partial_products( &trace_poly_values[*looking_table as usize], looking_columns, @@ -140,7 +140,7 @@ where { pub(crate) local_z: P, pub(crate) next_z: P, - pub(crate) challenges: PermutationChallenge, + pub(crate) challenges: GrandProductChallenge, pub(crate) columns: &'a [usize], } @@ -150,7 +150,7 @@ impl<'a, F: RichField + Extendable, const D: usize> pub(crate) fn from_proofs>( proofs: &[&StarkProofWithPublicInputs], cross_table_lookups: &'a [CrossTableLookup], - ctl_challenges: &'a PermutationChallengeSet, + ctl_challenges: &'a GrandProductChallengeSet, ) -> Vec> { let mut ctl_zs = proofs .iter() @@ -242,7 +242,7 @@ pub(crate) fn verify_cross_table_lookups< >( cross_table_lookups: Vec, proofs: &[&StarkProofWithPublicInputs], - challenges: PermutationChallengeSet, + challenges: GrandProductChallengeSet, config: &StarkConfig, ) -> Result<()> { let degrees_bits = proofs diff --git a/starky2/src/get_challenges.rs b/starky2/src/get_challenges.rs index acc0bbc0..9851c787 100644 --- a/starky2/src/get_challenges.rs +++ b/starky2/src/get_challenges.rs @@ -12,8 +12,8 @@ use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use crate::all_stark::AllStark; use crate::config::StarkConfig; use crate::permutation::{ - get_n_permutation_challenge_sets, get_n_permutation_challenge_sets_target, - get_permutation_challenge_set, + get_grand_product_challenge_set, get_n_grand_product_challenge_sets, + get_n_permutation_challenge_sets_target, }; use crate::proof::*; use crate::stark::Stark; @@ -41,7 +41,7 @@ where challenger.observe_cap(trace_cap); let permutation_challenge_sets = permutation_zs_cap.map(|permutation_zs_cap| { - let tmp = get_n_permutation_challenge_sets( + let tmp = get_n_grand_product_challenge_sets( challenger, num_challenges, stark.permutation_batch_size(), @@ -84,7 +84,8 @@ impl, C: GenericConfig, const D: usize> A challenger.observe_cap(&proof.proof.trace_cap); } - let ctl_challenges = get_permutation_challenge_set(&mut challenger, config.num_challenges); + let ctl_challenges = + get_grand_product_challenge_set(&mut challenger, config.num_challenges); AllProofChallenges { cpu_challenges: self.cpu_proof.get_challenges( diff --git a/starky2/src/permutation.rs b/starky2/src/permutation.rs index 2f0b5378..a5601a7b 100644 --- a/starky2/src/permutation.rs +++ b/starky2/src/permutation.rs @@ -41,12 +41,12 @@ impl PermutationPair { /// A single instance of a permutation check protocol. pub(crate) struct PermutationInstance<'a, T: Copy> { pub(crate) pair: &'a PermutationPair, - pub(crate) challenge: PermutationChallenge, + pub(crate) challenge: GrandProductChallenge, } /// Randomness for a single instance of a permutation check protocol. #[derive(Copy, Clone)] -pub(crate) struct PermutationChallenge { +pub(crate) struct GrandProductChallenge { /// Randomness used to combine multiple columns into one. pub(crate) beta: T, /// Random offset that's added to the beta-reduced column values. @@ -55,8 +55,8 @@ pub(crate) struct PermutationChallenge { /// Like `PermutationChallenge`, but with `num_challenges` copies to boost soundness. #[derive(Clone)] -pub(crate) struct PermutationChallengeSet { - pub(crate) challenges: Vec>, +pub(crate) struct GrandProductChallengeSet { + pub(crate) challenges: Vec>, } /// Compute all Z polynomials (for permutation arguments). @@ -64,7 +64,7 @@ pub(crate) fn compute_permutation_z_polys( stark: &S, config: &StarkConfig, trace_poly_values: &[PolynomialValues], - permutation_challenge_sets: &[PermutationChallengeSet], + permutation_challenge_sets: &[GrandProductChallengeSet], ) -> Vec> where F: RichField + Extendable, @@ -123,7 +123,7 @@ fn permutation_reduced_polys( ) -> (PolynomialValues, PolynomialValues) { let PermutationInstance { pair: PermutationPair { column_pairs }, - challenge: PermutationChallenge { beta, gamma }, + challenge: GrandProductChallenge { beta, gamma }, } = instance; let mut reduced_lhs = PolynomialValues::constant(*gamma, degree); @@ -147,31 +147,31 @@ fn poly_product_elementwise( product } -fn get_permutation_challenge>( +fn get_grand_product_challenge>( challenger: &mut Challenger, -) -> PermutationChallenge { +) -> GrandProductChallenge { let beta = challenger.get_challenge(); let gamma = challenger.get_challenge(); - PermutationChallenge { beta, gamma } + GrandProductChallenge { beta, gamma } } -pub(crate) fn get_permutation_challenge_set>( +pub(crate) fn get_grand_product_challenge_set>( challenger: &mut Challenger, num_challenges: usize, -) -> PermutationChallengeSet { +) -> GrandProductChallengeSet { let challenges = (0..num_challenges) - .map(|_| get_permutation_challenge(challenger)) + .map(|_| get_grand_product_challenge(challenger)) .collect(); - PermutationChallengeSet { challenges } + GrandProductChallengeSet { challenges } } -pub(crate) fn get_n_permutation_challenge_sets>( +pub(crate) fn get_n_grand_product_challenge_sets>( challenger: &mut Challenger, num_challenges: usize, num_sets: usize, -) -> Vec> { +) -> Vec> { (0..num_sets) - .map(|_| get_permutation_challenge_set(challenger, num_challenges)) + .map(|_| get_grand_product_challenge_set(challenger, num_challenges)) .collect() } @@ -182,10 +182,10 @@ fn get_permutation_challenge_target< >( builder: &mut CircuitBuilder, challenger: &mut RecursiveChallenger, -) -> PermutationChallenge { +) -> GrandProductChallenge { let beta = challenger.get_challenge(builder); let gamma = challenger.get_challenge(builder); - PermutationChallenge { beta, gamma } + GrandProductChallenge { beta, gamma } } fn get_permutation_challenge_set_target< @@ -196,11 +196,11 @@ fn get_permutation_challenge_set_target< builder: &mut CircuitBuilder, challenger: &mut RecursiveChallenger, num_challenges: usize, -) -> PermutationChallengeSet { +) -> GrandProductChallengeSet { let challenges = (0..num_challenges) .map(|_| get_permutation_challenge_target(builder, challenger)) .collect(); - PermutationChallengeSet { challenges } + GrandProductChallengeSet { challenges } } pub(crate) fn get_n_permutation_challenge_sets_target< @@ -212,7 +212,7 @@ pub(crate) fn get_n_permutation_challenge_sets_target< challenger: &mut RecursiveChallenger, num_challenges: usize, num_sets: usize, -) -> Vec> { +) -> Vec> { (0..num_sets) .map(|_| get_permutation_challenge_set_target(builder, challenger, num_challenges)) .collect() @@ -225,7 +225,7 @@ pub(crate) fn get_n_permutation_challenge_sets_target< /// chunk these arguments based on our batch size. pub(crate) fn get_permutation_batches<'a, T: Copy>( permutation_pairs: &'a [PermutationPair], - permutation_challenge_sets: &[PermutationChallengeSet], + permutation_challenge_sets: &[GrandProductChallengeSet], num_challenges: usize, batch_size: usize, ) -> Vec>> { @@ -254,7 +254,7 @@ where { pub(crate) local_zs: Vec

, pub(crate) next_zs: Vec

, - pub(crate) permutation_challenge_sets: Vec>, + pub(crate) permutation_challenge_sets: Vec>, } pub(crate) fn eval_permutation_checks( @@ -298,7 +298,7 @@ pub(crate) fn eval_permutation_checks, Vec<_>) = column_pairs @@ -320,7 +320,7 @@ pub(crate) fn eval_permutation_checks { pub(crate) local_zs: Vec>, pub(crate) next_zs: Vec>, - pub(crate) permutation_challenge_sets: Vec>, + pub(crate) permutation_challenge_sets: Vec>, } pub(crate) fn eval_permutation_checks_recursively( @@ -366,7 +366,7 @@ pub(crate) fn eval_permutation_checks_recursively( .map(|instance| { let PermutationInstance { pair: PermutationPair { column_pairs }, - challenge: PermutationChallenge { beta, gamma }, + challenge: GrandProductChallenge { beta, gamma }, } = instance; let beta_ext = builder.convert_to_ext(*beta); let gamma_ext = builder.convert_to_ext(*gamma); diff --git a/starky2/src/proof.rs b/starky2/src/proof.rs index 1dd40d3f..b8ede54f 100644 --- a/starky2/src/proof.rs +++ b/starky2/src/proof.rs @@ -15,7 +15,7 @@ use plonky2::plonk::config::GenericConfig; use rayon::prelude::*; use crate::config::StarkConfig; -use crate::permutation::PermutationChallengeSet; +use crate::permutation::GrandProductChallengeSet; #[derive(Debug, Clone)] pub struct AllProof, C: GenericConfig, const D: usize> { @@ -32,7 +32,7 @@ impl, C: GenericConfig, const D: usize> A pub(crate) struct AllProofChallenges, const D: usize> { pub cpu_challenges: StarkProofChallenges, pub keccak_challenges: StarkProofChallenges, - pub ctl_challenges: PermutationChallengeSet, + pub ctl_challenges: GrandProductChallengeSet, } #[derive(Debug, Clone)] @@ -121,7 +121,7 @@ pub struct CompressedStarkProofWithPublicInputs< pub(crate) struct StarkProofChallenges, const D: usize> { /// Randomness used in any permutation arguments. - pub permutation_challenge_sets: Option>>, + pub permutation_challenge_sets: Option>>, /// Random values used to combine STARK constraints. pub stark_alphas: Vec, @@ -133,7 +133,7 @@ pub(crate) struct StarkProofChallenges, const D: us } pub(crate) struct StarkProofChallengesTarget { - pub permutation_challenge_sets: Option>>, + pub permutation_challenge_sets: Option>>, pub stark_alphas: Vec, pub stark_zeta: ExtensionTarget, pub fri_challenges: FriChallengesTarget, diff --git a/starky2/src/prover.rs b/starky2/src/prover.rs index f6a412c6..25a05b69 100644 --- a/starky2/src/prover.rs +++ b/starky2/src/prover.rs @@ -24,7 +24,7 @@ use crate::constraint_consumer::ConstraintConsumer; use crate::cross_table_lookup::{cross_table_lookup_zs, CTLCheckVars, LookupData}; use crate::permutation::PermutationCheckVars; use crate::permutation::{ - compute_permutation_z_polys, get_n_permutation_challenge_sets, PermutationChallengeSet, + compute_permutation_z_polys, get_n_grand_product_challenge_sets, GrandProductChallengeSet, }; use crate::proof::{AllProof, StarkOpeningSet, StarkProof, StarkProofWithPublicInputs}; use crate::stark::Stark; @@ -148,7 +148,7 @@ where // Permutation arguments. let permutation_challenges = stark.uses_permutation_args().then(|| { - get_n_permutation_challenge_sets( + get_n_grand_product_challenge_sets( challenger, config.num_challenges, stark.permutation_batch_size(), @@ -290,7 +290,7 @@ fn compute_quotient_polys<'a, F, P, C, S, const D: usize>( trace_commitment: &'a PolynomialBatch, permutation_zs_commitment_challenges: Option<( &'a PolynomialBatch, - &'a Vec>, + &'a Vec>, )>, lookup_data: &LookupData, public_inputs: &[F],