sc25519.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef SC25519_H
  2. #define SC25519_H
  3. #include "crypto_int32.h"
  4. #include "crypto_uint32.h"
  5. #define sc25519 crypto_sign_ed25519_ref_sc25519
  6. #define shortsc25519 crypto_sign_ed25519_ref_shortsc25519
  7. #define sc25519_from32bytes crypto_sign_ed25519_ref_sc25519_from32bytes
  8. #define shortsc25519_from16bytes crypto_sign_ed25519_ref_shortsc25519_from16bytes
  9. #define sc25519_from64bytes crypto_sign_ed25519_ref_sc25519_from64bytes
  10. #define sc25519_from_shortsc crypto_sign_ed25519_ref_sc25519_from_shortsc
  11. #define sc25519_to32bytes crypto_sign_ed25519_ref_sc25519_to32bytes
  12. #define sc25519_iszero_vartime crypto_sign_ed25519_ref_sc25519_iszero_vartime
  13. #define sc25519_isshort_vartime crypto_sign_ed25519_ref_sc25519_isshort_vartime
  14. #define sc25519_lt_vartime crypto_sign_ed25519_ref_sc25519_lt_vartime
  15. #define sc25519_add crypto_sign_ed25519_ref_sc25519_add
  16. #define sc25519_sub_nored crypto_sign_ed25519_ref_sc25519_sub_nored
  17. #define sc25519_mul crypto_sign_ed25519_ref_sc25519_mul
  18. #define sc25519_mul_shortsc crypto_sign_ed25519_ref_sc25519_mul_shortsc
  19. #define sc25519_window3 crypto_sign_ed25519_ref_sc25519_window3
  20. #define sc25519_window5 crypto_sign_ed25519_ref_sc25519_window5
  21. #define sc25519_2interleave2 crypto_sign_ed25519_ref_sc25519_2interleave2
  22. typedef struct
  23. {
  24. crypto_uint32 v[32];
  25. }
  26. sc25519;
  27. typedef struct
  28. {
  29. crypto_uint32 v[16];
  30. }
  31. shortsc25519;
  32. void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
  33. void shortsc25519_from16bytes(shortsc25519 *r, const unsigned char x[16]);
  34. void sc25519_from64bytes(sc25519 *r, const unsigned char x[64]);
  35. void sc25519_from_shortsc(sc25519 *r, const shortsc25519 *x);
  36. void sc25519_to32bytes(unsigned char r[32], const sc25519 *x);
  37. int sc25519_iszero_vartime(const sc25519 *x);
  38. int sc25519_isshort_vartime(const sc25519 *x);
  39. int sc25519_lt_vartime(const sc25519 *x, const sc25519 *y);
  40. void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y);
  41. void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y);
  42. void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
  43. void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y);
  44. /* Convert s into a representation of the form \sum_{i=0}^{84}r[i]2^3
  45. * with r[i] in {-4,...,3}
  46. */
  47. void sc25519_window3(signed char r[85], const sc25519 *s);
  48. /* Convert s into a representation of the form \sum_{i=0}^{50}r[i]2^5
  49. * with r[i] in {-16,...,15}
  50. */
  51. void sc25519_window5(signed char r[51], const sc25519 *s);
  52. void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
  53. #endif