diff --git a/src/crypto/crypto-ops.c b/src/crypto/crypto-ops.c index 1623c0d5..2ab08dc2 100644 --- a/src/crypto/crypto-ops.c +++ b/src/crypto/crypto-ops.c @@ -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 */ /* diff --git a/src/crypto/crypto-ops.h b/src/crypto/crypto-ops.h index b1dc2f88..6fb6917c 100644 --- a/src/crypto/crypto-ops.h +++ b/src/crypto/crypto-ops.h @@ -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);