Bitcoin ABC
0.30.5
P2P Digital Currency
src
secp256k1
src
field_10x26.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_FIELD_REPR_H
8
#define SECP256K1_FIELD_REPR_H
9
10
#include <stdint.h>
11
12
typedef
struct
{
13
/* X = sum(i=0..9, n[i]*2^(i*26)) mod p
14
* where p = 2^256 - 0x1000003D1
15
*/
16
uint32_t n[10];
17
#ifdef VERIFY
18
int
magnitude;
19
int
normalized;
20
#endif
21
}
secp256k1_fe
;
22
23
/* Unpacks a constant into a overlapping multi-limbed FE element. */
24
#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \
25
(d0) & 0x3FFFFFFUL, \
26
(((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \
27
(((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \
28
(((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \
29
(((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \
30
(((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \
31
(((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \
32
(((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \
33
(((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \
34
(((uint32_t)d7) >> 10) \
35
}
36
37
#ifdef VERIFY
38
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0)), 1, 1}
39
#else
40
#define SECP256K1_FE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {SECP256K1_FE_CONST_INNER((d7), (d6), (d5), (d4), (d3), (d2), (d1), (d0))}
41
#endif
42
43
typedef
struct
{
44
uint32_t n[8];
45
}
secp256k1_fe_storage
;
46
47
#define SECP256K1_FE_STORAGE_CONST(d7, d6, d5, d4, d3, d2, d1, d0) {{ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }}
48
#define SECP256K1_FE_STORAGE_CONST_GET(d) d.n[7], d.n[6], d.n[5], d.n[4],d.n[3], d.n[2], d.n[1], d.n[0]
49
50
#endif
/* SECP256K1_FIELD_REPR_H */
secp256k1_fe_storage
Definition:
field_10x26.h:43
secp256k1_fe
Definition:
field_10x26.h:12
Generated on Wed Nov 20 2024 17:55:59 for Bitcoin ABC by
1.9.4