1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_sign_ed25519.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_sign_ed25519;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 import libsodium.crypto_hash_sha512;
15 
16 extern (C):
17 
18 struct crypto_sign_ed25519ph_state
19 {
20     crypto_hash_sha512_state hs;
21 }
22 
23 size_t crypto_sign_ed25519ph_statebytes ();
24 
25 enum crypto_sign_ed25519_BYTES = 64U;
26 size_t crypto_sign_ed25519_bytes ();
27 
28 enum crypto_sign_ed25519_SEEDBYTES = 32U;
29 size_t crypto_sign_ed25519_seedbytes ();
30 
31 enum crypto_sign_ed25519_PUBLICKEYBYTES = 32U;
32 size_t crypto_sign_ed25519_publickeybytes ();
33 
34 enum crypto_sign_ed25519_SECRETKEYBYTES = 32U + 32U;
35 size_t crypto_sign_ed25519_secretkeybytes ();
36 
37 enum crypto_sign_ed25519_MESSAGEBYTES_MAX = SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES;
38 size_t crypto_sign_ed25519_messagebytes_max ();
39 
40 int crypto_sign_ed25519 (
41     ubyte* sm,
42     ulong* smlen_p,
43     const(ubyte)* m,
44     ulong mlen,
45     const(ubyte)* sk);
46 
47 int crypto_sign_ed25519_open (
48     ubyte* m,
49     ulong* mlen_p,
50     const(ubyte)* sm,
51     ulong smlen,
52     const(ubyte)* pk);
53 
54 int crypto_sign_ed25519_detached (
55     ubyte* sig,
56     ulong* siglen_p,
57     const(ubyte)* m,
58     ulong mlen,
59     const(ubyte)* sk);
60 
61 int crypto_sign_ed25519_verify_detached (
62     const(ubyte)* sig,
63     const(ubyte)* m,
64     ulong mlen,
65     const(ubyte)* pk);
66 
67 int crypto_sign_ed25519_keypair (ubyte* pk, ubyte* sk);
68 
69 int crypto_sign_ed25519_seed_keypair (ubyte* pk, ubyte* sk, const(ubyte)* seed);
70 
71 int crypto_sign_ed25519_pk_to_curve25519 (
72     ubyte* curve25519_pk,
73     const(ubyte)* ed25519_pk);
74 
75 int crypto_sign_ed25519_sk_to_curve25519 (
76     ubyte* curve25519_sk,
77     const(ubyte)* ed25519_sk);
78 
79 int crypto_sign_ed25519_sk_to_seed (ubyte* seed, const(ubyte)* sk);
80 
81 int crypto_sign_ed25519_sk_to_pk (ubyte* pk, const(ubyte)* sk);
82 
83 int crypto_sign_ed25519ph_init (crypto_sign_ed25519ph_state* state);
84 
85 int crypto_sign_ed25519ph_update (
86     crypto_sign_ed25519ph_state* state,
87     const(ubyte)* m,
88     ulong mlen);
89 
90 int crypto_sign_ed25519ph_final_create (
91     crypto_sign_ed25519ph_state* state,
92     ubyte* sig,
93     ulong* siglen_p,
94     const(ubyte)* sk);
95 
96 int crypto_sign_ed25519ph_final_verify (
97     crypto_sign_ed25519ph_state* state,
98     const(ubyte)* sig,
99     const(ubyte)* pk);