ed25519.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef ED25519_H
  2. #define ED25519_H
  3. #include "../options.h"
  4. #if defined(__cplusplus)
  5. extern "C" {
  6. #endif
  7. typedef unsigned char ed25519_signature[64];
  8. typedef unsigned char ed25519_public_key[32];
  9. typedef unsigned char ed25519_secret_key[32];
  10. typedef unsigned char curve25519_key[32];
  11. typedef unsigned char ed25519_cosi_signature[32];
  12. void ed25519_publickey(const ed25519_secret_key sk, ed25519_public_key pk);
  13. void ed25519_publickey_ext(const ed25519_secret_key extsk, ed25519_public_key pk);
  14. int ed25519_sign_open(
  15. const unsigned char* m,
  16. size_t mlen,
  17. const ed25519_public_key pk,
  18. const ed25519_signature RS);
  19. void ed25519_sign(
  20. const unsigned char* m,
  21. size_t mlen,
  22. const ed25519_secret_key sk,
  23. ed25519_signature RS);
  24. void ed25519_sign_ext(
  25. const unsigned char* m,
  26. size_t mlen,
  27. const ed25519_secret_key sk,
  28. const ed25519_secret_key skext,
  29. ed25519_signature RS);
  30. int ed25519_scalarmult(
  31. ed25519_public_key res,
  32. const ed25519_secret_key sk,
  33. const ed25519_public_key pk);
  34. void curve25519_scalarmult(
  35. curve25519_key mypublic,
  36. const curve25519_key secret,
  37. const curve25519_key basepoint);
  38. void curve25519_scalarmult_basepoint(curve25519_key mypublic, const curve25519_key secret);
  39. #if !defined(__GNUC__) || __GNUC__ > 4
  40. #define CONST const
  41. #else
  42. #define CONST
  43. #endif
  44. int ed25519_cosi_combine_publickeys(
  45. ed25519_public_key res,
  46. CONST ed25519_public_key* pks,
  47. size_t n);
  48. void ed25519_cosi_combine_signatures(
  49. ed25519_signature res,
  50. const ed25519_public_key R,
  51. CONST ed25519_cosi_signature* sigs,
  52. size_t n);
  53. void ed25519_cosi_commit(ed25519_secret_key nonce, ed25519_public_key commitment);
  54. int ed25519_cosi_sign(
  55. const unsigned char* m,
  56. size_t mlen,
  57. const ed25519_secret_key key,
  58. const ed25519_secret_key nonce,
  59. const ed25519_public_key R,
  60. const ed25519_public_key pk,
  61. ed25519_cosi_signature sig);
  62. #if defined(__cplusplus)
  63. }
  64. #endif
  65. #endif // ED25519_H