Skip to content

Commit

Permalink
fri_config_validate fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Dec 18, 2023
1 parent 4a6194c commit 4a10e1b
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/fri/fri_config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::option::OptionTrait;
use core::array::SpanTrait;
use core::traits::Into;
use cairo_verifier::structs::table_commitment_config::TableCommitmentConfig;
use cairo_verifier::structs::vector_commitment_config::VectorCommitmentConfig;

const MAX_LAST_LAYER_LOG_DEGREE_BOUND: u32 = 15;
const MAX_FRI_LAYERS: u32 = 15;
Expand Down Expand Up @@ -33,27 +34,39 @@ fn fri_config_validate(
assert(*(config.fri_step_sizes[0]) == 0, '');

let len: u32 = config.n_layers.try_into().unwrap();
let mut i = 0_u32;
let mut i: u32 = 1;
let mut sum_of_step_sizes: felt252 = 0;
let mut log_input_size = config.log_input_size;
loop {
if i == len { break; }

let fri_step: felt252 = *(config.fri_step_sizes.at(i));
assert(1_u32 <= fri_step.try_into().unwrap(), '');
assert(fri_step.try_into().unwrap() <= MAX_FRI_STEP + 1, '');
assert((*(config.inner_layers.at(i))).columns == fri_step * fri_step, '');
let table_commitment = *(config.inner_layers.at(i));

let fri_step_u32: u32 = fri_step.try_into().unwrap();
assert(1_u32 <= fri_step_u32, '');
assert(fri_step_u32 <= MAX_FRI_STEP + 1, '');
assert(table_commitment.columns == fri_step * fri_step, '');

i += 1;
log_input_size -= fri_step;
sum_of_step_sizes += fri_step;
// validate_vector_commitment(
// config=layers[0].vector,
// expected_height=log_input_size,
// n_verifier_friendly_commitment_layers=n_verifier_friendly_commitment_layers,
// );
};

validate_vector_commitment(
table_commitment.vector,
log_input_size,
n_verifier_friendly_commitment_layers,
);
};

let log_expected_input_degree = sum_of_step_sizes + config.log_last_layer_degree_bound;
assert(log_expected_input_degree + log_n_cosets == config.log_input_size, '');
log_expected_input_degree
}
}

// ghost functions
fn validate_vector_commitment(
config: VectorCommitmentConfig,
expected_height: felt252,
n_verifier_friendly_commitment_layers: felt252,
) {}

0 comments on commit 4a10e1b

Please sign in to comment.