add op.maxN parameter

dev
MITSUNARI Shigeo 6 years ago
parent 78289c408d
commit c7c4de4392
  1. 2
      include/mcl/op.hpp
  2. 17
      src/fp.cpp

@ -179,6 +179,7 @@ struct Op {
FpGenerator *fg;
mcl::Array<Unit> invTbl;
#endif
size_t maxN;
size_t N;
size_t bitSize;
bool (*fp_isZero)(const Unit*);
@ -254,6 +255,7 @@ struct Op {
fg = 0;
invTbl.clear();
#endif
maxN = 0;
N = 0;
bitSize = 0;
fp_isZero = 0;

@ -361,15 +361,15 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBi
if (maxBitSize > MCL_MAX_BIT_SIZE) return false;
if (_p <= 0) return false;
clear();
bool b;
maxN = (maxBitSize + fp::UnitBitSize - 1) / fp::UnitBitSize;
N = gmp::getUnitSize(_p);
if (N > maxN) return false;
{
const size_t maxN = (maxBitSize + fp::UnitBitSize - 1) / fp::UnitBitSize;
N = gmp::getUnitSize(_p);
if (N > maxN) return false;
bool b;
gmp::getArray(&b, p, N, _p);
if (!b) return false;
mp = _p;
}
mp = _p;
bitSize = gmp::getBitSize(mp);
pmod4 = gmp::getUnit(mp, 0) % 4;
/*
@ -488,8 +488,11 @@ bool Op::init(const mpz_class& _p, size_t maxBitSize, Mode mode, size_t mclMaxBi
}
#endif
if (!fp::initForMont(*this, p, mode)) return false;
sq.set(&b, mp);
if (!b) return false;
{
bool b;
sq.set(&b, mp);
if (!b) return false;
}
if (N * UnitBitSize <= 256) {
hash = sha256;
} else {

Loading…
Cancel
Save