fe25519.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #ifndef FE25519_H
  2. #define FE25519_H
  3. #define fe25519 crypto_scalarmult_curve25519_amd64_64_fe25519
  4. #define fe25519_freeze crypto_scalarmult_curve25519_amd64_64_fe25519_freeze
  5. #define fe25519_unpack crypto_scalarmult_curve25519_amd64_64_fe25519_unpack
  6. #define fe25519_pack crypto_scalarmult_curve25519_amd64_64_fe25519_pack
  7. #define fe25519_iszero_vartime crypto_scalarmult_curve25519_amd64_64_fe25519_iszero_vartime
  8. #define fe25519_iseq_vartime crypto_scalarmult_curve25519_amd64_64_fe25519_iseq_vartime
  9. #define fe25519_cmov crypto_scalarmult_curve25519_amd64_64_fe25519_cmov
  10. #define fe25519_setint crypto_scalarmult_curve25519_amd64_64_fe25519_setint
  11. #define fe25519_neg crypto_scalarmult_curve25519_amd64_64_fe25519_neg
  12. #define fe25519_getparity crypto_scalarmult_curve25519_amd64_64_fe25519_getparity
  13. #define fe25519_add crypto_scalarmult_curve25519_amd64_64_fe25519_add
  14. #define fe25519_sub crypto_scalarmult_curve25519_amd64_64_fe25519_sub
  15. #define fe25519_mul crypto_scalarmult_curve25519_amd64_64_fe25519_mul
  16. #define fe25519_mul121666 crypto_scalarmult_curve25519_amd64_64_fe25519_mul121666
  17. #define fe25519_square crypto_scalarmult_curve25519_amd64_64_fe25519_square
  18. #define fe25519_invert crypto_scalarmult_curve25519_amd64_64_fe25519_invert
  19. #define fe25519_pow2523 crypto_scalarmult_curve25519_amd64_64_fe25519_pow2523
  20. typedef struct
  21. {
  22. unsigned long long v[4];
  23. }
  24. fe25519;
  25. void fe25519_freeze(fe25519 *r);
  26. void fe25519_unpack(fe25519 *r, const unsigned char x[32]);
  27. void fe25519_pack(unsigned char r[32], const fe25519 *x);
  28. void fe25519_cmov(fe25519 *r, const fe25519 *x, unsigned char b);
  29. void fe25519_cswap(fe25519 *r, fe25519 *x, unsigned char b);
  30. void fe25519_setint(fe25519 *r, unsigned int v);
  31. void fe25519_neg(fe25519 *r, const fe25519 *x);
  32. unsigned char fe25519_getparity(const fe25519 *x);
  33. int fe25519_iszero_vartime(const fe25519 *x);
  34. int fe25519_iseq_vartime(const fe25519 *x, const fe25519 *y);
  35. void fe25519_add(fe25519 *r, const fe25519 *x, const fe25519 *y);
  36. void fe25519_sub(fe25519 *r, const fe25519 *x, const fe25519 *y);
  37. void fe25519_mul(fe25519 *r, const fe25519 *x, const fe25519 *y);
  38. void fe25519_mul121666(fe25519 *r, const fe25519 *x);
  39. void fe25519_square(fe25519 *r, const fe25519 *x);
  40. void fe25519_pow(fe25519 *r, const fe25519 *x, const unsigned char *e);
  41. void fe25519_invert(fe25519 *r, const fe25519 *x);
  42. void fe25519_pow2523(fe25519 *r, const fe25519 *x);
  43. #endif