aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/mcl/bn.hpp3
-rw-r--r--test/bn_test.cpp3
2 files changed, 5 insertions, 1 deletions
diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp
index 25305b4..2b46cc4 100644
--- a/include/mcl/bn.hpp
+++ b/include/mcl/bn.hpp
@@ -325,13 +325,14 @@ struct GLV {
tbl[3] = A + P; tbl[3].normalize();
Q.clear();
if (constTime) {
+ G1 *pTbl[] = { &tbl[0], &Q, &Q, &Q };
tbl[0] = tbl[1];
for (int i = (int)n - 1; i >= 0; i--) {
G1::dbl(Q, Q);
bool ai = mcl::gmp::testBit(a, i);
bool bi = mcl::gmp::testBit(b, i);
unsigned int c = bi * 2 + ai;
- Q += tbl[c];
+ *pTbl[c] += tbl[c];
}
} else {
for (int i = (int)n - 1; i >= 0; i--) {
diff --git a/test/bn_test.cpp b/test/bn_test.cpp
index a7d67a3..736c277 100644
--- a/test/bn_test.cpp
+++ b/test/bn_test.cpp
@@ -229,6 +229,9 @@ void testPairing(const G1& P, const G2& Q, const char *eStr)
Fp12::pow(ea, e, a);
G1::mul(Pa, P, a);
G2::mul(Qa, Q, a);
+ G1 T;
+ G1::mulCT(T, P, a);
+ CYBOZU_TEST_EQUAL(Pa, T);
BN::pairing(e1, Pa, Q);
BN::pairing(e2, P, Qa);
CYBOZU_TEST_EQUAL(ea, e1);