Fabcoin Core  0.16.2
P2P Digital Currency
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 http://www.opensource.org/licenses/mit-license.php.*
5  **********************************************************************/
6 
7 #ifndef SECP256K1_GROUP_H
8 #define SECP256K1_GROUP_H
9 
10 #include "num.h"
11 #include "field.h"
12 
14 typedef struct {
17  int infinity; /* whether this represents the point at infinity */
18 } secp256k1_ge;
19 
20 #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}
21 #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}
22 
24 typedef struct {
25  secp256k1_fe x; /* actual X: x/z^2 */
26  secp256k1_fe y; /* actual Y: y/z^3 */
28  int infinity; /* whether this represents the point at infinity */
30 
31 #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}
32 #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}
33 
34 typedef struct {
38 
39 #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))}
40 
41 #define SECP256K1_GE_STORAGE_CONST_GET(t) SECP256K1_FE_STORAGE_CONST_GET(t.x), SECP256K1_FE_STORAGE_CONST_GET(t.y)
42 
44 static void secp256k1_ge_set_xy(secp256k1_ge *r, const secp256k1_fe *x, const secp256k1_fe *y);
45 
50 static int secp256k1_ge_set_xquad(secp256k1_ge *r, const secp256k1_fe *x);
51 
54 static int secp256k1_ge_set_xo_var(secp256k1_ge *r, const secp256k1_fe *x, int odd);
55 
57 static int secp256k1_ge_is_infinity(const secp256k1_ge *a);
58 
60 static int secp256k1_ge_is_valid_var(const secp256k1_ge *a);
61 
62 static void secp256k1_ge_neg(secp256k1_ge *r, const secp256k1_ge *a);
63 
65 static void secp256k1_ge_set_gej(secp256k1_ge *r, secp256k1_gej *a);
66 
68 static void secp256k1_ge_set_all_gej_var(secp256k1_ge *r, const secp256k1_gej *a, size_t len, const secp256k1_callback *cb);
69 
73 static void secp256k1_ge_set_table_gej_var(secp256k1_ge *r, const secp256k1_gej *a, const secp256k1_fe *zr, size_t len);
74 
80 static void secp256k1_ge_globalz_set_table_gej(size_t len, secp256k1_ge *r, secp256k1_fe *globalz, const secp256k1_gej *a, const secp256k1_fe *zr);
81 
83 static void secp256k1_gej_set_infinity(secp256k1_gej *r);
84 
86 static void secp256k1_gej_set_ge(secp256k1_gej *r, const secp256k1_ge *a);
87 
89 static int secp256k1_gej_eq_x_var(const secp256k1_fe *x, const secp256k1_gej *a);
90 
92 static void secp256k1_gej_neg(secp256k1_gej *r, const secp256k1_gej *a);
93 
95 static int secp256k1_gej_is_infinity(const secp256k1_gej *a);
96 
98 static int secp256k1_gej_has_quad_y_var(const secp256k1_gej *a);
99 
102 static void secp256k1_gej_double_nonzero(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr);
103 
105 static void secp256k1_gej_double_var(secp256k1_gej *r, const secp256k1_gej *a, secp256k1_fe *rzr);
106 
108 static void secp256k1_gej_add_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_gej *b, secp256k1_fe *rzr);
109 
111 static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b);
112 
116 static void secp256k1_gej_add_ge_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, secp256k1_fe *rzr);
117 
119 static void secp256k1_gej_add_zinv_var(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_ge *b, const secp256k1_fe *bzinv);
120 
121 #ifdef USE_ENDOMORPHISM
122 
123 static void secp256k1_ge_mul_lambda(secp256k1_ge *r, const secp256k1_ge *a);
124 #endif
125 
127 static void secp256k1_gej_clear(secp256k1_gej *r);
128 
130 static void secp256k1_ge_clear(secp256k1_ge *r);
131 
133 static void secp256k1_ge_to_storage(secp256k1_ge_storage *r, const secp256k1_ge *a);
134 
136 static void secp256k1_ge_from_storage(secp256k1_ge *r, const secp256k1_ge_storage *a);
137 
139 static void secp256k1_ge_storage_cmov(secp256k1_ge_storage *r, const secp256k1_ge_storage *a, int flag);
140 
142 static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *b);
143 
144 #endif /* SECP256K1_GROUP_H */
secp256k1_fe x
Definition: group.h:25
secp256k1_fe_storage y
Definition: group.h:36
A group element of the secp256k1 curve, in jacobian coordinates.
Definition: group.h:24
#define a(i)
#define x(i)
int infinity
Definition: group.h:28
secp256k1_fe_storage x
Definition: group.h:35
A group element of the secp256k1 curve, in affine coordinates.
Definition: group.h:14
secp256k1_fe x
Definition: group.h:15
int infinity
Definition: group.h:17
#define b(i, j)
secp256k1_fe z
Definition: group.h:27
secp256k1_fe y
Definition: group.h:26
secp256k1_fe y
Definition: group.h:16