diff --git a/evm/src/all_stark.rs b/evm/src/all_stark.rs index e4f93c62..7d7b0932 100644 --- a/evm/src/all_stark.rs +++ b/evm/src/all_stark.rs @@ -172,7 +172,6 @@ mod tests { use anyhow::Result; use ethereum_types::U256; use itertools::Itertools; - use log::debug; use plonky2::field::polynomial::PolynomialValues; use plonky2::field::types::{Field, PrimeField64}; use plonky2::iop::witness::PartialWitness; diff --git a/evm/src/cross_table_lookup.rs b/evm/src/cross_table_lookup.rs index 24b8059c..429a4fce 100644 --- a/evm/src/cross_table_lookup.rs +++ b/evm/src/cross_table_lookup.rs @@ -450,55 +450,6 @@ pub struct CtlCheckVarsTarget<'a, F: Field, const D: usize> { } impl<'a, F: Field, const D: usize> CtlCheckVarsTarget<'a, F, D> { - pub(crate) fn from_proofs( - proofs: &[StarkProofTarget; NUM_TABLES], - cross_table_lookups: &'a [CrossTableLookup], - ctl_challenges: &'a GrandProductChallengeSet, - num_permutation_zs: &[usize; NUM_TABLES], - ) -> [Vec; NUM_TABLES] { - let mut ctl_zs = proofs - .iter() - .zip(num_permutation_zs) - .map(|(p, &num_perms)| { - let openings = &p.openings; - let ctl_zs = openings.permutation_ctl_zs.iter().skip(num_perms); - let ctl_zs_next = openings.permutation_ctl_zs_next.iter().skip(num_perms); - ctl_zs.zip(ctl_zs_next) - }) - .collect::>(); - - let mut ctl_vars_per_table = [0; NUM_TABLES].map(|_| vec![]); - for CrossTableLookup { - looking_tables, - looked_table, - .. - } in cross_table_lookups - { - for &challenges in &ctl_challenges.challenges { - for table in looking_tables { - let (looking_z, looking_z_next) = ctl_zs[table.table as usize].next().unwrap(); - ctl_vars_per_table[table.table as usize].push(Self { - local_z: *looking_z, - next_z: *looking_z_next, - challenges, - columns: &table.columns, - filter_column: &table.filter_column, - }); - } - - let (looked_z, looked_z_next) = ctl_zs[looked_table.table as usize].next().unwrap(); - ctl_vars_per_table[looked_table.table as usize].push(Self { - local_z: *looked_z, - next_z: *looked_z_next, - challenges, - columns: &looked_table.columns, - filter_column: &looked_table.filter_column, - }); - } - } - ctl_vars_per_table - } - pub(crate) fn from_proof( table: Table, proof: &StarkProofTarget, diff --git a/evm/src/get_challenges.rs b/evm/src/get_challenges.rs index 8b254ee4..ac2e7aba 100644 --- a/evm/src/get_challenges.rs +++ b/evm/src/get_challenges.rs @@ -8,8 +8,8 @@ use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use crate::all_stark::{AllStark, NUM_TABLES}; use crate::config::StarkConfig; use crate::permutation::{ - get_grand_product_challenge_set, get_grand_product_challenge_set_target, - get_n_grand_product_challenge_sets, get_n_grand_product_challenge_sets_target, + get_grand_product_challenge_set, get_n_grand_product_challenge_sets, + get_n_grand_product_challenge_sets_target, }; use crate::proof::*; @@ -86,43 +86,6 @@ impl, C: GenericConfig, const D: usize> A } } -impl AllProofTarget { - pub(crate) fn get_challenges, C: GenericConfig>( - &self, - builder: &mut CircuitBuilder, - all_stark: &AllStark, - config: &StarkConfig, - ) -> AllProofChallengesTarget - where - C::Hasher: AlgebraicHasher, - { - let mut challenger = RecursiveChallenger::::new(builder); - - for proof in &self.stark_proofs { - challenger.observe_cap(&proof.trace_cap); - } - - let ctl_challenges = - get_grand_product_challenge_set_target(builder, &mut challenger, config.num_challenges); - - let num_permutation_zs = all_stark.nums_permutation_zs(config); - let num_permutation_batch_sizes = all_stark.permutation_batch_sizes(); - - AllProofChallengesTarget { - stark_challenges: std::array::from_fn(|i| { - self.stark_proofs[i].get_challenges::( - builder, - &mut challenger, - num_permutation_zs[i] > 0, - num_permutation_batch_sizes[i], - config, - ) - }), - ctl_challenges, - } - } -} - impl StarkProof where F: RichField + Extendable, diff --git a/evm/src/proof.rs b/evm/src/proof.rs index 577fbeb4..3b2d988b 100644 --- a/evm/src/proof.rs +++ b/evm/src/proof.rs @@ -99,11 +99,6 @@ pub struct BlockMetadataTarget { pub block_base_fee: Target, } -pub(crate) struct AllProofChallengesTarget { - pub stark_challenges: [StarkProofChallengesTarget; NUM_TABLES], - pub ctl_challenges: GrandProductChallengeSet, -} - #[derive(Debug, Clone)] pub struct StarkProof, C: GenericConfig, const D: usize> { /// Merkle cap of LDEs of trace values. diff --git a/evm/src/recursive_verifier.rs b/evm/src/recursive_verifier.rs index 95d8cd80..fd52c218 100644 --- a/evm/src/recursive_verifier.rs +++ b/evm/src/recursive_verifier.rs @@ -5,17 +5,14 @@ use itertools::Itertools; use plonky2::field::extension::Extendable; use plonky2::field::types::Field; use plonky2::fri::witness_util::set_fri_proof_target; -use plonky2::hash::hash_types::{HashOut, RichField}; +use plonky2::hash::hash_types::RichField; use plonky2::hash::hashing::SPONGE_WIDTH; -use plonky2::hash::merkle_tree::MerkleCap; -use plonky2::hash::poseidon::PoseidonHash; use plonky2::iop::challenger::{Challenger, RecursiveChallenger}; use plonky2::iop::ext_target::ExtensionTarget; use plonky2::iop::target::Target; use plonky2::iop::witness::{PartialWitness, Witness}; use plonky2::plonk::circuit_builder::CircuitBuilder; use plonky2::plonk::circuit_data::{CircuitConfig, VerifierCircuitData, VerifierCircuitTarget}; -use plonky2::plonk::config::GenericHashOut; use plonky2::plonk::config::Hasher; use plonky2::plonk::config::{AlgebraicHasher, GenericConfig}; use plonky2::plonk::proof::ProofWithPublicInputs; @@ -39,9 +36,9 @@ use crate::permutation::{ GrandProductChallengeSet, PermutationCheckDataTarget, }; use crate::proof::{ - AllChallengerState, AllProof, AllProofChallengesTarget, AllProofTarget, BlockMetadata, - BlockMetadataTarget, PublicValues, PublicValuesTarget, StarkOpeningSetTarget, StarkProof, - StarkProofChallengesTarget, StarkProofTarget, TrieRoots, TrieRootsTarget, + AllChallengerState, AllProof, AllProofTarget, BlockMetadata, BlockMetadataTarget, PublicValues, + PublicValuesTarget, StarkOpeningSetTarget, StarkProof, StarkProofChallengesTarget, + StarkProofTarget, TrieRoots, TrieRootsTarget, }; use crate::stark::Stark; use crate::util::{h160_limbs, u256_limbs}; @@ -425,120 +422,6 @@ where }) } -// pub fn verify_proof_circuit< -// F: RichField + Extendable, -// C: GenericConfig, -// const D: usize, -// >( -// builder: &mut CircuitBuilder, -// all_stark: AllStark, -// all_proof: AllProofTarget, -// inner_config: &StarkConfig, -// ) where -// [(); CpuStark::::COLUMNS]:, -// [(); KeccakStark::::COLUMNS]:, -// [(); KeccakMemoryStark::::COLUMNS]:, -// [(); LogicStark::::COLUMNS]:, -// [(); MemoryStark::::COLUMNS]:, -// C::Hasher: AlgebraicHasher, -// { -// let AllProofChallengesTarget { -// stark_challenges, -// ctl_challenges, -// } = all_proof.get_challenges::(builder, &all_stark, inner_config); -// -// let nums_permutation_zs = all_stark.nums_permutation_zs(inner_config); -// -// let AllStark { -// cpu_stark, -// keccak_stark, -// keccak_memory_stark, -// logic_stark, -// memory_stark, -// cross_table_lookups, -// } = all_stark; -// -// let ctl_vars_per_table = CtlCheckVarsTarget::from_proofs( -// &all_proof.stark_proofs, -// &cross_table_lookups, -// &ctl_challenges, -// &nums_permutation_zs, -// ); -// -// with_context!( -// builder, -// "verify CPU proof", -// verify_stark_proof_with_challenges_circuit::( -// builder, -// &cpu_stark, -// &all_proof.stark_proofs[Table::Cpu as usize], -// &stark_challenges[Table::Cpu as usize], -// &ctl_vars_per_table[Table::Cpu as usize], -// inner_config, -// ) -// ); -// with_context!( -// builder, -// "verify Keccak proof", -// verify_stark_proof_with_challenges_circuit::( -// builder, -// &keccak_stark, -// &all_proof.stark_proofs[Table::Keccak as usize], -// &stark_challenges[Table::Keccak as usize], -// &ctl_vars_per_table[Table::Keccak as usize], -// inner_config, -// ) -// ); -// with_context!( -// builder, -// "verify Keccak memory proof", -// verify_stark_proof_with_challenges_circuit::( -// builder, -// &keccak_memory_stark, -// &all_proof.stark_proofs[Table::KeccakMemory as usize], -// &stark_challenges[Table::KeccakMemory as usize], -// &ctl_vars_per_table[Table::KeccakMemory as usize], -// inner_config, -// ) -// ); -// with_context!( -// builder, -// "verify logic proof", -// verify_stark_proof_with_challenges_circuit::( -// builder, -// &logic_stark, -// &all_proof.stark_proofs[Table::Logic as usize], -// &stark_challenges[Table::Logic as usize], -// &ctl_vars_per_table[Table::Logic as usize], -// inner_config, -// ) -// ); -// with_context!( -// builder, -// "verify memory proof", -// verify_stark_proof_with_challenges_circuit::( -// builder, -// &memory_stark, -// &all_proof.stark_proofs[Table::Memory as usize], -// &stark_challenges[Table::Memory as usize], -// &ctl_vars_per_table[Table::Memory as usize], -// inner_config, -// ) -// ); -// -// with_context!( -// builder, -// "verify cross-table lookups", -// verify_cross_table_lookups_circuit::( -// builder, -// cross_table_lookups, -// &all_proof.stark_proofs, -// ctl_challenges, -// inner_config, -// ) -// ); -// } - /// Recursively verifies an inner proof. fn verify_stark_proof_with_challenges_circuit< F: RichField + Extendable,