aboutsummaryrefslogtreecommitdiffstats
path: root/include/mcl/fp_tower.hpp
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2018-08-15 10:13:37 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2018-08-15 10:13:37 +0800
commit8e6fe75858a5aac363bb8f8c6898b11f411d2857 (patch)
treee1379d98ca58eb4ca2cec3dbee7dffbc42ff0c7f /include/mcl/fp_tower.hpp
parent8af25706d81756f9376e78fa8bf7949af6c7a346 (diff)
downloadtangerine-mcl-8e6fe75858a5aac363bb8f8c6898b11f411d2857.tar.gz
tangerine-mcl-8e6fe75858a5aac363bb8f8c6898b11f411d2857.tar.zst
tangerine-mcl-8e6fe75858a5aac363bb8f8c6898b11f411d2857.zip
direct call Fp2::sqr
Diffstat (limited to 'include/mcl/fp_tower.hpp')
-rw-r--r--include/mcl/fp_tower.hpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp
index 955fcfd..35dd94f 100644
--- a/include/mcl/fp_tower.hpp
+++ b/include/mcl/fp_tower.hpp
@@ -243,7 +243,7 @@ public:
static void mul(Fp2T& z, const Fp2T& x, const Fp2T& y) { Fp::op_.fp2_mul(z.a.v_, x.a.v_, y.a.v_); }
static void inv(Fp2T& y, const Fp2T& x) { Fp::op_.fp2_inv(y.a.v_, x.a.v_); }
static void neg(Fp2T& y, const Fp2T& x) { Fp::op_.fp2_neg(y.a.v_, x.a.v_); }
- static void sqr(Fp2T& y, const Fp2T& x) { Fp::op_.fp2_sqr(y.a.v_, x.a.v_); }
+ static void (*sqr)(Fp2T& y, const Fp2T& x);
static void mul_xi(Fp2T& y, const Fp2T& x) { Fp::op_.fp2_mul_xi(y.a.v_, x.a.v_); }
static void divBy2(Fp2T& y, const Fp2T& x)
{
@@ -397,11 +397,8 @@ public:
op.fp2_mul = fp2_mulW;
}
}
- if (op.fp2_sqrA_) {
- op.fp2_sqr = op.fp2_sqrA_;
- } else {
- op.fp2_sqr = fp2_sqrW;
- }
+ sqr = (void (*)(Fp2T& y, const Fp2T& x))op.fp2_sqrA_;
+ if (sqr == 0) sqr = (void (*)(Fp2T& y, const Fp2T& x))fp2_sqrC;
op.fp2_neg = fp2_negW;
op.fp2_inv = fp2_invW;
if (xi_a == 1) {
@@ -545,7 +542,7 @@ private:
x = a + bi, i^2 = -1
y = x^2 = (a + bi)^2 = (a + b)(a - b) + 2abi
*/
- static void fp2_sqrW(Unit *y, const Unit *x)
+ static void fp2_sqrC(Unit *y, const Unit *x)
{
const Fp *px = reinterpret_cast<const Fp*>(x);
Fp *py = reinterpret_cast<Fp*>(y);
@@ -626,6 +623,8 @@ private:
}
};
+template<class Fp_> void (*Fp2T<Fp_>::sqr)(Fp2T& y, const Fp2T& x);
+
template<class Fp>
struct Fp2DblT {
typedef FpDblT<Fp> FpDbl;