From 34207640064313481e9aa801309921708024727d Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Fri, 5 Aug 2016 05:33:23 +0900 Subject: [PATCH] add getWeierstrass --- include/mcl/ec.hpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index d751187..42597f3 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -670,14 +670,18 @@ public: { compressedExpression_ = compressedExpression; } - static inline void getYfromX(Fp& y, const Fp& x, bool isYodd) + static inline void getWeierstrass(Fp& yy, const Fp& x) { Fp t; Fp::sqr(t, x); t += a_; t *= x; - t += b_; - Fp::squareRoot(y, t); + Fp::add(yy, t, b_); + } + static inline void getYfromX(Fp& y, const Fp& x, bool isYodd) + { + getWeierstrass(y, x); + if (!Fp::squareRoot(y, y)) throw cybozu::Exception("EcT:getYfromX") << x << isYodd; if (y.isOdd() ^ isYodd) { Fp::neg(y, y); }