Skip to content

Commit 45736e9

Browse files
committed
finding 6: final pairing native test.
1 parent bdc89a4 commit 45736e9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

barretenberg/cpp/src/barretenberg/ecc/curves/bn254/pairing.test.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ TEST(pairing, PairingLinearityCheck)
268268
TEST(pairing, FinalExponentiation)
269269
{
270270
auto pow = [](const fq12& a, const fq& b) {
271+
const uint256_t exponent(b);
271272
fq12 result = fq12::one();
272273
fq12 base = a;
273274
for (size_t i = 0; i < 256; ++i) {
274-
if ((b.data[0] >> i) & 1) {
275+
if (exponent.get_bit(i)) {
275276
result *= base;
276277
}
277278
base = base.sqr();
@@ -291,10 +292,11 @@ TEST(pairing, FinalExponentiation)
291292
fq12 result = pairing::final_exponentiation_easy_part(element);
292293
result = pairing::final_exponentiation_tricky_part(result);
293294

294-
fq12 expected = element;
295-
expected = pairing::final_exponentiation_easy_part(expected);
296-
expected = pow(expected, mu0) + pow(expected, mu1).frobenius_map_one() + pow(expected, mu2).frobenius_map_two() +
295+
fq12 expected = pairing::final_exponentiation_easy_part(element);
296+
expected = pow(expected, mu0) * pow(expected, mu1).frobenius_map_one() * pow(expected, mu2).frobenius_map_two() *
297297
pow(expected, mu3).frobenius_map_three();
298+
299+
EXPECT_EQ(result, expected);
298300
}
299301

300302
TEST(pairing, Constants)

0 commit comments

Comments
 (0)