fe_isnonzero.c 322 B

12345678910111213141516171819
  1. #include "fe.h"
  2. #include <sodium/crypto_verify_32.h>
  3. /*
  4. return 1 if f == 0
  5. return 0 if f != 0
  6. Preconditions:
  7. |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
  8. */
  9. static const unsigned char zero[32];
  10. int fe_isnonzero(const fe f)
  11. {
  12. unsigned char s[32];
  13. fe_tobytes(s,f);
  14. return crypto_verify_32(s,zero);
  15. }