From 258b63c48768471452293e021b1c3dafef5e6a31 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 30 Jun 2020 14:22:16 +0900 Subject: [PATCH] change mode of hashAndMapToG1 --- include/mcl/bn.hpp | 5 +++++ test/mapto_wb19_test.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index 657c8fa..61886d0 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -2056,6 +2056,11 @@ inline void mapToG2(G2& P, const Fp2& x, bool fast = false) #endif inline void hashAndMapToG1(G1& P, const void *buf, size_t bufSize) { + int mode = getMapToMode(); + if (mode == MCL_MAP_TO_MODE_HASH_TO_CURVE_07) { + BN::param.mapTo.mapTo_WB19_.msgToG1(P, buf, bufSize); + return; + } Fp t; t.setHashOf(buf, bufSize); bool b; diff --git a/test/mapto_wb19_test.cpp b/test/mapto_wb19_test.cpp index 5b3e547..80a9663 100644 --- a/test/mapto_wb19_test.cpp +++ b/test/mapto_wb19_test.cpp @@ -1160,6 +1160,11 @@ void testMsgToG1(const T& mapto) Q.z = 1; CYBOZU_TEST_EQUAL(P, Q); CYBOZU_BENCH_C("msgToG1", 1000, mapto.msgToG1, P, msg, msgSize, dst, dstSize); + if (i == 0) { // correct dst + P.clear(); + bn::hashAndMapToG1(P, msg, msgSize); + CYBOZU_TEST_EQUAL(P, Q); + } } }