aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-11-12 09:35:23 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-11-12 09:35:58 +0800
commitb087e6f1f4b8018e9b0f05a21fc261a5cf2f0f58 (patch)
tree20b21d1184bf6c0216c939d39b1f593a5d3443ee
parent951f57111ce2723685053cdc83abd1cf1afad22c (diff)
downloadtangerine-mcl-b087e6f1f4b8018e9b0f05a21fc261a5cf2f0f58.tar.gz
tangerine-mcl-b087e6f1f4b8018e9b0f05a21fc261a5cf2f0f58.tar.zst
tangerine-mcl-b087e6f1f4b8018e9b0f05a21fc261a5cf2f0f58.zip
set xi_a in Fp::init
-rw-r--r--include/mcl/fp.hpp8
-rw-r--r--include/mcl/op.hpp3
-rw-r--r--src/fp.cpp8
3 files changed, 7 insertions, 12 deletions
diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp
index 44aab76..9fd6d74 100644
--- a/include/mcl/fp.hpp
+++ b/include/mcl/fp.hpp
@@ -120,10 +120,10 @@ public:
}
printf("\n");
}
- static inline void init(bool *pb, const mpz_class& _p, fp::Mode mode = fp::FP_AUTO)
+ static inline void init(bool *pb, const mpz_class& _p, fp::Mode mode = fp::FP_AUTO, int xi_a = 0)
{
assert(maxBitSize <= MCL_MAX_BIT_SIZE);
- *pb = op_.init(_p, maxBitSize, mode);
+ *pb = op_.init(_p, maxBitSize, xi_a, mode);
if (!*pb) return;
{ // set oneRep
FpT& one = *reinterpret_cast<FpT*>(op_.oneRep);
@@ -151,12 +151,12 @@ public:
#endif
*pb = true;
}
- static inline void init(bool *pb, const char *mstr, fp::Mode mode = fp::FP_AUTO)
+ static inline void init(bool *pb, const char *mstr, fp::Mode mode = fp::FP_AUTO, int xi_a = 0)
{
mpz_class p;
gmp::setStr(pb, p, mstr);
if (!*pb) return;
- init(pb, p, mode);
+ init(pb, p, mode, xi_a);
}
static inline size_t getModulo(char *buf, size_t bufSize)
{
diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp
index afbc8a4..a3b482f 100644
--- a/include/mcl/op.hpp
+++ b/include/mcl/op.hpp
@@ -341,8 +341,7 @@ struct Op {
*/
fp_mul(y, x, R2, p);
}
- bool init(const mpz_class& p, size_t maxBitSize, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE);
- void initFp2(int xi_a);
+ bool init(const mpz_class& p, size_t maxBitSize, int xi_a, Mode mode, size_t mclMaxBitSize = MCL_MAX_BIT_SIZE);
#ifdef MCL_USE_XBYAK
static FpGenerator* createFpGenerator();
static void destroyFpGenerator(FpGenerator *fg);
diff --git a/src/fp.cpp b/src/fp.cpp
index 473b26c..907d76d 100644
--- a/src/fp.cpp
+++ b/src/fp.cpp
@@ -362,7 +362,7 @@ static bool initForMont(Op& op, const Unit *p, Mode mode)
return true;
}
-bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBitSize)
+bool Op::init(const mpz_class& _p, size_t maxBitSize, int xi_a, Mode mode, size_t mclMaxBitSize)
{
if (mclMaxBitSize != MCL_MAX_BIT_SIZE) return false;
#ifdef MCL_USE_VINT
@@ -384,6 +384,7 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBi
mp = _p;
bitSize = gmp::getBitSize(mp);
pmod4 = gmp::getUnit(mp, 0) % 4;
+ this->xi_a = xi_a;
/*
priority : MCL_USE_XBYAK > MCL_USE_LLVM > none
Xbyak > llvm_mont > llvm > gmp_mont > gmp
@@ -653,10 +654,5 @@ int64_t getInt64(bool *pb, fp::Block& b, const fp::Op& op)
#pragma warning(pop)
#endif
-void Op::initFp2(int _xi_a)
-{
- this->xi_a = _xi_a;
-}
-
} } // mcl::fp