1
0
Fork 0
forked from lthn/blockchain

crypto sugar: point_t::is_zero fixed, operator!= added

This commit is contained in:
sowle 2021-12-27 07:10:21 +03:00
parent f2e58daa8c
commit 286385cc83
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC

View file

@ -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();