aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-05-01 15:09:52 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-05-01 15:09:52 +0800
commit4ce42c26b456fbe521854817c120969a022fb194 (patch)
tree1f7de118c06f4e9cad48dc7ccdf6bba360374925
parent050122518696d406511d282b45d72fdcb3ab1c8e (diff)
downloaddexon-mcl-4ce42c26b456fbe521854817c120969a022fb194.tar.gz
dexon-mcl-4ce42c26b456fbe521854817c120969a022fb194.tar.zst
dexon-mcl-4ce42c26b456fbe521854817c120969a022fb194.zip
change value of IoPrefix
-rw-r--r--include/mcl/fp.hpp4
-rw-r--r--include/mcl/op.hpp12
-rw-r--r--src/fp.cpp4
3 files changed, 10 insertions, 10 deletions
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<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
{
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);