Electroneum
group.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Copyright (c) 2013, 2014 Pieter Wuille *
3  * Distributed under the MIT software license, see the accompanying *
4  * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
5  ***********************************************************************/
6 
7 #ifndef SECP256K1_GROUP_H
8 #define SECP256K1_GROUP_H
9 
10 #include "field.h"
11 
16 typedef struct {
19  int infinity; /* whether this represents the point at infinity */
20 } secp256k1_ge;
21 
22 #define SECP256K1_GE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), 0}
23 #define SECP256K1_GE_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1}
24 
28 typedef struct {
29  secp256k1_fe x; /* actual X: x/z^2 */
30  secp256k1_fe y; /* actual Y: y/z^3 */
32  int infinity; /* whether this represents the point at infinity */
34 
35 #define SECP256K1_GEJ_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_CONST((i),(j),(k),(l),(m),(n),(o),(p)), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 1), 0}
36 #define SECP256K1_GEJ_CONST_INFINITY {SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), SECP256K1_FE_CONST(0, 0, 0, 0, 0, 0, 0, 0), 1}
37 
38 typedef struct {
42 
43 #define SECP256K1_GE_STORAGE_CONST(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) {SECP256K1_FE_STORAGE_CONST((a),(b),(c),(d),(e),(f),(g),(h)), SECP256K1_FE_STORAGE_CONST((i),(j),(k),(l),(m),(n),(o),(p))}
44 
45 #define SECP256K1_GE_STORAGE_CONST_GET(t) SECP256K1_FE_STORAGE_CONST_GET(t.x), SECP256K1_FE_STORAGE_CONST_GET(t.y)
46 
48 static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y);
49 
52 static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd);
53 
55 static int secp256k1_ge_is_infinity(const secp256k1_ge *a);
56 
58 static int secp256k1_ge_is_valid_var(const secp256k1_ge *a);
59 
61 static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a);
62 
64 static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a);
65 
67 static void secp256k1_ge_set_gej_var(secp256k1_ge *r, secp256k1_gej *a);
68 
70 static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len);
71 
89 static void secp256k1_ge_table_set_globalz(size_t len, secp256k1_ge *a, const secp256k1_fe *zr);
90 
92 static void secp256k1_ge_set_infinity(secp256k1_ge *r);
93 
95 static void secp256k1_gej_set_infinity(secp256k1_gej *r);
96 
98 static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a);
99 
101 static int secp256k1_gej_eq_var(const secp256k1_gej *a, const secp256k1_gej *b);
102 
104 static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a);
105 
107 static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a);
108 
110 static int secp256k1_gej_is_infinity(const secp256k1_gej *a);
111 
113 static void secp256k1_gej_double(secp256k1_gej *r, const secp256k1_gej *a);
114 
116 static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr);
117 
119 static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr);
120 
122 static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b);
123 
127 static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr);
128 
130 static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv);
131 
133 static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a);
134 
136 static void secp256k1_gej_clear(secp256k1_gej *r);
137 
139 static void secp256k1_ge_clear(secp256k1_ge *r);
140 
142 static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a);
143 
145 static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a);
146 
148 static void secp256k1_gej_cmov(secp256k1_gej *r, const secp256k1_gej *a, int flag);
149 
151 static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag);
152 
154 static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b);
155 
165 static int secp256k1_ge_is_in_correct_subgroup(const secp256k1_ge* ge);
166 
167 #endif /* SECP256K1_GROUP_H */
secp256k1_fe x
Definition: group.h:29
secp256k1_fe_storage y
Definition: group.h:40
int infinity
Definition: group.h:32
secp256k1_fe_storage x
Definition: group.h:39
secp256k1_fe x
Definition: group.h:17
int infinity
Definition: group.h:19
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
secp256k1_fe z
Definition: group.h:31
secp256k1_fe y
Definition: group.h:30
secp256k1_fe y
Definition: group.h:18