Skip to content

Commit

Permalink
dynamic layout integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Aug 28, 2024
1 parent 1c4498a commit a2659dd
Show file tree
Hide file tree
Showing 26 changed files with 128 additions and 39 deletions.
3 changes: 2 additions & 1 deletion src/air/air.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ trait AIRComposition<IE, PI> {
) -> felt252;
}

trait AIROods {
trait AIROods<DY> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DY,
) -> felt252;
}
2 changes: 1 addition & 1 deletion src/air/layouts.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod recursive;
// mod starknet_with_keccak;
// === STARKNET_WITH_KECCAK END ===
// === DYNAMIC BEGIN ===
mod dynamic;
// mod dynamic;
// === DYNAMIC END ===


7 changes: 4 additions & 3 deletions src/air/layouts/dex.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cairo_verifier::{
global_values::{GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig},
public_input::DexPublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, PEDERSEN_BUILTIN_RATIO, ECDSA_BUILTIN_RATIO,
DynamicParams, PUBLIC_MEMORY_STEP, PEDERSEN_BUILTIN_RATIO, ECDSA_BUILTIN_RATIO,
ECDSA_BUILTIN_REPETITIONS, PEDERSEN_BUILTIN_REPETITIONS, segments,
},
},
Expand Down Expand Up @@ -95,17 +95,18 @@ impl DexAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
}
}

impl DexAIROodsImpl of AIROods {
impl DexAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator
)
}
}
3 changes: 3 additions & 0 deletions src/air/layouts/dex/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 8;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 128;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const ECDSA: usize = 5;
const EXECUTION: usize = 1;
Expand Down
22 changes: 13 additions & 9 deletions src/air/layouts/dynamic.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use cairo_verifier::{
common::{math::{Felt252Div, Felt252PartialOrd, pow}, asserts::assert_range_u128}
};

impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
impl DynamicAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
interaction_elements: InteractionElements,
public_input: @PublicInput,
Expand Down Expand Up @@ -203,25 +203,29 @@ impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInp
};

eval_composition_polynomial_inner(
mask_values,
constraint_coefficients,
point,
trace_generator,
global_values,
dynamic_params
mask_values, constraint_coefficients, point, trace_generator, global_values,
)
}
}

impl StarknetAIROodsImpl of AIROods {
impl DynamicAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
0
eval_oods_polynomial_inner(
column_values,
oods_values,
constraint_coefficients,
point,
oods_point,
trace_generator,
dynamic_params,
)
}
}
2 changes: 1 addition & 1 deletion src/air/layouts/dynamic/autogenerated.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn eval_composition_polynomial_inner(
point: felt252,
trace_generator: felt252,
global_values: GlobalValues,
dynamic_params: DynamicParams
) -> felt252 {
let dynamic_params = global_values.dynamic_params;
let add_mod_a0_suboffset = dynamic_params.add_mod_a0_suboffset;
let add_mod_a1_suboffset = dynamic_params.add_mod_a1_suboffset;
let add_mod_a2_suboffset = dynamic_params.add_mod_a2_suboffset;
Expand Down
9 changes: 5 additions & 4 deletions src/air/layouts/recursive.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use cairo_verifier::{
global_values::{GlobalValues, InteractionElements, EcPoint},
public_input::RecursivePublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING, PEDERSEN_BUILTIN_RATIO,
PEDERSEN_BUILTIN_REPETITIONS, segments,
DynamicParams, PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING,
PEDERSEN_BUILTIN_RATIO, PEDERSEN_BUILTIN_REPETITIONS, segments,
},
},
air::{AIRComposition, AIROods}, diluted::get_diluted_product,
Expand Down Expand Up @@ -96,17 +96,18 @@ impl RecursiveAIRCompositionImpl of AIRComposition<InteractionElements, PublicIn
}
}

impl RecursiveAIROodsImpl of AIROods {
impl RecursiveAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator
)
}
}
3 changes: 3 additions & 0 deletions src/air/layouts/recursive/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 8;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 128;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const BITWISE: usize = 5;
const EXECUTION: usize = 1;
Expand Down
7 changes: 4 additions & 3 deletions src/air/layouts/recursive_with_poseidon.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use cairo_verifier::{
global_values::{GlobalValues, InteractionElements, EcPoint},
public_input::RecursiveWithPoseidonPublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING, PEDERSEN_BUILTIN_RATIO,
PEDERSEN_BUILTIN_REPETITIONS, segments, POSEIDON_RATIO
DynamicParams, PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING,
PEDERSEN_BUILTIN_RATIO, PEDERSEN_BUILTIN_REPETITIONS, segments, POSEIDON_RATIO
},
},
air::{AIRComposition, AIROods}, diluted::get_diluted_product,
Expand Down Expand Up @@ -125,14 +125,15 @@ impl RecursiveWithPoseidonAIRCompositionImpl of AIRComposition<InteractionElemen
}
}

impl RecursiveWithPoseidonAIROodsImpl of AIROods {
impl RecursiveWithPoseidonAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
Expand Down
3 changes: 3 additions & 0 deletions src/air/layouts/recursive_with_poseidon/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 16;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 256;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const BITWISE: usize = 5;
const EXECUTION: usize = 1;
Expand Down
5 changes: 3 additions & 2 deletions src/air/layouts/small.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cairo_verifier::{
global_values::{GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig},
public_input::SmallPublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, PEDERSEN_BUILTIN_RATIO, ECDSA_BUILTIN_RATIO,
DynamicParams, PUBLIC_MEMORY_STEP, PEDERSEN_BUILTIN_RATIO, ECDSA_BUILTIN_RATIO,
ECDSA_BUILTIN_REPETITIONS, PEDERSEN_BUILTIN_REPETITIONS, segments,
},
},
Expand Down Expand Up @@ -95,14 +95,15 @@ impl SmallAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput>
}
}

impl SmallAIROodsImpl of AIROods {
impl SmallAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
Expand Down
3 changes: 3 additions & 0 deletions src/air/layouts/small/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 8;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 128;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const ECDSA: usize = 5;
const EXECUTION: usize = 1;
Expand Down
7 changes: 4 additions & 3 deletions src/air/layouts/starknet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use cairo_verifier::{
},
public_input::StarknetPublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING, PEDERSEN_BUILTIN_RATIO,
PEDERSEN_BUILTIN_REPETITIONS, segments, ECDSA_BUILTIN_RATIO,
DynamicParams, PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING,
PEDERSEN_BUILTIN_RATIO, PEDERSEN_BUILTIN_REPETITIONS, segments, ECDSA_BUILTIN_RATIO,
ECDSA_BUILTIN_REPETITIONS, POSEIDON_RATIO
},
},
Expand Down Expand Up @@ -145,14 +145,15 @@ impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInp
}
}

impl StarknetAIROodsImpl of AIROods {
impl StarknetAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
Expand Down
3 changes: 3 additions & 0 deletions src/air/layouts/starknet/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 16;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 256;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const BITWISE: usize = 6;
const EC_OP: usize = 7;
Expand Down
7 changes: 4 additions & 3 deletions src/air/layouts/starknet_with_keccak.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use cairo_verifier::{
},
public_input::StarknetWithKeccakPublicInputImpl,
constants::{
PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING, PEDERSEN_BUILTIN_RATIO,
PEDERSEN_BUILTIN_REPETITIONS, segments, ECDSA_BUILTIN_RATIO,
DynamicParams, PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING,
PEDERSEN_BUILTIN_RATIO, PEDERSEN_BUILTIN_REPETITIONS, segments, ECDSA_BUILTIN_RATIO,
ECDSA_BUILTIN_REPETITIONS, POSEIDON_RATIO, KECCAK_RATIO
},
},
Expand Down Expand Up @@ -167,14 +167,15 @@ impl StarknetWithKeccakAIRCompositionImpl of AIRComposition<InteractionElements,
}
}

impl StarknetWithKeccakAIROodsImpl of AIROods {
impl StarknetWithKeccakAIROodsImpl of AIROods<DynamicParams> {
fn eval_oods_polynomial(
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
dynamic_params: DynamicParams,
) -> felt252 {
eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
Expand Down
3 changes: 3 additions & 0 deletions src/air/layouts/starknet_with_keccak/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ const RANGE_CHECK_BUILTIN_RATIO: felt252 = 16;
const RANGE_CHECK_BUILTIN_ROW_RATIO: felt252 = 256;
const RANGE_CHECK_N_PARTS: felt252 = 8;

#[derive(Drop, Copy, Serde)]
struct DynamicParams {}

mod segments {
const BITWISE: usize = 6;
const EC_OP: usize = 7;
Expand Down
3 changes: 3 additions & 0 deletions src/air/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use cairo_verifier::{
// === STARKNET_WITH_KECCAK BEGIN ===
// air::layouts::starknet_with_keccak::constants::segments,
// === STARKNET_WITH_KECCAK END ===
// === DYNAMIC BEGIN ===
// air::layouts::dynamic::constants::segments,
// === DYNAMIC END ===
air::public_memory::{
Page, PageTrait, ContinuousPageHeader, get_continuous_pages_product, AddrValueSize
},
Expand Down
9 changes: 8 additions & 1 deletion src/benches/stark/verify.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ use cairo_verifier::{
};

fn bench_stark_verify() {
let public_input = stone_proof_fibonacci_keccak::public_input::get();
let queries = stone_proof_fibonacci_keccak::queries::get().span();
let commitment = stone_proof_fibonacci_keccak::stark::commitment::get();
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, queries, commitment, witness, stark_domains,
NUM_COLUMNS_FIRST,
NUM_COLUMNS_SECOND,
@public_input,
queries,
commitment,
witness,
stark_domains,
)
}
3 changes: 3 additions & 0 deletions src/deserialization/stark.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ use cairo_verifier::{
// === STARKNET_WITH_KECCAK BEGIN ===
// air::layouts::starknet_with_keccak::traces::TracesConfig,
// === STARKNET_WITH_KECCAK END ===
// === DYNAMIC BEGIN ===
// air::layouts::dynamic::traces::TracesConfig,
// === DYNAMIC END ===
deserialization::{
traces::{
TracesConfigWithSerde, TracesDecommitmentWithSerde, TracesWitnessWithSerde,
Expand Down
5 changes: 5 additions & 0 deletions src/deserialization/traces.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ use cairo_verifier::{
// traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness}
// },
// === STARKNET_WITH_KECCAK END ===
// === DYNAMIC BEGIN ===
// air::layouts::dynamic::{
// traces::TracesConfig, traces::{TracesUnsentCommitment, TracesDecommitment, TracesWitness}
// },
// === DYNAMIC END ===
deserialization::{
vector::{
VectorCommitmentConfig, VectorCommitmentWitness, VectorCommitmentConfigWithSerde,
Expand Down
3 changes: 3 additions & 0 deletions src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ use cairo_verifier::{
// === STARKNET_WITH_KECCAK BEGIN ===
// air::layouts::starknet_with_keccak::public_input::StarknetWithKeccakPublicInputImpl as PublicInputImpl,
// === STARKNET_WITH_KECCAK END ===
// === DYNAMIC BEGIN ===
// air::layouts::dynamic::public_input::DynamicPublicInputImpl as PublicInputImpl,
// === DYNAMIC END ===
};

const SECURITY_BITS: felt252 = 50;
Expand Down
Loading

0 comments on commit a2659dd

Please sign in to comment.