Skip to content

Commit

Permalink
base public input verification
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofneto committed Jan 2, 2024
1 parent e09fe34 commit 92c26b4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/air/composition.cairo
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
use cairo_verifier::air::global_values::{EcPoint, InteractionElements, GlobalValues};
use cairo_verifier::air::constants::{
PUBLIC_MEMORY_STEP, DILUTED_N_BITS, DILUTED_SPACING, PEDERSEN_BUILTIN_RATIO,
PEDERSEN_BUILTIN_REPETITIONS, segments
PEDERSEN_BUILTIN_REPETITIONS, segments, SHIFT_POINT_X, SHIFT_POINT_Y
};
use cairo_verifier::air::public_input::{PublicInput, PublicInputTrait};
use cairo_verifier::air::diluted::get_diluted_product;
use cairo_verifier::air::pedersen::{eval_pedersen_x, eval_pedersen_y};
use cairo_verifier::air::autogenerated::eval_composition_polynomial_inner;
use cairo_verifier::common::math::{Felt252Div, Felt252PartialOrd, pow};

const SHIFT_POINT_X: felt252 = 0x49ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804;
const SHIFT_POINT_Y: felt252 = 0x3ca0cfe4b3bc6ddf346d49d06ea0ed34e621062c0e056c1d0405d266e10268a;

fn eval_composition_polynomial(
interaction_elements: InteractionElements,
public_input: PublicInput,
Expand Down
8 changes: 8 additions & 0 deletions src/air/constants.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,11 @@ mod segments {
const BITWISE: usize = 5;
const N_SEGMENTS: usize = 6;
}

// Pedersen builtin
const SHIFT_POINT_X: felt252 = 0x49ee3eba8c1600700ee1b87eb599f16716b0b1022947733551fde4050ca6804;
const SHIFT_POINT_Y: felt252 = 0x3ca0cfe4b3bc6ddf346d49d06ea0ed34e621062c0e056c1d0405d266e10268a;

const SECURITY_BITS: felt252 = 128;
const MAX_ADDRESS: felt252 = 0xffffffffffffffff;
const INITIAL_PC: felt252 = 1;
21 changes: 21 additions & 0 deletions src/air/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use cairo_verifier::air::public_memory::{
Page, PageTrait, ContinuousPageHeader, get_continuous_pages_product
};
use cairo_verifier::common::math::{pow, Felt252PartialOrd, Felt252Div};
use cairo_verifier::air::constants::{segments, MAX_ADDRESS};

#[derive(Drop)]
struct SegmentInfo {
Expand Down Expand Up @@ -58,4 +59,24 @@ impl PublicInputImpl of PublicInputTrait {

(prod, total_length)
}

fn verify(self: @PublicInput) -> (felt252, felt252) {
let public_segments = self.segments;

let initial_pc = *public_segments.at(segments::PROGRAM).begin_addr;
let final_pc = *public_segments.at(segments::PROGRAM).stop_ptr;
let initial_ap = *public_segments.at(segments::EXECUTION).begin_addr;
let initial_fp = initial_ap;
let final_ap = *public_segments.at(segments::EXECUTION).stop_ptr;
let output_start = *public_segments.at(segments::OUTPUT).begin_addr;
let output_stop = *public_segments.at(segments::OUTPUT).stop_ptr;

assert(initial_ap < MAX_ADDRESS, 'Invalid initial_ap');
assert(final_ap < MAX_ADDRESS, 'Invalid final_ap');

// TODO support more pages?
assert((*self.continuous_page_headers).len() == 0, 'Invalid continuous_page_headers');

(0, 0)
}
}

0 comments on commit 92c26b4

Please sign in to comment.