1
0

sc25519.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef SC25519_H
  2. #define SC25519_H
  3. #include "compat.h"
  4. #define sc25519 CRYPTO_NAMESPACE(batch_sc25519)
  5. #define shortsc25519 CRYPTO_NAMESPACE(batch_shortsc25519)
  6. #define sc25519_from32bytes CRYPTO_NAMESPACE(batch_sc25519_from32bytes)
  7. #define shortsc25519_from16bytes CRYPTO_NAMESPACE(batch_shortsc25519_from16bytes)
  8. #define sc25519_from64bytes CRYPTO_NAMESPACE(batch_sc25519_from64bytes)
  9. #define sc25519_from_shortsc CRYPTO_NAMESPACE(batch_sc25519_from_shortsc)
  10. #define sc25519_to32bytes CRYPTO_NAMESPACE(batch_sc25519_to32bytes)
  11. #define sc25519_iszero_vartime CRYPTO_NAMESPACE(batch_sc25519_iszero_vartime)
  12. #define sc25519_isshort_vartime CRYPTO_NAMESPACE(batch_sc25519_isshort_vartime)
  13. #define sc25519_lt CRYPTO_NAMESPACE(batch_sc25519_lt)
  14. #define sc25519_add CRYPTO_NAMESPACE(batch_sc25519_add)
  15. #define sc25519_sub_nored CRYPTO_NAMESPACE(batch_sc25519_sub_nored)
  16. #define sc25519_mul CRYPTO_NAMESPACE(batch_sc25519_mul)
  17. #define sc25519_mul_shortsc CRYPTO_NAMESPACE(batch_sc25519_mul_shortsc)
  18. #define sc25519_window4 CRYPTO_NAMESPACE(batch_sc25519_window4)
  19. #define sc25519_window5 CRYPTO_NAMESPACE(batch_sc25519_window5)
  20. #define sc25519_slide CRYPTO_NAMESPACE(batch_sc25519_slide)
  21. #define sc25519_2interleave2 CRYPTO_NAMESPACE(batch_sc25519_2interleave2)
  22. #define sc25519_barrett CRYPTO_NAMESPACE(batch_sc25519_barrett)
  23. typedef struct
  24. {
  25. unsigned long long v[4];
  26. }
  27. sc25519;
  28. typedef struct
  29. {
  30. unsigned long long v[2];
  31. }
  32. shortsc25519;
  33. void sc25519_from32bytes(sc25519 *r, const unsigned char x[32]);
  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_lt(const sc25519 *x, const sc25519 *y) SYSVABI;
  39. void sc25519_add(sc25519 *r, const sc25519 *x, const sc25519 *y) SYSVABI;
  40. void sc25519_sub_nored(sc25519 *r, const sc25519 *x, const sc25519 *y) SYSVABI;
  41. void sc25519_mul(sc25519 *r, const sc25519 *x, const sc25519 *y);
  42. void sc25519_mul_shortsc(sc25519 *r, const sc25519 *x, const shortsc25519 *y);
  43. /* Convert s into a representation of the form \sum_{i=0}^{63}r[i]2^(4*i)
  44. * with r[i] in {-8,...,7}
  45. */
  46. void sc25519_window4(signed char r[64], const sc25519 *s);
  47. void sc25519_window5(signed char r[51], const sc25519 *s);
  48. void sc25519_slide(signed char r[256], const sc25519 *s, int swindowsize);
  49. void sc25519_2interleave2(unsigned char r[127], const sc25519 *s1, const sc25519 *s2);
  50. void sc25519_barrett(sc25519 *r, unsigned long long x[8]) SYSVABI;
  51. #endif