diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-20 11:35:22 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-04-20 11:35:22 +0800 |
commit | c044993c4c3dcaff76e994a109b638c330428691 (patch) | |
tree | 6a7bd6efcce3b9395df8c20fe7b6bf543262d1d4 | |
parent | 4e43eeabd88432a7c61aaba4fad2556696560678 (diff) | |
download | tangerine-mcl-c044993c4c3dcaff76e994a109b638c330428691.tar.gz tangerine-mcl-c044993c4c3dcaff76e994a109b638c330428691.tar.zst tangerine-mcl-c044993c4c3dcaff76e994a109b638c330428691.zip |
split pow and powCT
-rw-r--r-- | include/mcl/operator.hpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/include/mcl/operator.hpp b/include/mcl/operator.hpp index 7d6cdac..efe55d7 100644 --- a/include/mcl/operator.hpp +++ b/include/mcl/operator.hpp @@ -41,21 +41,32 @@ struct Operator : E { friend MCL_FORCE_INLINE T operator/(const T& a, const T& b) { T c; T::inv(c, b); c *= a; return c; } MCL_FORCE_INLINE T operator-() const { T c; T::neg(c, static_cast<const T&>(*this)); return c; } template<class tag2, size_t maxBitSize2, template<class _tag, size_t _maxBitSize> class FpT> - static void pow(T& z, const T& x, const FpT<tag2, maxBitSize2>& y, bool constTime = false) + static void pow(T& z, const T& x, const FpT<tag2, maxBitSize2>& y) { fp::Block b; y.getBlock(b); - powArray(z, x, b.p, b.n, false, constTime); + powArray(z, x, b.p, b.n, false); } - static void pow(T& z, const T& x, int y, bool constTime = false) + template<class tag2, size_t maxBitSize2, template<class _tag, size_t _maxBitSize> class FpT> + static void powCT(T& z, const T& x, const FpT<tag2, maxBitSize2>& y) + { + fp::Block b; + y.getBlock(b); + powArray(z, x, b.p, b.n, false, true); + } + static void pow(T& z, const T& x, int y) { const Unit u = abs(y); - powArray(z, x, &u, 1, y < 0, constTime); + powArray(z, x, &u, 1, y < 0); } static void pow(T& z, const T& x, const mpz_class& y, bool constTime = false) { powArray(z, x, gmp::getUnit(y), abs(y.get_mpz_t()->_mp_size), y < 0, constTime); } + static void powCT(T& z, const T& x, const mpz_class& y) + { + powArray(z, x, gmp::getUnit(y), abs(y.get_mpz_t()->_mp_size), y < 0, true); + } private: static void powArray(T& z, const T& x, const Unit *y, size_t yn, bool isNegative, bool constTime) { |