ed25519/fe_isnonzero.c

21 lines
314 B
C
Raw Normal View History

2013-01-10 21:14:17 +01:00
#include "fe.h"
2013-01-11 22:32:39 +01:00
#include "consttime_cmp.h"
2013-01-10 21:14:17 +01:00
/*
return 1 if f == 0
return 0 if f != 0
Preconditions:
|f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
*/
static const unsigned char zero[32];
int fe_isnonzero(const fe f)
{
unsigned char s[32];
fe_tobytes(s,f);
2013-01-11 22:32:39 +01:00
return consttime_cmp_32(s, zero);
2013-01-10 21:14:17 +01:00
}