sc25519.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef SC25519_H
  2. #define SC25519_H
  3. #define sc25519 crypto_sign_ed25519_amd64_64_sc25519
  4. #define shortsc25519 crypto_sign_ed25519_amd64_64_shortsc25519
  5. #define sc25519_from32bytes crypto_sign_ed25519_amd64_64_sc25519_from32bytes
  6. #define shortsc25519_from16bytes crypto_sign_ed25519_amd64_64_shortsc25519_from16bytes
  7. #define sc25519_from64bytes crypto_sign_ed25519_amd64_64_sc25519_from64bytes
  8. #define sc25519_from_shortsc crypto_sign_ed25519_amd64_64_sc25519_from_shortsc
  9. #define sc25519_to32bytes crypto_sign_ed25519_amd64_64_sc25519_to32bytes
  10. #define sc25519_iszero_vartime crypto_sign_ed25519_amd64_64_sc25519_iszero_vartime
  11. #define sc25519_isshort_vartime crypto_sign_ed25519_amd64_64_sc25519_isshort_vartime
  12. #define sc25519_lt crypto_sign_ed25519_amd64_64_sc25519_lt
  13. #define sc25519_add crypto_sign_ed25519_amd64_64_sc25519_add
  14. #define sc25519_sub_nored crypto_sign_ed25519_amd64_64_sc25519_sub_nored
  15. #define sc25519_mul crypto_sign_ed25519_amd64_64_sc25519_mul
  16. #define sc25519_mul_shortsc crypto_sign_ed25519_amd64_64_sc25519_mul_shortsc
  17. #define sc25519_window4 crypto_sign_ed25519_amd64_64_sc25519_window4
  18. #define sc25519_slide crypto_sign_ed25519_amd64_64_sc25519_slide
  19. #define sc25519_2interleave2 crypto_sign_ed25519_amd64_64_sc25519_2interleave2
  20. #define sc25519_barrett crypto_sign_ed25519_amd64_64_sc25519_barrett
  21. typedef struct
  22. {
  23. unsigned long long v[4];
  24. }
  25. sc25519;
  26. typedef struct
  27. {
  28. unsigned long long v[2];
  29. }
  30. shortsc25519;
  31. void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
  32. void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]);
  33. void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x);
  34. void sc25519_to32bytes(unsigned char r[32], const sc25519 *x);
  35. int sc25519_iszero_vartime(const sc25519 *x);
  36. int sc25519_lt(const sc25519 *x, const sc25519 *y);
  37. void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y);
  38. void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y);
  39. void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
  40. void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y);
  41. /* Convert s into a representation of the form \sum_{i=0}^{63}r[i]2^(4*i)
  42. * with r[i] in {-8,...,7}
  43. */
  44. void sc25519_window4(signed char r[85], const sc25519 *s);
  45. void sc25519_slide(signed char r[256], const sc25519 *s, int swindowsize);
  46. void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
  47. void sc25519_barrett(sc25519 *r, unsigned long long x[8]);
  48. #endif