1
0
Fork 0
forked from lthn/blockchain

crypto: fe_cmp implemented

This commit is contained in:
sowle 2021-04-24 04:45:30 +03:00
parent 7fb643d894
commit 4ce59c023b
No known key found for this signature in database
GPG key ID: C07A24B2D89D49FC
2 changed files with 11 additions and 0 deletions

View file

@ -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 */
/*

View file

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