diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-03-08 13:59:58 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-03-08 13:59:58 +0800 |
commit | fa9bab8666586efe21522c5cbd5b794e20aea502 (patch) | |
tree | ea4b355d38740334fb9fc5042996ceba2db64b84 | |
parent | 598fcc6ebaddac6795fcdcf17b768fc30fea48d3 (diff) | |
download | dexon-mcl-fa9bab8666586efe21522c5cbd5b794e20aea502.tar.gz dexon-mcl-fa9bab8666586efe21522c5cbd5b794e20aea502.tar.zst dexon-mcl-fa9bab8666586efe21522c5cbd5b794e20aea502.zip |
add getPrecomputedQcoeffSize
-rw-r--r-- | include/mcl/bn.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index c9873e2..c862d7b 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -232,6 +232,7 @@ struct ParamT { // Loop parameter for the Miller loop part of opt. ate pairing. typedef std::vector<int8_t> SignVec; SignVec siTbl; + size_t precomputedQcoeffSize; bool useNAF; SignVec zReplTbl; @@ -297,6 +298,7 @@ struct ParamT { const mpz_class largest_c = abs(6 * z + 2); useNAF = getGoodRepl(siTbl, largest_c); + precomputedQcoeffSize = getPrecomputeQcoeffSize(siTbl); getGoodRepl(zReplTbl, abs(z)); exp_c0 = -2 + z * (-18 + z * (-30 - 36 *z)); exp_c1 = 1 + z * (-12 + z * (-18 - 36 * z)); @@ -306,6 +308,15 @@ struct ParamT { { return (((c[4] * x + c[3]) * x + c[2]) * x + c[1]) * x + c[0]; } + size_t getPrecomputeQcoeffSize(const SignVec& sv) const + { + size_t idx = 2 + 2; + for (size_t i = 2; i < sv.size(); i++) { + idx++; + if (sv[i]) idx++; + } + return idx; + } }; template<class Fp> |