1 /*******************************************************************************
2 
3     D language bindings for libsodium's crypto_core_ed25519.h
4 
5     License: ISC (see LICENSE.txt)
6 
7 *******************************************************************************/
8 
9 module libsodium.crypto_core_ed25519;
10 
11 @nogc nothrow:
12 
13 import libsodium.export_;
14 
15 extern (C):
16 
17 enum crypto_core_ed25519_BYTES = 32;
18 size_t crypto_core_ed25519_bytes ();
19 
20 enum crypto_core_ed25519_UNIFORMBYTES = 32;
21 size_t crypto_core_ed25519_uniformbytes ();
22 
23 enum crypto_core_ed25519_HASHBYTES = 64;
24 size_t crypto_core_ed25519_hashbytes ();
25 
26 enum crypto_core_ed25519_SCALARBYTES = 32;
27 size_t crypto_core_ed25519_scalarbytes ();
28 
29 enum crypto_core_ed25519_NONREDUCEDSCALARBYTES = 64;
30 size_t crypto_core_ed25519_nonreducedscalarbytes ();
31 
32 int crypto_core_ed25519_is_valid_point (const(ubyte)* p);
33 
34 int crypto_core_ed25519_add (ubyte* r, const(ubyte)* p, const(ubyte)* q);
35 
36 int crypto_core_ed25519_sub (ubyte* r, const(ubyte)* p, const(ubyte)* q);
37 
38 int crypto_core_ed25519_from_uniform (ubyte* p, const(ubyte)* r);
39 
40 int crypto_core_ed25519_from_hash (ubyte* p, const(ubyte)* h);
41 
42 void crypto_core_ed25519_random (ubyte* p);
43 
44 void crypto_core_ed25519_scalar_random (ubyte* r);
45 
46 int crypto_core_ed25519_scalar_invert (ubyte* recip, const(ubyte)* s);
47 
48 void crypto_core_ed25519_scalar_negate (ubyte* neg, const(ubyte)* s);
49 
50 void crypto_core_ed25519_scalar_complement (ubyte* comp, const(ubyte)* s);
51 
52 void crypto_core_ed25519_scalar_add (
53     ubyte* z,
54     const(ubyte)* x,
55     const(ubyte)* y);
56 
57 void crypto_core_ed25519_scalar_sub (
58     ubyte* z,
59     const(ubyte)* x,
60     const(ubyte)* y);
61 
62 void crypto_core_ed25519_scalar_mul (
63     ubyte* z,
64     const(ubyte)* x,
65     const(ubyte)* y);
66 
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 void crypto_core_ed25519_scalar_reduce (ubyte* r, const(ubyte)* s);