From 271a2e4146a1bdb3c642fafe1c360f06a3b8a6ae Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sun, 26 Aug 2018 11:31:31 +0900 Subject: [PATCH] don't clear order_ if setOrder(0) --- include/mcl/ec.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index 276aea7..92d4f67 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -188,8 +188,13 @@ public: */ static void setOrder(const mpz_class& order) { - verifyOrder_ = order != 0; - order_ = order; + if (order) { + verifyOrder_ = true; + order_ = order; + } else { + verifyOrder_ = false; + // don't clear order_ because it is used for isValidOrder() + } } static void setMulArrayGLV(void f(EcT& z, const EcT& x, const fp::Unit *y, size_t yn, bool isNegative, bool constTime)) { @@ -207,6 +212,7 @@ public: // verify the order bool isValidOrder() const { + assert(order_); EcT Q; EcT::mulGeneric(Q, *this, order_); return Q.isZero();