From 49ebc4119e7531a6e9ae80d7be2cd4334c42c9c3 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sun, 28 May 2017 09:00:50 +0900 Subject: [PATCH] rename IoEcComp to IoFixedSizeByteSeq --- include/mcl/ec.hpp | 10 +++++----- include/mcl/fp.hpp | 2 +- include/mcl/op.hpp | 12 ++++++------ src/fp.cpp | 2 +- test/bn_test.cpp | 2 +- test/ec_test.cpp | 16 ++++++++-------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index 2a39f57..e2424c1 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -645,7 +645,7 @@ public: return z.isZero(); #endif } - static inline bool isIoEcCompSupported() + static inline bool isFixedSizeByteSeq() { return !b_.isZero() && (Fp::BaseFp::getBitSize() & 7) != 0; } @@ -667,8 +667,8 @@ public: } EcT P(*this); P.normalize(); - if (ioMode & IoEcComp) { - if (!isIoEcCompSupported()) throw cybozu::Exception("EcT:getStr:not supported ioMode") << ioMode; + if (ioMode & IoFixedSizeByteSeq) { + if (!isFixedSizeByteSeq()) throw cybozu::Exception("EcT:getStr:not supported ioMode") << ioMode; const size_t n = Fp::getByteSize(); if (isZero()) { str.clear(); @@ -717,8 +717,8 @@ public: #else z = 1; #endif - if (ioMode & IoEcComp) { - if (!isIoEcCompSupported()) throw cybozu::Exception("EcT:readStream:not supported ioMode") << ioMode; + if (ioMode & IoFixedSizeByteSeq) { + if (!isFixedSizeByteSeq()) throw cybozu::Exception("EcT:readStream:not supported ioMode") << ioMode; std::string str; const size_t n = Fp::getByteSize(); str.resize(n); diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index 8287fd9..501956a 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -273,7 +273,7 @@ public: getBlock(b); p = b.p; } - if (ioMode & (IoArray | IoArrayRaw | IoEcComp)) { + if (ioMode & (IoArray | IoArrayRaw | IoFixedSizeByteSeq)) { str.resize(n); fp::copyUnitToByteAsLE(reinterpret_cast(&str[0]), p, str.size()); return; diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index 5e7a1fa..c6411a8 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -26,13 +26,14 @@ namespace mcl { byte string(not zero terminated, fixed size) IoArray | IoArrayRaw + IoArray = IoFixedSizeByteSeq // for Ec affine(0) | IoEcCompY | IoComp default : affine affine and IoEcCompY are available with ioMode for Fp - IoEcComp ignores ioMode for Fp + IoFixedSizeByteSeq ignores ioMode for Fp IoAuto dec or hex according to ios_base::fmtflags @@ -64,7 +65,7 @@ namespace mcl { "2 " ; compressed for even y "3 " ; compressed for odd y - IoComp(fixed size = Fp::getByteSize()) + IoFixedSizeByteSeq(fixed size = Fp::getByteSize()) use MSB of array of x for 1-bit y for prime p where (p % 8 != 0) [0] ; infinity ; for even y @@ -82,9 +83,8 @@ enum IoMode { IoHexPrefix = IoHex | IoPrefix, IoEcAffine = 0, // affine 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) + IoFixedSizeByteSeq = 512, // use MBS for 1-bit y + IoEcProj = 1024 // projective or jacobi coordinate }; namespace fp { @@ -306,7 +306,7 @@ void arrayToStr(std::string& str, const Unit *x, size_t n, int ioMode); inline const char* getIoSeparator(int ioMode) { - return (ioMode & (IoArray | IoArrayRaw | IoEcComp)) ? "" : " "; + return (ioMode & (IoArray | IoArrayRaw | IoFixedSizeByteSeq)) ? "" : " "; } int detectIoMode(int ioMode, const std::ios_base& ios); diff --git a/src/fp.cpp b/src/fp.cpp index 81f6bc5..a9e1a7a 100644 --- a/src/fp.cpp +++ b/src/fp.cpp @@ -539,7 +539,7 @@ int detectIoMode(int ioMode, const std::ios_base& ios) void streamToArray(bool *pIsMinus, Unit *x, size_t byteSize, std::istream& is, int ioMode) { std::string str; - if (ioMode & (IoArray | IoArrayRaw | IoEcComp)) { + if (ioMode & (IoArray | IoArrayRaw | IoFixedSizeByteSeq)) { str.resize(byteSize); is.read(&str[0], byteSize); *pIsMinus = false; diff --git a/test/bn_test.cpp b/test/bn_test.cpp index 6e9e2c6..045ce06 100644 --- a/test/bn_test.cpp +++ b/test/bn_test.cpp @@ -277,7 +277,7 @@ void testTrivial(const G1& P, const G2& Q) void testIoAll(const G1& P, const G2& Q) { int FpTbl[] = { 0, 2, 2|mcl::IoPrefix, 10, 16, 16|mcl::IoPrefix, mcl::IoArray, mcl::IoArrayRaw }; - int EcTbl[] = { mcl::IoEcAffine, mcl::IoEcProj, mcl::IoEcCompY, mcl::IoEcComp }; + int EcTbl[] = { mcl::IoEcAffine, mcl::IoEcProj, mcl::IoEcCompY, mcl::IoFixedSizeByteSeq }; for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(FpTbl); i++) { for (size_t j = 0; j < CYBOZU_NUM_OF_ARRAY(EcTbl); j++) { G1 P2 = P, P3; diff --git a/test/ec_test.cpp b/test/ec_test.cpp index d29ed9e..c8c079c 100644 --- a/test/ec_test.cpp +++ b/test/ec_test.cpp @@ -280,28 +280,28 @@ struct Test { ss >> Q; CYBOZU_TEST_EQUAL(P, Q); } - // IoEcComp - if (!Ec::isIoEcCompSupported()) return; + // IoFixedSizeByteSeq + if (!Ec::isFixedSizeByteSeq()) return; P.set(x, y); { - std::string s = P.getStr(mcl::IoEcComp); + std::string s = P.getStr(mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(s.size(), Fp::getByteSize()); - Q.setStr(s, mcl::IoEcComp); + Q.setStr(s, mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(P, Q); } { P = -P; - std::string s = P.getStr(mcl::IoEcComp); + std::string s = P.getStr(mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(s.size(), Fp::getByteSize()); - Q.setStr(s, mcl::IoEcComp); + Q.setStr(s, mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(P, Q); } P.clear(); { - std::string s = P.getStr(mcl::IoEcComp); + std::string s = P.getStr(mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(s.size(), Fp::getByteSize()); CYBOZU_TEST_ASSERT(mcl::fp::isZeroArray(s.c_str(), s.size())); - Q.setStr(s, mcl::IoEcComp); + Q.setStr(s, mcl::IoFixedSizeByteSeq); CYBOZU_TEST_EQUAL(P, Q); } }