diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index 130372f..02f58f2 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -859,7 +859,7 @@ struct GLV2 { template void mul(T& Q, const T& P, mpz_class x, bool constTime = false) const { -#if 0 +#if 1 const int w = 5; const size_t tblSize = 1 << (w - 2); const size_t splitN = 4; @@ -877,14 +877,14 @@ struct GLV2 { x += r; } split(u, x); - for (size_t i = 0; i < splitN; i++) { - gmp::getNAFwidth(&b, naf[i], u[i], w); - assert(b); (void)b; - } tbl[0][0] = P; Frobenius(tbl[1][0], tbl[0][0]); Frobenius(tbl[2][0], tbl[1][0]); Frobenius(tbl[3][0], tbl[2][0]); + for (size_t i = 0; i < splitN; i++) { + gmp::getNAFwidth(&b, naf[i], u[i], w); + assert(b); (void)b; + } { T P2; T::dbl(P2, P); diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index 8d79a7e..dbbfacd 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -1336,6 +1336,12 @@ struct GroupMtoA : public T { { T::mul(castT(z), castT(x), castT(y)); } + static void sub(GroupMtoA& z, const GroupMtoA& x, const GroupMtoA& y) + { + T r; + T::unitaryInv(r, castT(y)); + T::mul(castT(z), castT(x), r); + } static void dbl(GroupMtoA& y, const GroupMtoA& x) { T::sqr(castT(y), castT(x)); @@ -1363,6 +1369,10 @@ struct GroupMtoA : public T { { add(*this, *this, rhs); } + void operator-=(const GroupMtoA& rhs) + { + sub(*this, *this, rhs); + } void normalize() {} private: bool isOne() const;