crypto_core_ed25519.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef crypto_core_ed25519_H
  2. #define crypto_core_ed25519_H
  3. #include <stddef.h>
  4. #include "export.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define crypto_core_ed25519_BYTES 32
  9. SODIUM_EXPORT
  10. size_t crypto_core_ed25519_bytes(void);
  11. #define crypto_core_ed25519_UNIFORMBYTES 32
  12. SODIUM_EXPORT
  13. size_t crypto_core_ed25519_uniformbytes(void);
  14. #define crypto_core_ed25519_HASHBYTES 64
  15. SODIUM_EXPORT
  16. size_t crypto_core_ed25519_hashbytes(void);
  17. #define crypto_core_ed25519_SCALARBYTES 32
  18. SODIUM_EXPORT
  19. size_t crypto_core_ed25519_scalarbytes(void);
  20. #define crypto_core_ed25519_NONREDUCEDSCALARBYTES 64
  21. SODIUM_EXPORT
  22. size_t crypto_core_ed25519_nonreducedscalarbytes(void);
  23. SODIUM_EXPORT
  24. int crypto_core_ed25519_is_valid_point(const unsigned char *p)
  25. __attribute__ ((nonnull));
  26. SODIUM_EXPORT
  27. int crypto_core_ed25519_add(unsigned char *r,
  28. const unsigned char *p, const unsigned char *q)
  29. __attribute__ ((nonnull));
  30. SODIUM_EXPORT
  31. int crypto_core_ed25519_sub(unsigned char *r,
  32. const unsigned char *p, const unsigned char *q)
  33. __attribute__ ((nonnull));
  34. SODIUM_EXPORT
  35. int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r)
  36. __attribute__ ((nonnull));
  37. SODIUM_EXPORT
  38. int crypto_core_ed25519_from_hash(unsigned char *p, const unsigned char *h)
  39. __attribute__ ((nonnull));
  40. SODIUM_EXPORT
  41. void crypto_core_ed25519_random(unsigned char *p)
  42. __attribute__ ((nonnull));
  43. SODIUM_EXPORT
  44. void crypto_core_ed25519_scalar_random(unsigned char *r)
  45. __attribute__ ((nonnull));
  46. SODIUM_EXPORT
  47. int crypto_core_ed25519_scalar_invert(unsigned char *recip, const unsigned char *s)
  48. __attribute__ ((nonnull));
  49. SODIUM_EXPORT
  50. void crypto_core_ed25519_scalar_negate(unsigned char *neg, const unsigned char *s)
  51. __attribute__ ((nonnull));
  52. SODIUM_EXPORT
  53. void crypto_core_ed25519_scalar_complement(unsigned char *comp, const unsigned char *s)
  54. __attribute__ ((nonnull));
  55. SODIUM_EXPORT
  56. void crypto_core_ed25519_scalar_add(unsigned char *z, const unsigned char *x,
  57. const unsigned char *y)
  58. __attribute__ ((nonnull));
  59. SODIUM_EXPORT
  60. void crypto_core_ed25519_scalar_sub(unsigned char *z, const unsigned char *x,
  61. const unsigned char *y)
  62. __attribute__ ((nonnull));
  63. SODIUM_EXPORT
  64. void crypto_core_ed25519_scalar_mul(unsigned char *z, const unsigned char *x,
  65. const unsigned char *y)
  66. __attribute__ ((nonnull));
  67. /*
  68. * The interval `s` is sampled from should be at least 317 bits to ensure almost
  69. * uniformity of `r` over `L`.
  70. */
  71. SODIUM_EXPORT
  72. void crypto_core_ed25519_scalar_reduce(unsigned char *r, const unsigned char *s)
  73. __attribute__ ((nonnull));
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif