Skip to content

Commit

Permalink
review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Dec 27, 2023
1 parent 02b604d commit 1f64cdf
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
3 changes: 0 additions & 3 deletions calc.py

This file was deleted.

1 change: 1 addition & 0 deletions src/common.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod array_append;
mod math;
mod array_print;
mod array_extend;
mod consts;

#[cfg(test)]
mod tests;
5 changes: 1 addition & 4 deletions src/common/array_extend.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
trait ArrayExtendTrait<T> {
fn extend(ref self: Array<T>, span: Span<T>);
}

#[generate_trait]
impl ArrayExtend<T, +Copy<T>, +Drop<T>> of ArrayExtendTrait<T> {
fn extend(ref self: Array<T>, span: Span<T>) {
let mut i = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/common/consts.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const STARK_PRIME_MINUS_TWO: felt252 =
3618502788666131213697322783095070105623107215331596699973092056135872020479;
4 changes: 3 additions & 1 deletion src/common/math.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use cairo_verifier::common::consts::STARK_PRIME_MINUS_TWO;

fn pow(base: felt252, exp: felt252) -> felt252 {
if exp == 0 {
return 1;
Expand All @@ -23,5 +25,5 @@ fn pow(base: felt252, exp: felt252) -> felt252 {
fn mul_inverse(x: felt252) -> felt252 {
// From Fermat's little theorem, a ^ (p - 1) = 1 when p is prime and a != 0. Since a ^ (p - 1) = a · a ^ (p - 2) we have that
// a ^ (p - 2) is the multiplicative inverse of a modulo p.
pow(x, 3618502788666131213697322783095070105623107215331596699973092056135872020479)
pow(x, STARK_PRIME_MINUS_TWO)
}
5 changes: 2 additions & 3 deletions src/fri/fri_config.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ struct FriConfig {
fn fri_config_validate(
config: FriConfig, log_n_cosets: felt252, n_verifier_friendly_commitment_layers: felt252
) -> felt252 {
let n_layers = config.n_layers.try_into().unwrap();
let log_last_layer_degree_bound = config.log_last_layer_degree_bound.try_into().unwrap();
let n_layers: u32 = config.n_layers.try_into().unwrap();
let log_last_layer_degree_bound: u32 = config.log_last_layer_degree_bound.try_into().unwrap();

assert(log_last_layer_degree_bound >= 0, 'Must be non negative value');
assert(log_last_layer_degree_bound <= MAX_LAST_LAYER_LOG_DEGREE_BOUND, 'Value too big');

assert(*config.fri_step_sizes.at(0) == 0, 'Invalid value');
Expand Down
3 changes: 1 addition & 2 deletions src/fri/fri_layer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ fn compute_next_layer(
let coset_size_u256: u256 = coset_size.into();

let coset_index = (index_u256 / coset_size_u256).low.into();
assert(coset_index.into() >= 0_u256, 'Must be non negative value');

verify_indices.append(coset_index);

Expand All @@ -116,7 +115,7 @@ fn compute_next_layer(

// Verify that at least one query was consumed.
let coset_elements_len = coset_elements.len();
assert(coset_elements_len >= 0, 'Must be non negative value');
assert(coset_elements_len > 0, 'Must be non negative value');

let coset_elements_span = coset_elements.span();

Expand Down

0 comments on commit 1f64cdf

Please sign in to comment.