From 3e7cce7ccffc8184fbcc71e0682b28200257b692 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sat, 11 Jun 2016 19:24:47 +0900 Subject: [PATCH] add operator< for Ec --- include/mcl/ec.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/mcl/ec.hpp b/include/mcl/ec.hpp index 5bb0b00..ad1c749 100644 --- a/include/mcl/ec.hpp +++ b/include/mcl/ec.hpp @@ -693,6 +693,20 @@ public: sub(R, *this, rhs); // QQQ : optimized later return R.isZero(); } + bool operator<(const EcT& rhs) const + { + if (isZero()) { + return !rhs.isZero(); + } + if (rhs.isZero()) return false; + int cmp = Fp::compare(x, rhs.x); + if (cmp < 0) return true; + if (cmp > 0) return false; + return y < rhs.y; + } + bool operator>=(const EcT& rhs) const { return !operator<(rhs); } + bool operator>(const EcT& rhs) const { return rhs < *this; } + bool operator<=(const EcT& rhs) const { return !operator>(rhs); } bool operator!=(const EcT& rhs) const { return !operator==(rhs); } private: static inline void mulArray(EcT& z, const EcT& x, const fp::Unit *y, size_t yn, bool isNegative)