forked from lthn/blockchain
crypto sugar: point_t::is_zero fixed, operator!= added
This commit is contained in:
parent
f2e58daa8c
commit
286385cc83
1 changed files with 11 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue