Skip to content

Commit

Permalink
tests for mod sqr
Browse files Browse the repository at this point in the history
  • Loading branch information
shramee committed May 15, 2024
1 parent 25ac6fe commit c76f71e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/math/src/tests/mod_arithmetics_test.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use alexandria_math::mod_arithmetics::{add_mod, sub_mod, mult_mod, div_mod, pow_mod};
use alexandria_math::mod_arithmetics::{add_mod, sub_mod, mult_mod, sqr_mod, div_mod, pow_mod};
use core::traits::TryInto;

const p: u256 =
Expand Down Expand Up @@ -115,6 +115,22 @@ fn mult_mod_2_test() {
assert_eq!(mult_mod(pow_256_minus_1, 1, 2), 1, "Incorrect result");
}

#[test]
#[available_gas(500000000)]
fn sqr_mod_test() {
assert_eq!(sqr_mod(p, 2), 1, "Incorrect result");
assert_eq!(
sqr_mod(p, pow_256_minus_1),
mult_mod(p, p, pow_256_minus_1.try_into().unwrap()),
"Incorrect result"
);
assert_eq!(
sqr_mod(pow_256_minus_1, p),
mult_mod(pow_256_minus_1, pow_256_minus_1, p.try_into().unwrap()),
"Incorrect result"
);
}

#[test]
#[available_gas(500000000)]
fn div_mod_test() {
Expand Down

0 comments on commit c76f71e

Please sign in to comment.