forked from lthn/blockchain
crypto: fe_isnonzero made public, point_t::is_zero() added
This commit is contained in:
parent
8063604b37
commit
5843f6964c
3 changed files with 8 additions and 1 deletions
|
|
@ -332,7 +332,7 @@ static int fe_isnegative(const fe f) {
|
|||
|
||||
/* From fe_isnonzero.c, modified */
|
||||
|
||||
static int fe_isnonzero(const fe f) {
|
||||
int fe_isnonzero(const fe f) {
|
||||
unsigned char s[32];
|
||||
fe_tobytes(s, f);
|
||||
return (((int) (s[0] | s[1] | s[2] | s[3] | s[4] | s[5] | s[6] | s[7] | s[8] |
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ int sc_isnonzero(const unsigned char *); /* Doesn't normalize */
|
|||
void sc_invert(unsigned char*, const unsigned char*);
|
||||
|
||||
void fe_sq(fe h, const fe f);
|
||||
int fe_isnonzero(const fe f);
|
||||
void fe_mul(fe, const fe, const fe);
|
||||
void fe_frombytes(fe h, const unsigned char *s);
|
||||
void fe_invert(fe out, const fe z);
|
||||
|
|
|
|||
|
|
@ -418,6 +418,12 @@ struct point_t
|
|||
ge_p3_0(&m_p3);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
bool from_public_key(const crypto::public_key& pk)
|
||||
{
|
||||
return ge_frombytes_vartime(&m_p3, reinterpret_cast<const unsigned char*>(&pk)) == 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue