From cc964d1c3300c985c25d123301f276cbe6952fde Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 28 Aug 2024 19:17:14 +0200 Subject: [PATCH] columns dependent on layout internally in stark_verify function --- src/benches/stark/verify.cairo | 16 ++------- src/oods.cairo | 45 ++++++++++++++++++++----- src/stark.cairo | 15 +-------- src/stark/stark_verify.cairo | 4 --- src/stark/tests/test_stark_verify.cairo | 14 ++------ 5 files changed, 41 insertions(+), 53 deletions(-) diff --git a/src/benches/stark/verify.cairo b/src/benches/stark/verify.cairo index ccbe774f8..bafd02aaa 100644 --- a/src/benches/stark/verify.cairo +++ b/src/benches/stark/verify.cairo @@ -1,8 +1,4 @@ -use cairo_verifier::{ - stark::stark_verify::stark_verify, - air::layouts::recursive::constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND}, - tests::stone_proof_fibonacci_keccak, -}; +use cairo_verifier::{stark::stark_verify::stark_verify, tests::stone_proof_fibonacci_keccak,}; fn bench_stark_verify() { let public_input = stone_proof_fibonacci_keccak::public_input::get(); @@ -11,13 +7,5 @@ fn bench_stark_verify() { let witness = stone_proof_fibonacci_keccak::stark::witness::get(); let stark_domains = stone_proof_fibonacci_keccak::stark::domains::get(); - stark_verify( - NUM_COLUMNS_FIRST, - NUM_COLUMNS_SECOND, - @public_input, - queries, - commitment, - witness, - stark_domains, - ) + stark_verify(@public_input, queries, commitment, witness, stark_domains,) } diff --git a/src/oods.cairo b/src/oods.cairo index 1cc7748d6..182565599 100644 --- a/src/oods.cairo +++ b/src/oods.cairo @@ -4,49 +4,49 @@ use cairo_verifier::{ // air::layouts::dex::{ // AIRComposition, AIROods, DexAIRCompositionImpl, DexAIROodsImpl, // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::{CONSTRAINT_DEGREE, DynamicParams}, + // constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === DEX END === // === RECURSIVE BEGIN === air::layouts::recursive::{ AIRComposition, AIROods, RecursiveAIRCompositionImpl, RecursiveAIROodsImpl, global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - constants::{CONSTRAINT_DEGREE, DynamicParams}, + constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, }, // === RECURSIVE END === // === RECURSIVE_WITH_POSEIDON BEGIN === // air::layouts::recursive_with_poseidon::{ // AIRComposition, AIROods, RecursiveWithPoseidonAIRCompositionImpl, // RecursiveWithPoseidonAIROodsImpl, global_values::InteractionElements, - // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, DynamicParams}, + // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === RECURSIVE_WITH_POSEIDON END === // === SMALL BEGIN === // air::layouts::small::{ // AIRComposition, AIROods, SmallAIRCompositionImpl, SmallAIROodsImpl, // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::{CONSTRAINT_DEGREE, DynamicParams}, + // constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === SMALL END === // === STARKNET BEGIN === // air::layouts::starknet::{ // AIRComposition, AIROods, StarknetAIRCompositionImpl, StarknetAIROodsImpl, // global_values::InteractionElements, public_input::PublicInput, traces::TracesDecommitment, - // constants::{CONSTRAINT_DEGREE, DynamicParams}, + // constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === STARKNET END === // === STARKNET_WITH_KECCAK BEGIN === // air::layouts::starknet_with_keccak::{ // AIRComposition, AIROods, StarknetWithKeccakAIRCompositionImpl, // StarknetWithKeccakAIROodsImpl, global_values::InteractionElements, - // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, DynamicParams}, + // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === STARKNET_WITH_KECCAK END === // === DYNAMIC BEGIN === // air::layouts::dynamic::{ // AIRComposition, AIROods, StarknetWithKeccakAIRCompositionImpl, // StarknetWithKeccakAIROodsImpl, global_values::InteractionElements, - // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, DynamicParams}, + // public_input::PublicInput, traces::TracesDecommitment, constants::{CONSTRAINT_DEGREE, NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND, DynamicParams}, // }, // === DYNAMIC END === table_commitment::table_commitment::TableDecommitment @@ -88,8 +88,6 @@ fn verify_oods( } fn eval_oods_boundary_poly_at_points( - n_original_columns: u32, - n_interaction_columns: u32, public_input: @PublicInput, eval_info: OodsEvaluationInfo, points: Span, @@ -99,6 +97,35 @@ fn eval_oods_boundary_poly_at_points( let mut dynamic_params_span = public_input.dynamic_params.span(); let dynamic_params = Serde::::deserialize(ref dynamic_params_span).unwrap(); + // === DEX BEGIN === + // let n_original_columns: u32 = NUM_COLUMNS_FIRST; + // let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === DEX END === + // === RECURSIVE BEGIN === + let n_original_columns: u32 = NUM_COLUMNS_FIRST; + let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === RECURSIVE END === + // === RECURSIVE_WITH_POSEIDON BEGIN === + // let n_original_columns: u32 = NUM_COLUMNS_FIRST; + // let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === RECURSIVE_WITH_POSEIDON END === + // === SMALL BEGIN === + // let n_original_columns: u32 = NUM_COLUMNS_FIRST; + // let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === SMALL END === + // === STARKNET BEGIN === + // let n_original_columns: u32 = NUM_COLUMNS_FIRST; + // let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === STARKNET END === + // === STARKNET_WITH_KECCAK BEGIN === + // let n_original_columns: u32 = NUM_COLUMNS_FIRST; + // let n_interaction_columns: u32 = NUM_COLUMNS_SECOND; + // === STARKNET_WITH_KECCAK END === + // === DYNAMIC BEGIN === + // let n_original_columns: u32 = dynamic_params.num_columns_first; + // let n_interaction_columns: u32 = dynamic_params.num_columns_second; + // === DYNAMIC END === + assert( decommitment.original.values.len() == points.len() * n_original_columns, 'Invalid value' ); diff --git a/src/stark.cairo b/src/stark.cairo index b4fa620fa..30cebd527 100644 --- a/src/stark.cairo +++ b/src/stark.cairo @@ -11,14 +11,12 @@ use cairo_verifier::{ // layouts::dex::{ // traces::{TracesConfig, TracesConfigTrait}, public_input::DexPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === DEX END === // === RECURSIVE BEGIN === layouts::recursive::{ traces::{TracesConfig, TracesConfigTrait}, public_input::RecursivePublicInputImpl, traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND}, }, // === RECURSIVE END === // === RECURSIVE_WITH_POSEIDON BEGIN === @@ -26,21 +24,18 @@ use cairo_verifier::{ // traces::{TracesConfig, TracesConfigTrait}, // public_input::RecursiveWithPoseidonPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === RECURSIVE_WITH_POSEIDON END === // === SMALL BEGIN === // layouts::small::{ // traces::{TracesConfig, TracesConfigTrait}, public_input::SmallPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === SMALL END === // === STARKNET BEGIN === // layouts::starknet::{ // traces::{TracesConfig, TracesConfigTrait}, public_input::StarknetPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === STARKNET END === // === STARKNET_WITH_KECCAK BEGIN === @@ -48,7 +43,6 @@ use cairo_verifier::{ // traces::{TracesConfig, TracesConfigTrait}, // public_input::StarknetWithKeccakPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === STARKNET_WITH_KECCAK END === // === DYNAMIC BEGIN === @@ -56,7 +50,6 @@ use cairo_verifier::{ // traces::{TracesConfig, TracesConfigTrait}, // public_input::StarknetWithKeccakPublicInputImpl, // traces::{TracesUnsentCommitment, TracesCommitment, TracesDecommitment, TracesWitness}, - // constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND} // }, // === DYNAMIC END === }, @@ -115,13 +108,7 @@ impl StarkProofImpl of StarkProofTrait { // STARK verify phase. stark_verify::stark_verify( - NUM_COLUMNS_FIRST, - NUM_COLUMNS_SECOND, - self.public_input, - queries.span(), - stark_commitment, - *self.witness, - stark_domains + self.public_input, queries.span(), stark_commitment, *self.witness, stark_domains ) } } diff --git a/src/stark/stark_verify.cairo b/src/stark/stark_verify.cairo index d952c7bf2..2e808729e 100644 --- a/src/stark/stark_verify.cairo +++ b/src/stark/stark_verify.cairo @@ -28,8 +28,6 @@ use cairo_verifier::{ // STARK verify phase. fn stark_verify( - n_original_columns: u32, - n_interaction_columns: u32, public_input: @PublicInput, queries: Span, commitment: StarkCommitment, @@ -59,8 +57,6 @@ fn stark_verify( constraint_coefficients: commitment.interaction_after_oods, }; let oods_poly_evals = eval_oods_boundary_poly_at_points( - n_original_columns, - n_interaction_columns, public_input, eval_info, points.span(), diff --git a/src/stark/tests/test_stark_verify.cairo b/src/stark/tests/test_stark_verify.cairo index 895a3409c..98bcba70d 100644 --- a/src/stark/tests/test_stark_verify.cairo +++ b/src/stark/tests/test_stark_verify.cairo @@ -1,7 +1,5 @@ use cairo_verifier::{ - stark::stark_verify::stark_verify, - air::layouts::recursive::constants::{NUM_COLUMNS_FIRST, NUM_COLUMNS_SECOND}, - tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} + stark::stark_verify::stark_verify, tests::{stone_proof_fibonacci, stone_proof_fibonacci_keccak} }; // === BLAKE2S BEGIN === @@ -29,15 +27,7 @@ fn test_stark_verify() { let witness = stone_proof_fibonacci_keccak::stark::witness::get(); let stark_domains = stone_proof_fibonacci_keccak::stark::domains::get(); - stark_verify( - NUM_COLUMNS_FIRST, - NUM_COLUMNS_SECOND, - @public_input, - queries, - commitment, - witness, - stark_domains, - ) + stark_verify(@public_input, queries, commitment, witness, stark_domains,) } // === KECCAK END ===