rename len to size

dev
MITSUNARI Shigeo 10 years ago
parent 31abdd0eec
commit 0683d21e41
  1. 4
      include/mcl/gmp_util.hpp
  2. 2
      src/fp.cpp
  3. 2
      test/ec_test.cpp
  4. 2
      test/elgamal_test.cpp

@ -77,7 +77,7 @@ struct Gmp {
static size_t getArray(T *buf, size_t maxSize, const mpz_class& x)
{
const size_t totalSize = sizeof(T) * maxSize;
if (getBitLen(x) > totalSize * 8) return 0;
if (getBitSize(x) > totalSize * 8) return 0;
memset(buf, 0, sizeof(*buf) * maxSize);
size_t size;
mpz_export(buf, &size, -1, sizeof(T), 0, 0, x.get_mpz_t());
@ -244,7 +244,7 @@ struct Gmp {
{
return mpz_probab_prime_p(x.get_mpz_t(), 25) != 0;
}
static inline size_t getBitLen(const mpz_class& x)
static inline size_t getBitSize(const mpz_class& x)
{
return mpz_sizeinbase(x.get_mpz_t(), 2);
}

@ -248,7 +248,7 @@ void Op::init(const std::string& mstr, int base, size_t maxBitSize)
bool isMinus;
strToGmp(mp, &isMinus, mstr, base);
if (isMinus) throw cybozu::Exception("Op:init:mstr is minus") << mstr;
bitSize = Gmp::getBitLen(mp);
bitSize = Gmp::getBitSize(mp);
if (bitSize > maxBitSize) throw cybozu::Exception("Op:init:too large bitSize") << mstr << bitSize << maxBitSize;
const size_t n = Gmp::getArray(p, maxN, mp);
if (n == 0) throw cybozu::Exception("Op:init:bad mstr") << mstr;

@ -26,7 +26,7 @@ struct Test {
Fp::setModulo(para.p);
Zn::setModulo(para.n);
Ec::setParam(para.a, para.b);
// CYBOZU_TEST_EQUAL(para.bitSize, Fp(-1).getBitLen());
// CYBOZU_TEST_EQUAL(para.bitSize, Fp(-1).getBitSize());
}
void cstr() const
{

@ -191,7 +191,7 @@ CYBOZU_TEST_AUTO(testEc)
Ec::setParam(para.a, para.b);
const Fp x0(para.gx);
const Fp y0(para.gy);
const size_t bitSize = Zn(-1).getBitLen();
const size_t bitSize = Zn(-1).getBitSize();
const Ec P(x0, y0);
/*
Zn = <P>

Loading…
Cancel
Save