diff --git a/include/mcl/mapto_wb19.hpp b/include/mcl/mapto_wb19.hpp index a35d79c..17246d9 100644 --- a/include/mcl/mapto_wb19.hpp +++ b/include/mcl/mapto_wb19.hpp @@ -340,39 +340,23 @@ struct MapTo_WB19 { // refer (g1xnum, g1xden, g1ynum, g1yden) void iso11(G1& Q, E1& P) const { -#if 1 ec::normalizeJacobi(P); Fp xn, xd, yn, yd; xn = evalPoly2(P.x, g1xnum); xd = evalPoly2(P.x, g1xden); yn = evalPoly2(P.x, g1ynum); yd = evalPoly2(P.x, g1yden); - Fp::div(Q.x, xn, xd); - Fp::div(Q.y, yn, yd); - Q.y *= P.y; - Q.z = 1; -#else - Fp zpows[3]; - Fp::sqr(zpows[0], P.z); - Fp::sqr(zpows[1], zpows[0]); - Fp::mul(zpows[2], zpows[1], zpows[0]); - Fp mapvals[4]; - evalPoly(mapvals[0], P.x, zpows, g1xnum); - evalPoly(mapvals[1], P.x, zpows, g1xden); - evalPoly(mapvals[2], P.x, zpows, g1ynum); - evalPoly(mapvals[3], P.x, zpows, g1yden); - mapvals[1] *= zpows[0]; - mapvals[2] *= P.y; - mapvals[3] *= zpows[0]; - mapvals[3] *= P.z; - Fp::mul(Q.z, mapvals[1], mapvals[3]); - Fp::mul(Q.x, mapvals[0], mapvals[3]); + /* + [xn/xd:y * yn/yd:1] = [xn xd yd^2:y yn xd^3 yd^2:xd yd] + =[xn yd z:y yn xd z^2:z] where z = xd yd + */ + Fp::mul(Q.z, xd, yd); + Fp::mul(Q.x, xn, yd); Q.x *= Q.z; - Fp t; - Fp::sqr(t, Q.z); - Fp::mul(Q.y, mapvals[2], mapvals[1]); - Q.y *= t; -#endif + Fp::mul(Q.y, P.y, yn); + Q.y *= xd; + Fp::sqr(xd, Q.z); + Q.y *= xd; } /* xi = -2-i diff --git a/test/mapto_wb19_test.cpp b/test/mapto_wb19_test.cpp index 59754a1..5b3e547 100644 --- a/test/mapto_wb19_test.cpp +++ b/test/mapto_wb19_test.cpp @@ -1159,6 +1159,7 @@ void testMsgToG1(const T& mapto) Q.y.setStr(tbl[i].y, 16); Q.z = 1; CYBOZU_TEST_EQUAL(P, Q); +CYBOZU_BENCH_C("msgToG1", 1000, mapto.msgToG1, P, msg, msgSize, dst, dstSize); } }