diff --git a/src/crypto/crypto-sugar.h b/src/crypto/crypto-sugar.h index 600fe914..0e48e949 100644 --- a/src/crypto/crypto-sugar.h +++ b/src/crypto/crypto-sugar.h @@ -497,7 +497,7 @@ namespace crypto zero(); } - // as we're using additive notation, zero means identity group element here and after + // as we're using additive notation, zero means identity group element (EC point (0, 1)) here and after void zero() { ge_p3_0(&m_p3); @@ -506,7 +506,11 @@ namespace crypto bool is_zero() const { // (0, 1) ~ (0, z, z, 0) - return fe_isnonzero(m_p3.X) * fe_cmp(m_p3.Y, m_p3.Z) == 0; + if (fe_isnonzero(m_p3.X) != 0) + return false; + fe y_minus_z; + fe_sub(y_minus_z, m_p3.Y, m_p3.Z); + return fe_isnonzero(y_minus_z) == 0; } bool is_in_main_subgroup() const @@ -669,6 +673,11 @@ namespace crypto return true; }; + friend bool operator!=(const point_t& lhs, const point_t& rhs) + { + return !(lhs == rhs); + }; + friend std::ostream& operator<<(std::ostream& ss, const point_t &v) { crypto::public_key pk = v.to_public_key();