diff --git a/include/mcl/mapto_wb19.hpp b/include/mcl/mapto_wb19.hpp index 07f5dfd..f6ceb81 100644 --- a/include/mcl/mapto_wb19.hpp +++ b/include/mcl/mapto_wb19.hpp @@ -72,7 +72,6 @@ template int PointT::specialA_; template struct MapToG2_WB19 { typedef local::PointT Point; - Fp half; mpz_class sqrtConst; // (p^2 - 9) / 16 Fp2 Ep_a; Fp2 Ep_b; @@ -98,8 +97,6 @@ struct MapToG2_WB19 { Point::b_.a = 4; Point::b_.b = 4; Point::specialA_ = ec::Zero; - half = -1; - half /= 2; sqrtConst = Fp::getOp().mp; sqrtConst *= sqrtConst; sqrtConst -= 9; @@ -239,9 +236,10 @@ struct MapToG2_WB19 { } bool isNegSign(const Fp2& x) const { - if (x.b > half) return true; + // x.isNegative() <=> x > (p-1)/2 <=> x >= (p+1)/2 + if (x.b.isNegative()) return true; if (!x.b.isZero()) return false; - if (x.a > half) return true; + if (x.a.isNegative()) return true; if (!x.b.isZero()) return false; return false; } diff --git a/test/mapto_wb19_test.cpp b/test/mapto_wb19_test.cpp index 5e12290..3321233 100644 --- a/test/mapto_wb19_test.cpp +++ b/test/mapto_wb19_test.cpp @@ -453,7 +453,8 @@ void py_eccTest(const T& mapto) template void testSign(const T& mapto) { - const Fp& H = mapto.half; + Fp H = -1; + H /= 2; const size_t N = 4; const Fp tbl[N] = { 0, 1, H, H + 1 }; const int expect[N][N] = {