Skip to content

Commit

Permalink
Starknet layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fmkra committed Jul 24, 2024
1 parent d1e7cd7 commit e4d935b
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/air/layouts/starknet.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ mod constants;
mod global_values;
mod public_input;
mod traces;
mod contract;

use cairo_verifier::{
air::{
constants::{SHIFT_POINT_X, SHIFT_POINT_Y, StarkCurve},
layouts::starknet::{
autogenerated::{eval_composition_polynomial_inner, eval_oods_polynomial_inner},
contract::{
IStarknetLayoutContract1Dispatcher, IStarknetLayoutContract1DispatcherTrait,
IStarknetLayoutContract2Dispatcher, IStarknetLayoutContract2DispatcherTrait,
},
global_values::{
GlobalValues, InteractionElements, EcPoint, EcdsaSigConfig, CurveConfig
},
Expand All @@ -30,6 +34,7 @@ use cairo_verifier::{
},
common::{math::{Felt252Div, Felt252PartialOrd, pow}, asserts::assert_range_u128}
};
use starknet::ContractAddress;

impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInput> {
fn eval_composition_polynomial(
Expand All @@ -39,7 +44,8 @@ impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInp
constraint_coefficients: Span<felt252>,
point: felt252,
trace_domain_size: felt252,
trace_generator: felt252
trace_generator: felt252,
contract_address_1: ContractAddress,
) -> felt252 {
let memory_z = interaction_elements.memory_multi_column_perm_perm_interaction_elm;
let memory_alpha = interaction_elements.memory_multi_column_perm_hash_interaction_elm0;
Expand Down Expand Up @@ -139,7 +145,9 @@ impl StarknetAIRCompositionImpl of AIRComposition<InteractionElements, PublicInp
diluted_check_final_cum_val: diluted_prod
};

eval_composition_polynomial_inner(
IStarknetLayoutContract1Dispatcher {
contract_address: contract_address_1
}.eval_composition_polynomial_inner(
mask_values, constraint_coefficients, point, trace_generator, global_values
)
}
Expand All @@ -153,8 +161,11 @@ impl StarknetAIROodsImpl of AIROods {
point: felt252,
oods_point: felt252,
trace_generator: felt252,
contract_address_2: ContractAddress,
) -> felt252 {
eval_oods_polynomial_inner(
IStarknetLayoutContract2Dispatcher {
contract_address: contract_address_2
}.eval_oods_polynomial_inner(
column_values, oods_values, constraint_coefficients, point, oods_point, trace_generator,
)
}
Expand Down
92 changes: 92 additions & 0 deletions src/air/layouts/starknet/contract.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
use cairo_verifier::air::layouts::starknet::global_values::GlobalValues;

#[starknet::interface]
trait IStarknetLayoutContract1<ContractState> {
fn eval_composition_polynomial_inner(
self: @ContractState,
mask_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
trace_generator: felt252,
global_values: GlobalValues
) -> felt252;
}

#[starknet::interface]
trait IStarknetLayoutContract2<ContractState> {
fn eval_oods_polynomial_inner(
self: @ContractState,
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
) -> felt252;
}

#[starknet::contract]
mod StarknetLayoutContract1 {
use super::IStarknetLayoutContract1;
use cairo_verifier::air::layouts::starknet::{
global_values::GlobalValues,
autogenerated::eval_composition_polynomial_inner,
};

#[storage]
struct Storage {}

#[abi(embed_v0)]
impl StarknetLayoutContract1 of IStarknetLayoutContract1<ContractState> {
fn eval_composition_polynomial_inner(
self: @ContractState,
mask_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
trace_generator: felt252,
global_values: GlobalValues
) -> felt252 {
eval_composition_polynomial_inner(
mask_values,
constraint_coefficients,
point,
trace_generator,
global_values
)
}
}
}

#[starknet::contract]
mod StarknetLayoutContract2 {
use super::IStarknetLayoutContract2;
use cairo_verifier::air::layouts::starknet::{
global_values::GlobalValues,
autogenerated::eval_oods_polynomial_inner,
};

#[storage]
struct Storage {}

#[abi(embed_v0)]
impl StarknetLayoutContract2 of IStarknetLayoutContract2<ContractState> {
fn eval_oods_polynomial_inner(
self: @ContractState,
column_values: Span<felt252>,
oods_values: Span<felt252>,
constraint_coefficients: Span<felt252>,
point: felt252,
oods_point: felt252,
trace_generator: felt252,
) -> felt252 {
eval_oods_polynomial_inner(
column_values,
oods_values,
constraint_coefficients,
point,
oods_point,
trace_generator,
)
}
}
}

0 comments on commit e4d935b

Please sign in to comment.