crypto_mGnP/ed25519/ref10/fe_isnegative.c
raw| 1 | // 20240926 djb: use cryptoint |
| 2 | |
| 3 | // linker define fe_isnegative |
| 4 | // linker use fe_tobytes |
| 5 | |
| 6 | #include "fe.h" |
| 7 | #include "crypto_uint8.h" |
| 8 | |
| 9 | /* |
| 10 | return 1 if f is in {1,3,5,...,q-2} |
| 11 | return 0 if f is in {0,2,4,...,q-1} |
| 12 | |
| 13 | Preconditions: |
| 14 | |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. |
| 15 | */ |
| 16 | |
| 17 | int fe_isnegative(const fe f) |
| 18 | { |
| 19 | unsigned char s[32]; |
| 20 | fe_tobytes(s,f); |
| 21 | return crypto_uint8_bottombit_01(s[0]); |
| 22 | } |