fe25519.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef FE25519_H
  2. #define FE25519_H
  3. #include <stddef.h>
  4. #include "compat.h"
  5. #define fe25519 CRYPTO_NAMESPACE(batch_fe25519)
  6. #define fe25519_freeze CRYPTO_NAMESPACE(batch_fe25519_freeze)
  7. #define fe25519_unpack CRYPTO_NAMESPACE(batch_fe25519_unpack)
  8. #define fe25519_pack CRYPTO_NAMESPACE(batch_fe25519_pack)
  9. #define fe25519_iszero_vartime CRYPTO_NAMESPACE(batch_fe25519_iszero_vartime)
  10. #define fe25519_iseq_vartime CRYPTO_NAMESPACE(batch_fe25519_iseq_vartime)
  11. #define fe25519_cmov CRYPTO_NAMESPACE(batch_fe25519_cmov)
  12. #define fe25519_setint CRYPTO_NAMESPACE(batch_fe25519_setint)
  13. #define fe25519_neg CRYPTO_NAMESPACE(batch_fe25519_neg)
  14. #define fe25519_getparity CRYPTO_NAMESPACE(batch_fe25519_getparity)
  15. #define fe25519_add CRYPTO_NAMESPACE(batch_fe25519_add)
  16. #define fe25519_sub CRYPTO_NAMESPACE(batch_fe25519_sub)
  17. #define fe25519_mul CRYPTO_NAMESPACE(batch_fe25519_mul)
  18. #define fe25519_square CRYPTO_NAMESPACE(batch_fe25519_square)
  19. #define fe25519_nsquare CRYPTO_NAMESPACE(batch_fe25519_nsquare)
  20. #define fe25519_invert CRYPTO_NAMESPACE(batch_fe25519_invert)
  21. #define fe25519_batchinvert CRYPTO_NAMESPACE(batch_fe25519_batchinvert)
  22. #define fe25519_pow2523 CRYPTO_NAMESPACE(batch_fe25519_pow2523)
  23. typedef struct
  24. {
  25. unsigned long long v[5];
  26. }
  27. fe25519;
  28. void fe25519_freeze(fe25519 *r) SYSVABI;
  29. void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
  30. void fe25519_pack(unsigned char r[32], const fe25519 *x);
  31. void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b);
  32. void fe25519_cswap(fe25519 *r, fe25519 *x, unsigned char b);
  33. void fe25519_setint(fe25519 *r, unsigned int v);
  34. void fe25519_neg(fe25519 *r, const fe25519 *x);
  35. unsigned char fe25519_getparity(const fe25519 *x);
  36. int fe25519_iszero_vartime(const fe25519 *x);
  37. int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y);
  38. void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y);
  39. void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y);
  40. void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y) SYSVABI;
  41. void fe25519_square(fe25519 *r, const fe25519 *x) SYSVABI;
  42. void fe25519_nsquare(fe25519 *r, unsigned long long n) SYSVABI;
  43. void fe25519_invert(fe25519 *r, const fe25519 *x);
  44. void fe25519_batchinvert(fe25519 *out, const fe25519 *in, fe25519 *tmp, size_t num, size_t offset);
  45. void fe25519_pow2523(fe25519 *r, const fe25519 *x);
  46. #endif