diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index b429d2d..1e526f5 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -590,7 +590,7 @@ struct MapTo { } 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); 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) { 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); return; } diff --git a/include/mcl/op.hpp b/include/mcl/op.hpp index 5e35700..db1dd7c 100644 --- a/include/mcl/op.hpp +++ b/include/mcl/op.hpp @@ -23,7 +23,7 @@ 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() diff --git a/readme.md b/readme.md index b6c782e..34ae2c6 100644 --- a/readme.md +++ b/readme.md @@ -312,7 +312,7 @@ If `MCL_USE_OLD_MAPTO_FOR_BLS12` is defined, then the old function is used, but # 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/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 diff --git a/test/mapto_wb19_test.cpp b/test/mapto_wb19_test.cpp index b7bfe63..d539382 100644 --- a/test/mapto_wb19_test.cpp +++ b/test/mapto_wb19_test.cpp @@ -957,6 +957,13 @@ void testHashToFp2v7(const T& mapto) mapto.map2curve_osswu2(P2, msg, msgSize, dst, dstSize); 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()); + } } }