Skip to content

Commit

Permalink
Test pow ext (#2003)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Nov 1, 2024
1 parent 97b0fd2 commit ede8310
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions std/math/fp2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ mod test {
use super::sub_ext;
use super::mul_ext;
use super::square_ext;
use super::pow_ext;
use super::inv_ext;
use super::eq_ext;
use std::check::assert;
Expand Down Expand Up @@ -247,4 +248,20 @@ mod test {
assert(eq_ext(mul_with_inverse, from_base(1)), || "Should be 1")
})
};

let test_pow = || {
let test_pow = |a, i, b| assert(eq_ext(pow_ext(a, i), b), || "Wrong power result");

test_pow(from_base(0), 0, from_base(1));
test_pow(from_base(1), 0, from_base(1));
test_pow(Fp2::Fp2(123, 1234), 0, from_base(1));

test_pow(from_base(9), 1, from_base(9));
test_pow(Fp2::Fp2(123, 1234), 1, Fp2::Fp2(123, 1234));

test_pow(from_base(9), 2, from_base(9 * 9));
test_pow(Fp2::Fp2(123, 1234), 2, Fp2::Fp2(16765445, 303564));

test_pow(from_base(9), 20, from_base(std::convert::fe(12157665459056928801 % std::field::modulus())));
};
}

0 comments on commit ede8310

Please sign in to comment.