diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-02 10:10:29 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-02 10:10:29 +0800 |
commit | c20c7610244af8846d9d6a3d6a5be676a7ce92d7 (patch) | |
tree | 835f780487d5c7b50af84010cd9532b0dfe544eb | |
parent | 624259deea0c52c54626ac3821c2c47d3e74c599 (diff) | |
download | dexon-mcl-c20c7610244af8846d9d6a3d6a5be676a7ce92d7.tar.gz dexon-mcl-c20c7610244af8846d9d6a3d6a5be676a7ce92d7.tar.zst dexon-mcl-c20c7610244af8846d9d6a3d6a5be676a7ce92d7.zip |
bug fix of mulCTrelease20170402
-rw-r--r-- | include/mcl/bn.hpp | 3 | ||||
-rw-r--r-- | test/bn_test.cpp | 3 |
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); |