PRCYCoin  2.0.0.7rc1
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_
8 #define _SECP256K1_GROUP_
9 
10 #include "num.h"
11 #include "field.h"
12 
14 typedef struct {
17  int infinity; /* whether this represents the point at infinity */
19 
21 typedef struct {
22  secp256k1_fe_t x; /* actual X: x/z^2 */
23  secp256k1_fe_t y; /* actual Y: y/z^3 */
25  int infinity; /* whether this represents the point at infinity */
27 
29 typedef struct {
30  secp256k1_ge_t g; /* the generator point */
31 
32 #ifdef USE_ENDOMORPHISM
33  /* constants related to secp256k1's efficiently computable endomorphism */
34  secp256k1_fe_t beta;
35 #endif
37 
38 static const secp256k1_ge_consts_t *secp256k1_ge_consts = NULL;
39 
41 static void secp256k1_ge_start(void);
42 
44 static void secp256k1_ge_stop(void);
45 
47 static void secp256k1_ge_set_infinity(secp256k1_ge_t *r);
48 
50 static void secp256k1_ge_set_xy(secp256k1_ge_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y);
51 
54 static int secp256k1_ge_set_xo(secp256k1_ge_t *r, const secp256k1_fe_t *x, int odd);
55 
57 static int secp256k1_ge_is_infinity(const secp256k1_ge_t *a);
58 
60 static int secp256k1_ge_is_valid(const secp256k1_ge_t *a);
61 
62 static void secp256k1_ge_neg(secp256k1_ge_t *r, const secp256k1_ge_t *a);
63 
65 static void secp256k1_ge_get_hex(char *r, int *rlen, const secp256k1_ge_t *a);
66 
68 static void secp256k1_ge_set_gej(secp256k1_ge_t *r, secp256k1_gej_t *a);
69 
71 static void secp256k1_ge_set_all_gej_var(size_t len, secp256k1_ge_t r[len], const secp256k1_gej_t a[len]);
72 
73 
75 static void secp256k1_gej_set_infinity(secp256k1_gej_t *r);
76 
78 static void secp256k1_gej_set_xy(secp256k1_gej_t *r, const secp256k1_fe_t *x, const secp256k1_fe_t *y);
79 
81 static void secp256k1_gej_set_ge(secp256k1_gej_t *r, const secp256k1_ge_t *a);
82 
84 static void secp256k1_gej_get_x_var(secp256k1_fe_t *r, const secp256k1_gej_t *a);
85 
87 static void secp256k1_gej_neg(secp256k1_gej_t *r, const secp256k1_gej_t *a);
88 
90 static int secp256k1_gej_is_infinity(const secp256k1_gej_t *a);
91 
93 static void secp256k1_gej_double_var(secp256k1_gej_t *r, const secp256k1_gej_t *a);
94 
96 static void secp256k1_gej_add_var(secp256k1_gej_t *r, const secp256k1_gej_t *a, const secp256k1_gej_t *b);
97 
99 static void secp256k1_gej_add_ge(secp256k1_gej_t *r, const secp256k1_gej_t *a, const secp256k1_ge_t *b);
100 
104 static void secp256k1_gej_add_ge_var(secp256k1_gej_t *r, const secp256k1_gej_t *a, const secp256k1_ge_t *b);
105 
107 static void secp256k1_gej_get_hex(char *r, int *rlen, const secp256k1_gej_t *a);
108 
109 #ifdef USE_ENDOMORPHISM
110 
111 static void secp256k1_gej_mul_lambda(secp256k1_gej_t *r, const secp256k1_gej_t *a);
112 #endif
113 
115 static void secp256k1_gej_clear(secp256k1_gej_t *r);
116 
118 static void secp256k1_ge_clear(secp256k1_ge_t *r);
119 
120 #endif
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
secp256k1_gej_t
A group element of the secp256k1 curve, in jacobian coordinates.
Definition: group.h:21
r
void const uint64_t uint64_t * r
Definition: field_5x52_asm_impl.h:10
secp256k1_ge_consts_t
Global constants related to the group.
Definition: group.h:29
secp256k1_fe_t
Definition: field_10x26.h:12
secp256k1_gej_t::infinity
int infinity
Definition: group.h:25
secp256k1_gej_t::z
secp256k1_fe_t z
Definition: group.h:24
secp256k1_gej_t::x
secp256k1_fe_t x
Definition: group.h:22
num.h
secp256k1_gej_t::y
secp256k1_fe_t y
Definition: group.h:23
secp256k1_ge_t
A group element of the secp256k1 curve, in affine coordinates.
Definition: group.h:14
secp256k1_ge_consts_t::g
secp256k1_ge_t g
Definition: group.h:30
field.h