diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-05-30 21:09:47 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-05-30 21:09:47 +0800 |
commit | 2ca430617c391b2ec6fb3b8e997efdc19f56b864 (patch) | |
tree | ac04de168ef519ccbbf4b9d6c48b7eef0834a1b1 | |
parent | 3c105608366c0132b399cbd005e1ce371ae0be21 (diff) | |
download | dexon-mcl-2ca430617c391b2ec6fb3b8e997efdc19f56b864.tar.gz dexon-mcl-2ca430617c391b2ec6fb3b8e997efdc19f56b864.tar.zst dexon-mcl-2ca430617c391b2ec6fb3b8e997efdc19f56b864.zip |
rename setMsg to SetHashOf
-rw-r--r-- | include/mcl/bn256.h | 2 | ||||
-rw-r--r-- | include/mcl/fp.hpp | 8 | ||||
-rw-r--r-- | sample/bls_sig.cpp | 2 | ||||
-rw-r--r-- | src/bn256.cpp | 8 | ||||
-rw-r--r-- | src/fp.cpp | 4 | ||||
-rw-r--r-- | test/bn256_test.cpp | 6 | ||||
-rw-r--r-- | test/bn_test.cpp | 2 | ||||
-rw-r--r-- | test/fp_test.cpp | 6 |
8 files changed, 19 insertions, 19 deletions
diff --git a/include/mcl/bn256.h b/include/mcl/bn256.h index c80f957..671dbc5 100644 --- a/include/mcl/bn256.h +++ b/include/mcl/bn256.h @@ -83,7 +83,7 @@ BN256_DLL_API int BN256_Fr_isOne(const BN256_Fr *x); BN256_DLL_API void BN256_Fr_setRand(BN256_Fr *x); // hash(s) and set x -BN256_DLL_API void BN256_Fr_setMsg(BN256_Fr *x, const char *s); +BN256_DLL_API void BN256_Fr_setHashOf(BN256_Fr *x, const char *s); // return 0 if success BN256_DLL_API int BN256_Fr_getStr(char *buf, int maxBufSize, const BN256_Fr *x); diff --git a/include/mcl/fp.hpp b/include/mcl/fp.hpp index de63e3e..e4d95ff 100644 --- a/include/mcl/fp.hpp +++ b/include/mcl/fp.hpp @@ -57,7 +57,7 @@ std::string littleEndianToHexStr(const char *buf, size_t bufSize); bool isEnableJIT(); // 1st call is not threadsafe // hash msg -std::string hash(size_t bitSize, const char *msg, size_t msgSize); +std::string hash(size_t bitSize, const void *msg, size_t msgSize); } // mcl::fp @@ -253,14 +253,14 @@ public: /* hash msg and mask with (1 << (bitLen - 1)) - 1 */ - void setMsg(const char *msg, size_t msgSize) + void setHashOf(const void *msg, size_t msgSize) { std::string digest = mcl::fp::hash(op_.bitSize, msg, msgSize); setArrayMask(digest.c_str(), digest.size()); } - void setMsg(const std::string& msg) + void setHashOf(const std::string& msg) { - setMsg(msg.data(), msg.size()); + setHashOf(msg.data(), msg.size()); } #ifdef _MSC_VER #pragma warning(push) diff --git a/sample/bls_sig.cpp b/sample/bls_sig.cpp index f054d9c..8df6b77 100644 --- a/sample/bls_sig.cpp +++ b/sample/bls_sig.cpp @@ -22,7 +22,7 @@ using namespace mcl::bn256; void Hash(G1& P, const std::string& m) { Fp t; - t.setMsg(m); + t.setHashOf(m); BN::mapToG1(P, t); } diff --git a/src/bn256.cpp b/src/bn256.cpp index 976b0f3..8629834 100644 --- a/src/bn256.cpp +++ b/src/bn256.cpp @@ -121,9 +121,9 @@ void BN256_Fr_setRand(BN256_Fr *x) } // hash(str) and set x -void BN256_Fr_setMsg(BN256_Fr *x, const char *str) +void BN256_Fr_setHashOf(BN256_Fr *x, const char *str) { - cast(x)->setMsg(str); + cast(x)->setHashOf(str); } // return 0 if success @@ -208,7 +208,7 @@ int BN256_G1_hashAndMapTo(BN256_G1 *x, const char *str) try { Fp y; - y.setMsg(str); + y.setHashOf(str); BN::mapToG1(*cast(x), y); return 0; } catch (std::exception& e) { @@ -294,7 +294,7 @@ int BN256_G2_hashAndMapTo(BN256_G2 *x, const char *str) try { Fp y; - y.setMsg(str); + y.setHashOf(str); BN::mapToG2(*cast(x), Fp2(y, 0)); return 0; } catch (std::exception& e) { @@ -187,7 +187,7 @@ bool isEnableJIT() #endif } -std::string hash(size_t bitSize, const char *msg, size_t msgSize) +std::string hash(size_t bitSize, const void *msg, size_t msgSize) { cybozu::crypto::Hash::Name name; if (bitSize <= 160) { @@ -201,7 +201,7 @@ std::string hash(size_t bitSize, const char *msg, size_t msgSize) } else { name = cybozu::crypto::Hash::N_SHA512; } - return cybozu::crypto::Hash::digest(name, msg, msgSize); + return cybozu::crypto::Hash::digest(name, (const char *)msg, msgSize); } static inline void set_mpz_t(mpz_t& z, const Unit* p, int n) diff --git a/test/bn256_test.cpp b/test/bn256_test.cpp index cd1afe9..cacdd3c 100644 --- a/test/bn256_test.cpp +++ b/test/bn256_test.cpp @@ -55,10 +55,10 @@ CYBOZU_TEST_AUTO(Fr) BN256_Fr_copy(&y, &x); CYBOZU_TEST_ASSERT(BN256_Fr_isSame(&x, &y)); - BN256_Fr_setMsg(&x, ""); - BN256_Fr_setMsg(&y, "abc"); + BN256_Fr_setHashOf(&x, ""); + BN256_Fr_setHashOf(&y, "abc"); CYBOZU_TEST_ASSERT(!BN256_Fr_isSame(&x, &y)); - BN256_Fr_setMsg(&x, "abc"); + BN256_Fr_setHashOf(&x, "abc"); CYBOZU_TEST_ASSERT(BN256_Fr_isSame(&x, &y)); char buf[1024]; diff --git a/test/bn_test.cpp b/test/bn_test.cpp index 045ce06..d3e6224 100644 --- a/test/bn_test.cpp +++ b/test/bn_test.cpp @@ -130,7 +130,7 @@ void testMapToG2() CYBOZU_TEST_EXCEPTION(BN::mapToG2(g, 0), cybozu::Exception); } Fp x; - x.setMsg("abc"); + x.setHashOf("abc"); BN::mapToG2(g, Fp2(x, 0)); CYBOZU_TEST_ASSERT(g.isValid()); } diff --git a/test/fp_test.cpp b/test/fp_test.cpp index 5c6a05c..efda750 100644 --- a/test/fp_test.cpp +++ b/test/fp_test.cpp @@ -705,7 +705,7 @@ void getStrTest() } } -void setMsgTest() +void setHashOfTest() { const std::string msgTbl[] = { "", "abc", "111111111111111111111111111111111111", @@ -727,7 +727,7 @@ void setMsgTest() std::string digest = cybozu::crypto::Hash::digest(name, msgTbl[i]); Fp x, y; x.setArrayMask(digest.c_str(), digest.size()); - y.setMsg(msgTbl[i]); + y.setHashOf(msgTbl[i]); CYBOZU_TEST_EQUAL(x, y); } } @@ -859,7 +859,7 @@ void sub(mcl::fp::Mode mode) getInt64Test(); divBy2Test(); getStrTest(); - setMsgTest(); + setHashOfTest(); } anotherFpTest(mode); setArrayTest2(mode); |