From a5dbd60af6ce1d1c62b1ad034ba89ffd4e264b80 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Tue, 15 Mar 2016 17:45:33 +0900 Subject: Fp::sqr without FpDbl --- include/mcl/fp_tower.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/mcl/fp_tower.hpp b/include/mcl/fp_tower.hpp index 828e9a1..1139c8b 100644 --- a/include/mcl/fp_tower.hpp +++ b/include/mcl/fp_tower.hpp @@ -274,6 +274,15 @@ private: Fp::mul(t, a, b); Fp::sub(py[0], aa, bb); // a^2 - b^2 Fp::add(py[1], t, t); // 2ab +#else +#if 1 // faster than using FpDbl + Fp t1, t2, t3; + Fp::add(t1, b, b); // 2b + t1 *= a; // 2ab + Fp::add(t2, a, b); // a + b + Fp::sub(t3, a, b); // a - b + Fp::mul(py[0], t2, t3); // (a + b)(a - b) + py[1] = t1; #else Fp t1, t2; FpDbl d1, d2; @@ -284,6 +293,7 @@ private: FpDbl::mulPre(d1, t1, t2); // (a + b)(a - b) FpDbl::mod(py[0], d1); FpDbl::mod(py[1], d2); +#endif #endif } /* -- cgit