forked from lthn/blockchain
crypto: fe_cmp implemented
This commit is contained in:
parent
7fb643d894
commit
4ce59c023b
2 changed files with 11 additions and 0 deletions
|
|
@ -342,6 +342,16 @@ int fe_isnonzero(const fe f) {
|
|||
s[27] | s[28] | s[29] | s[30] | s[31]) - 1) >> 8) + 1;
|
||||
}
|
||||
|
||||
int fe_cmp(const fe a, const fe b)
|
||||
{
|
||||
for (size_t i = 9; i != SIZE_MAX; --i)
|
||||
{
|
||||
if ((const uint32_t)a[i] < (const uint32_t)b[i]) return -1;
|
||||
if ((const uint32_t)a[i] > (const uint32_t)b[i]) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* From fe_mul.c */
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ void sc_invert(unsigned char*, const unsigned char*);
|
|||
|
||||
void fe_sq(fe h, const fe f);
|
||||
int fe_isnonzero(const fe f);
|
||||
int fe_cmp(const fe a, const fe b);
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue