Botan  2.4.0
Crypto and TLS for C++11
ed25519_internal.h
Go to the documentation of this file.
1 /*
2 * Ed25519
3 * (C) 2017 Ribose Inc
4 *
5 * Based on the public domain code from SUPERCOP ref10 by
6 * Peter Schwabe, Daniel J. Bernstein, Niels Duif, Tanja Lange, Bo-Yin Yang
7 *
8 * Botan is released under the Simplified BSD License (see license.txt)
9 */
10 
11 #ifndef BOTAN_ED25519_INT_H_
12 #define BOTAN_ED25519_INT_H_
13 
14 #include <botan/internal/ed25519_fe.h>
15 #include <botan/loadstor.h>
16 
17 namespace Botan {
18 
19 inline uint64_t load_3(const uint8_t in[3])
20  {
21  return static_cast<uint64_t>(in[0]) |
22  (static_cast<uint64_t>(in[1]) << 8) |
23  (static_cast<uint64_t>(in[2]) << 16);
24  }
25 
26 inline uint64_t load_4(const uint8_t* in)
27  {
28  return load_le<uint32_t>(in, 0);
29  }
30 
31 /*
32 ge means group element.
33 
34 Here the group is the set of pairs (x,y) of field elements (see fe.h)
35 satisfying -x^2 + y^2 = 1 + d x^2y^2
36 where d = -121665/121666.
37 
38 Representations:
39  ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
40 */
41 
42 typedef struct
43  {
44  fe X;
45  fe Y;
46  fe Z;
47  fe T;
48  } ge_p3;
49 
50 int ge_frombytes_negate_vartime(ge_p3*, const uint8_t*);
51 void ge_scalarmult_base(uint8_t out[32], const uint8_t in[32]);
52 
53 void ge_double_scalarmult_vartime(uint8_t out[32],
54  const uint8_t a[],
55  const ge_p3* A,
56  const uint8_t b[]);
57 
58 /*
59 The set of scalars is \Z/l
60 where l = 2^252 + 27742317777372353535851937790883648493.
61 */
62 
63 void sc_reduce(uint8_t*);
64 void sc_muladd(uint8_t*, const uint8_t*, const uint8_t*, const uint8_t*);
65 
66 }
67 
68 #endif
void sc_muladd(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *)
Definition: sc_muladd.cpp:26
void sc_reduce(uint8_t *)
Definition: sc_reduce.cpp:25
uint64_t load_4(const uint8_t *in)
uint32_t load_le< uint32_t >(const uint8_t in[], size_t off)
Definition: loadstor.h:196
uint64_t load_3(const uint8_t in[3])
int ge_frombytes_negate_vartime(ge_p3 *, const uint8_t *)
Definition: ge.cpp:458
void ge_double_scalarmult_vartime(uint8_t out[32], const uint8_t a[], const ge_p3 *A, const uint8_t b[])
Definition: alg_id.cpp:13
void ge_scalarmult_base(uint8_t out[32], const uint8_t in[32])
Definition: ge.cpp:2118