change value of IoPrefix

dev
MITSUNARI Shigeo 8 years ago
parent 0501225186
commit 4ce42c26b4
  1. 4
      include/mcl/fp.hpp
  2. 12
      include/mcl/op.hpp
  3. 4
      src/fp.cpp

@ -274,8 +274,8 @@ public:
fp::copyUnitToByteAsLE(reinterpret_cast<uint8_t*>(&str[0]), p, str.size());
return;
}
// use low 5-bit ioMode for base
fp::arrayToStr(str, b.p, b.n, ioMode & 31);
// use low 8-bit ioMode for Fp
fp::arrayToStr(str, b.p, b.n, ioMode & 255);
}
std::string getStr(int ioMode = 0) const
{

@ -72,18 +72,18 @@ namespace mcl {
*/
enum IoMode {
IoAuto = 0, // dec or hex according to ios_base::fmtflags
IoPrefix = 1, // append '0b'(bin) or '0x'(hex)
IoBin = 2, // binary number without prefix
IoDec = 10, // decimal number without prefix
IoHex = 16, // hexadecimal number without prefix
IoBinPrefix = IoBin | IoPrefix,
IoHexPrefix = IoHex | IoPrefix,
IoArray = 32, // array of Unit(fixed size)
IoArrayRaw = 64, // raw array of Unit without Montgomery conversion
IoPrefix = 128, // append '0b'(bin) or '0x'(hex)
IoBinPrefix = IoBin | IoPrefix,
IoHexPrefix = IoHex | IoPrefix,
IoEcAffine = 0, // affine coordinate
IoEcCompY = 128, // 1-bit y representation of elliptic curve
IoEcComp = 256, // use MBS for 1-bit y
IoEcProj = 512, // projective or jacobi coordinate
IoEcCompY = 256, // 1-bit y representation of elliptic curve
IoEcComp = 512, // use MBS for 1-bit y
IoEcProj = 1024, // projective or jacobi coordinate
IoTight = IoEcComp // tight repr of Ec(obsolete)
};

@ -538,8 +538,8 @@ void streamToArray(bool *pIsMinus, Unit *x, size_t byteSize, std::istream& is, i
is >> str;
const char *p = verifyStr(pIsMinus, &ioMode, str);
mpz_class mx;
// check low 5-bit of ioMode
if (!gmp::setStr(mx, p, ioMode & (31 & ~IoPrefix))) {
// use low 8-bit ioMode for Fp
if (!gmp::setStr(mx, p, ioMode & (255 & ~IoPrefix))) {
throw cybozu::Exception("fp:streamToArray:bad format") << ioMode << str;
}
const size_t n = (byteSize + sizeof(Unit) - 1) / sizeof(Unit);

Loading…
Cancel
Save