Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Dec 19, 2023
1 parent 9fcec24 commit c483e4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/common/math.cairo
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
fn pow(base: felt252, exp: felt252) -> felt252 {
if exp == 0 {
return 1; // Return 1 for zero exponent
return 1;
}
let mut exp: u256 = exp.into();
let mut res = 1; // Initialize result as 1
let mut curr_base = base; // Current base value
let mut res = 1;
let mut curr_base = base;

loop {
if exp == 0 {
break;
} else {
if exp % 2 == 1 {
res = res * curr_base; // Multiply result only when exp is odd
res = res * curr_base;
}
curr_base = curr_base * curr_base; // Square the base for next iteration
exp = exp / 2; // Divide exponent by 2
curr_base = curr_base * curr_base;
exp = exp / 2;
}
};
res
Expand All @@ -24,4 +24,4 @@ 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)
}
}
1 change: 1 addition & 0 deletions src/fri/fri.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 1 addition & 3 deletions src/fri/fri_last_layer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ use cairo_verifier::fri::fri_layer::FriLayerQuery;
// Verifies FRI last layer by evaluating the given polynomial on the given points (=inverses of
// x_inv_values), and comparing the results to the given values.
fn verify_last_layer(
n_queries: felt252,
queries: Span<FriLayerQuery>,
coefficients: Span<felt252>
n_queries: felt252, queries: Span<FriLayerQuery>, coefficients: Span<felt252>
) {
let mut i: u32 = 0;
let len: u32 = n_queries.try_into().unwrap();
Expand Down

0 comments on commit c483e4c

Please sign in to comment.