hashAndMapToG2 support draft-07

update-fork
MITSUNARI Shigeo 5 years ago
parent 21dbb7ab8b
commit 7b4eb83d5b
  1. 4
      include/mcl/bn.hpp
  2. 2
      include/mcl/op.hpp
  3. 2
      readme.md
  4. 7
      test/mapto_wb19_test.cpp

@ -590,7 +590,7 @@ struct MapTo {
} }
bool calc(G2& P, const Fp2& t, bool fast = false) const bool calc(G2& P, const Fp2& t, bool fast = false) const
{ {
if (mapToMode_ == MCL_MAP_TO_MODE_WB19 || mapToMode_ == MCL_MAP_TO_MODE_HASH_TO_CURVE_06) { if (mapToMode_ == MCL_MAP_TO_MODE_WB19 || mapToMode_ >= MCL_MAP_TO_MODE_HASH_TO_CURVE_06) {
mapToG2_WB19_.opt_swu2_map(P, t); mapToG2_WB19_.opt_swu2_map(P, t);
return true; return true;
} }
@ -2103,7 +2103,7 @@ inline void hashAndMapToG1(G1& P, const void *buf, size_t bufSize)
inline void hashAndMapToG2(G2& P, const void *buf, size_t bufSize) inline void hashAndMapToG2(G2& P, const void *buf, size_t bufSize)
{ {
int mode = getMapToMode(); int mode = getMapToMode();
if (mode == MCL_MAP_TO_MODE_WB19 || mode == MCL_MAP_TO_MODE_HASH_TO_CURVE_06) { if (mode == MCL_MAP_TO_MODE_WB19 || mode >= MCL_MAP_TO_MODE_HASH_TO_CURVE_06) {
BN::param.mapTo.mapToG2_WB19_.msgToG2(P, buf, bufSize); BN::param.mapTo.mapToG2_WB19_.msgToG2(P, buf, bufSize);
return; return;
} }

@ -23,7 +23,7 @@
namespace mcl { namespace mcl {
static const int version = 0x108; /* 0xABC = A.BC */ static const int version = 0x109; /* 0xABC = A.BC */
/* /*
specifies available string format mode for X::setIoMode() specifies available string format mode for X::setIoMode()

@ -312,7 +312,7 @@ If `MCL_USE_OLD_MAPTO_FOR_BLS12` is defined, then the old function is used, but
# History # History
- 2020/May/13 v1.08 support draft-irtf-cfrg-hash-to-curve-07 - 2020/May/13 v1.09 support draft-irtf-cfrg-hash-to-curve-07
- 2020/Mar/26 v1.07 change DST for hash-to-curve-06 - 2020/Mar/26 v1.07 change DST for hash-to-curve-06
- 2020/Mar/15 v1.06 support hash-to-curve-06 - 2020/Mar/15 v1.06 support hash-to-curve-06
- 2020/Jan/31 v1.05 mclBn_ethMsgToFp2 has changed to append zero byte at the end of msg - 2020/Jan/31 v1.05 mclBn_ethMsgToFp2 has changed to append zero byte at the end of msg

@ -957,6 +957,13 @@ void testHashToFp2v7(const T& mapto)
mapto.map2curve_osswu2(P2, msg, msgSize, dst, dstSize); mapto.map2curve_osswu2(P2, msg, msgSize, dst, dstSize);
CYBOZU_TEST_EQUAL(P1, P2); CYBOZU_TEST_EQUAL(P1, P2);
} }
{
G2 P;
mcl::bn::hashAndMapToG2(P, "asdf", 4);
CYBOZU_BENCH_C("draft07 hashAndMapToG2", 1000, mcl::bn::hashAndMapToG2, P, "asdf", 4);
P.normalize();
printf("P=%s %s\n", P.x.getStr(10).c_str(), P.y.getStr(10).c_str());
}
} }
} }

Loading…
Cancel
Save