4 #include <stddef.h> /* for size_t */
5 #include <stdbool.h> /* foor bool */
6 #include <stdint.h> /* for uint8_t */
8 #ifndef __has_attribute
9 #define __has_attribute(x) 0
13 # if defined(_WIN32) || defined(__CYGWIN__)
15 # define EDDSA_DECL __declspec(dllexport)
17 # define EDDSA_DECL __declspec(dllimport)
19 # elif defined(EDDSA_BUILD) && defined(__GNUC__) && __GNUC__ >= 4
20 # define EDDSA_DECL __attribute__((visibility ("default")))
21 # elif defined(EDDSA_BUILD) && defined(__CLANG__) && __has_attribute(visibility)
22 # define EDDSA_DECL __attribute__((visibility ("default")))
41 #define ED25519_KEY_LEN 32
42 #define ED25519_SIG_LEN 64
44 EDDSA_DECL void ed25519_genpub(uint8_t pub[ED25519_KEY_LEN],
45 const uint8_t sec[ED25519_KEY_LEN]);
47 EDDSA_DECL void ed25519_sign(uint8_t sig[ED25519_SIG_LEN],
48 const uint8_t sec[ED25519_KEY_LEN],
49 const uint8_t pub[ED25519_KEY_LEN],
50 const uint8_t *data, size_t len);
52 EDDSA_DECL bool ed25519_verify(const uint8_t sig[ED25519_SIG_LEN],
53 const uint8_t pub[ED25519_KEY_LEN],
54 const uint8_t *data, size_t len);
59 * X25519 Diffie-Hellman
62 #define X25519_KEY_LEN 32
64 EDDSA_DECL void x25519_base(uint8_t out[X25519_KEY_LEN],
65 const uint8_t scalar[X25519_KEY_LEN]);
67 EDDSA_DECL void x25519(uint8_t out[X25519_KEY_LEN],
68 const uint8_t scalar[X25519_KEY_LEN],
69 const uint8_t point[X25519_KEY_LEN]);
74 * Key-conversion between ed25519 and x25519
77 EDDSA_DECL void pk_ed25519_to_x25519(uint8_t out[X25519_KEY_LEN],
78 const uint8_t in[ED25519_KEY_LEN]);
80 EDDSA_DECL void sk_ed25519_to_x25519(uint8_t out[X25519_KEY_LEN],
81 const uint8_t in[ED25519_KEY_LEN]);
92 EDDSA_DECL void eddsa_genpub(uint8_t pub[32], const uint8_t sec[32]);
94 EDDSA_DECL void eddsa_sign(uint8_t sig[64],
95 const uint8_t sec[32],
96 const uint8_t pub[32],
97 const uint8_t *data, size_t len);
99 EDDSA_DECL bool eddsa_verify(const uint8_t sig[64],
100 const uint8_t pub[32],
101 const uint8_t *data, size_t len);
105 EDDSA_DECL void DH(uint8_t out[32], const uint8_t sec[32],
106 const uint8_t point[32]);
110 EDDSA_DECL void eddsa_pk_eddsa_to_dh(uint8_t out[32],
111 const uint8_t in[32]);
113 EDDSA_DECL void eddsa_sk_eddsa_to_dh(uint8_t out[32],
114 const uint8_t in[32]);