diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 6ec11fa..d15176f 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -274,8 +274,8 @@ public: fp::copyUnitToByteAsLE(reinterpret_cast(&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 { diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index b91bedc..c660fc6 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -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) }; diff --git a/src/fp.cpp b/src/fp.cpp index c99a3fe..debebd9 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -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);