diff options
-rw-r--r-- | include/mcl/bgn.hpp | 6 | ||||
-rw-r--r-- | include/mcl/bn.hpp | 14 | ||||
-rw-r--r-- | include/mcl/fp_tower.hpp | 8 |
3 files changed, 14 insertions, 14 deletions
diff --git a/include/mcl/bgn.hpp b/include/mcl/bgn.hpp index 8239ddd..8cabbc5 100644 --- a/include/mcl/bgn.hpp +++ b/include/mcl/bgn.hpp @@ -110,13 +110,13 @@ struct BGNT { if (y == 1) return 0; if (y == x) return 1; GT inv; - BN::unitaryInv(inv, x); + GT::unitaryInv(inv, x); if (y == inv) return -1; GT t = x; for (int i = 2; i < 100; i++) { t *= x; if (y == t) return i; - BN::unitaryInv(inv, t); + GT::unitaryInv(inv, t); if (y == inv) return -i; } throw cybozu::Exception("BGN:dec:logGT:not found"); @@ -158,7 +158,7 @@ struct BGNT { GT::pow(t, c.g[1], x1); GT::pow(u, c.g[2], x2); t *= u; - BN::unitaryInv(t, t); + GT::unitaryInv(t, t); s *= t; return logGT(g, s); } diff --git a/include/mcl/bn.hpp b/include/mcl/bn.hpp index e6d388d..ad96eff 100644 --- a/include/mcl/bn.hpp +++ b/include/mcl/bn.hpp @@ -940,14 +940,6 @@ struct BNT { #endif } /* - y = 1 / x = conjugate of x if |x| = 1 - */ - static void unitaryInv(Fp12& y, const Fp12& x) - { - y.a = x.a; - Fp6::neg(y.b, x.b); - } - /* Faster Squaring in the Cyclotomic Subgroup of Sixth Degree Extensions Robert Granger, Michael Scott */ @@ -1207,7 +1199,7 @@ struct BNT { Fp12::pow(y, x, param.abs_z); #endif if (param.isNegative) { - unitaryInv(y, y); + Fp12::unitaryInv(y, y); } } /* @@ -1243,13 +1235,13 @@ struct BNT { fasterSqr(a3, a2); // x^(12z^2) pow_z(a3, a3); // x^(12z^3) a *= a3; - unitaryInv(b, b); + Fp12::unitaryInv(b, b); b *= a; a2 *= a; Frobenius2(a, a); a *= a2; a *= x; - unitaryInv(y, x); + Fp12::unitaryInv(y, x); y *= b; Frobenius(b, b); a *= b; diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index 086cfe8..5d3cae2 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -952,6 +952,14 @@ struct Fp12T : public fp::Operator<Fp12T<Fp> > { Fp6::mul(y.b, x.b, t0); Fp6::neg(y.b, y.b); } + /* + y = 1 / x = conjugate of x if |x| = 1 + */ + static void unitaryInv(Fp12T& y, const Fp12T& x) + { + if (&y != &x) y.a = x.a; + Fp6::neg(y.b, x.b); + } std::istream& readStream(std::istream& is, int ioMode) { a.readStream(is, ioMode); |