PRCYCoin  2.0.0.7rc1
P2P Digital Currency
field.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_FIELD_
8 #define _SECP256K1_FIELD_
9 
21 #if defined HAVE_CONFIG_H
22 #include "libsecp256k1-config.h"
23 #endif
24 
25 #if defined(USE_FIELD_GMP)
26 #include "field_gmp.h"
27 #elif defined(USE_FIELD_10X26)
28 #include "field_10x26.h"
29 #elif defined(USE_FIELD_5X52)
30 #include "field_5x52.h"
31 #else
32 #error "Please select field implementation"
33 #endif
34 
35 typedef struct {
36 #ifndef USE_NUM_NONE
38 #endif
39  secp256k1_fe_t order;
41 
42 static const secp256k1_fe_consts_t *secp256k1_fe_consts = NULL;
43 
45 static void secp256k1_fe_start(void);
46 
48 static void secp256k1_fe_stop(void);
49 
51 static void secp256k1_fe_normalize(secp256k1_fe_t *r);
52 
54 static void secp256k1_fe_set_int(secp256k1_fe_t *r, int a);
55 
57 static int secp256k1_fe_is_zero(const secp256k1_fe_t *a);
58 
60 static int secp256k1_fe_is_odd(const secp256k1_fe_t *a);
61 
63 static int secp256k1_fe_equal(const secp256k1_fe_t *a, const secp256k1_fe_t *b);
64 
66 static int secp256k1_fe_cmp_var(const secp256k1_fe_t *a, const secp256k1_fe_t *b);
67 
69 static int secp256k1_fe_set_b32(secp256k1_fe_t *r, const unsigned char *a);
70 
72 static void secp256k1_fe_get_b32(unsigned char *r, const secp256k1_fe_t *a);
73 
76 static void secp256k1_fe_negate(secp256k1_fe_t *r, const secp256k1_fe_t *a, int m);
77 
80 static void secp256k1_fe_mul_int(secp256k1_fe_t *r, int a);
81 
83 static void secp256k1_fe_add(secp256k1_fe_t *r, const secp256k1_fe_t *a);
84 
87 static void secp256k1_fe_mul(secp256k1_fe_t *r, const secp256k1_fe_t *a, const secp256k1_fe_t * SECP256K1_RESTRICT b);
88 
91 static void secp256k1_fe_sqr(secp256k1_fe_t *r, const secp256k1_fe_t *a);
92 
96 static int secp256k1_fe_sqrt(secp256k1_fe_t *r, const secp256k1_fe_t *a);
97 
100 static void secp256k1_fe_inv(secp256k1_fe_t *r, const secp256k1_fe_t *a);
101 
103 static void secp256k1_fe_inv_var(secp256k1_fe_t *r, const secp256k1_fe_t *a);
104 
108 static void secp256k1_fe_inv_all(size_t len, secp256k1_fe_t r[len], const secp256k1_fe_t a[len]);
109 
111 static void secp256k1_fe_inv_all_var(size_t len, secp256k1_fe_t r[len], const secp256k1_fe_t a[len]);
112 
114 static void secp256k1_fe_get_hex(char *r, int *rlen, const secp256k1_fe_t *a);
115 
117 static int secp256k1_fe_set_hex(secp256k1_fe_t *r, const char *a, int alen);
118 
120 static void secp256k1_fe_cmov(secp256k1_fe_t *r, const secp256k1_fe_t *a, int flag);
121 
122 #endif
b
void const uint64_t * b
Definition: field_5x52_asm_impl.h:10
SECP256K1_RESTRICT
#define SECP256K1_RESTRICT
Definition: util.h:74
secp256k1_fe_consts_t
Field element module.
Definition: field.h:35
secp256k1_num_t
Definition: num_gmp.h:14
r
void const uint64_t uint64_t * r
Definition: field_5x52_asm_impl.h:10
secp256k1_fe_t
Definition: field_10x26.h:12
field_gmp.h