-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsecp256k1.cpp
103 lines (85 loc) · 2.41 KB
/
secp256k1.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <gec/curve/secp256k1.hpp>
#ifdef GEC_NVCC
GEC_INT_TOO_LARGE
#endif // GEC_NVCC
namespace gec {
namespace curve {
namespace secp256k1 {
using namespace gec::bigint::literal;
// ----- Field -----
namespace _secp256k1_ {
const FBase MOD( //
0xffffffff'ffffffff'ffffffff'ffffffff'ffffffff'ffffffff'fffffffe'fffffc2f_int);
const FBase RR( //
0x01'000007a2'000e90a1_int);
const FBase ONE_R( //
0x1'000003d1_int);
#ifdef GEC_ENABLE_CUDA
#ifdef __CUDACC__
__constant__
#endif
const FBase d_MOD( //
0xffffffff'ffffffff'ffffffff'ffffffff'ffffffff'ffffffff'fffffffe'fffffc2f_int);
#ifdef __CUDACC__
__constant__
#endif
const FBase d_RR( //
0x1'000007a2'000e90a1_int);
#ifdef __CUDACC__
__constant__
#endif
const FBase d_ONE_R( //
0x1'000003d1_int);
#endif // GEC_ENABLE_CUDA
const SBase CARD( //
0xffffffff'ffffffff'ffffffff'fffffffe'baaedce6'af48a03b'bfd25e8c'd0364141_int);
const SBase CARD_RR( //
0x9d671cd5'81c69bc5'e697f5e4'5bcd07c6'741496c2'0e7cf878'896cf214'67d7d140_int);
const SBase CARD_ONE_R( //
0x1'45512319'50b75fc4'402da173'2fc9bebf_int);
#ifdef GEC_ENABLE_CUDA
#ifdef __CUDACC__
__constant__
#endif
const SBase d_CARD( //
0xffffffff'ffffffff'ffffffff'fffffffe'baaedce6'af48a03b'bfd25e8c'd0364141_int);
#ifdef __CUDACC__
__constant__
#endif
const SBase d_CARD_RR( //
0x9d671cd5'81c69bc5'e697f5e4'5bcd07c6'741496c2'0e7cf878'896cf214'67d7d140_int);
#ifdef __CUDACC__
__constant__
#endif
const SBase d_CARD_ONE_R( //
0x1'45512319'50b75fc4'402da173'2fc9bebf_int);
#endif // GEC_ENABLE_CUDA
// A = 0
const Field B(0x7'00001ab7_int);
#ifdef GEC_ENABLE_CUDA
// d_A = 0
#ifdef __CUDACC__
__constant__
#endif
const Field d_B(0x7'00001ab7_int);
#endif // GEC_ENABLE_CUDA
} // namespace _secp256k1_
const Curve<> Gen(
Field( //
0x9981e643'e9089f48'979f48c0'33fd129c'231e2953'29bc66db'd7362e5a'487e2097_int),
Field( //
0xcf3f851f'd4a582d6'70b6b59a'ac19c136'8dfc5d5d'1f1dc64d'b15ea6d2'd3dbabe2_int),
Field( //
0x1'000003d1_int));
#ifdef __CUDACC__
__constant__ const Curve<> d_Gen(
Field( //
0x9981e643'e9089f48'979f48c0'33fd129c'231e2953'29bc66db'd7362e5a'487e2097_int),
Field( //
0xcf3f851f'd4a582d6'70b6b59a'ac19c136'8dfc5d5d'1f1dc64d'b15ea6d2'd3dbabe2_int),
Field( //
0x1'000003d1_int));
#endif // __CUDACC__
} // namespace secp256k1
} // namespace curve
} // namespace gec