24
24
// We use affine coordinates for elliptic curve point (ie Z=1)
25
25
26
26
__device__ __noinline__ void CheckPoint (uint32_t * _h , int32_t incr , int32_t endo , int32_t mode ,prefix_t * prefix ,
27
- uint32_t * lookup32 , uint32_t maxFound , uint32_t * out ) {
27
+ uint32_t * lookup32 , uint32_t maxFound , uint32_t * out , int type ) {
28
28
29
29
uint32_t off ;
30
30
prefixl_t l32 ;
@@ -36,43 +36,59 @@ __device__ __noinline__ void CheckPoint(uint32_t *_h, int32_t incr, int32_t endo
36
36
uint32_t mi ;
37
37
uint32_t lmi ;
38
38
uint32_t tid = (blockIdx .x * blockDim .x ) + threadIdx .x ;
39
-
40
- pr0 = * (prefix_t * )(_h );
41
- hit = prefix [pr0 ];
42
-
43
- if (hit ) {
44
-
45
- if (lookup32 ) {
46
- off = lookup32 [pr0 ];
47
- l32 = _h [0 ];
48
- st = off ;
49
- ed = off + hit - 1 ;
50
- while (st <=ed ) {
51
- mi = (st + ed )/2 ;
52
- lmi = lookup32 [mi ];
53
- if (l32 < lmi ) {
54
- ed = mi - 1 ;
55
- } else if (l32 == lmi ) {
56
- // found
57
- goto addItem ;
58
- } else {
59
- st = mi + 1 ;
60
- }
61
- }
62
- return ;
39
+ char add [48 ];
40
+
41
+ if (prefix == NULL ) {
42
+
43
+ // No lookup compute address and return
44
+ char * pattern = (char * )lookup32 ;
45
+ _GetAddress (type , _h , add );
46
+ if (_Match (add , pattern )) {
47
+ // found
48
+ goto addItem ;
63
49
}
50
+
51
+ } else {
52
+
53
+ // Lookup table
54
+ pr0 = * (prefix_t * )(_h );
55
+ hit = prefix [pr0 ];
56
+
57
+ if (hit ) {
58
+
59
+ if (lookup32 ) {
60
+ off = lookup32 [pr0 ];
61
+ l32 = _h [0 ];
62
+ st = off ;
63
+ ed = off + hit - 1 ;
64
+ while (st <= ed ) {
65
+ mi = (st + ed ) / 2 ;
66
+ lmi = lookup32 [mi ];
67
+ if (l32 < lmi ) {
68
+ ed = mi - 1 ;
69
+ } else if (l32 == lmi ) {
70
+ // found
71
+ goto addItem ;
72
+ } else {
73
+ st = mi + 1 ;
74
+ }
75
+ }
76
+ return ;
77
+ }
78
+
79
+ addItem :
80
+
81
+ pos = atomicAdd (out , 1 );
82
+ if (pos < maxFound ) {
83
+ out [pos * ITEM_SIZE32 + 1 ] = tid ;
84
+ out [pos * ITEM_SIZE32 + 2 ] = (uint32_t )(incr << 16 ) | (uint32_t )(mode << 15 ) | (uint32_t )(endo );
85
+ out [pos * ITEM_SIZE32 + 3 ] = _h [0 ];
86
+ out [pos * ITEM_SIZE32 + 4 ] = _h [1 ];
87
+ out [pos * ITEM_SIZE32 + 5 ] = _h [2 ];
88
+ out [pos * ITEM_SIZE32 + 6 ] = _h [3 ];
89
+ out [pos * ITEM_SIZE32 + 7 ] = _h [4 ];
90
+ }
64
91
65
- addItem :
66
-
67
- pos = atomicAdd (out , 1 );
68
- if (pos < maxFound ) {
69
- out [pos * ITEM_SIZE32 + 1 ] = tid ;
70
- out [pos * ITEM_SIZE32 + 2 ] = (uint32_t )(incr << 16 ) | (uint32_t )(mode << 15 ) | (uint32_t )(endo );
71
- out [pos * ITEM_SIZE32 + 3 ] = _h [0 ];
72
- out [pos * ITEM_SIZE32 + 4 ] = _h [1 ];
73
- out [pos * ITEM_SIZE32 + 5 ] = _h [2 ];
74
- out [pos * ITEM_SIZE32 + 6 ] = _h [3 ];
75
- out [pos * ITEM_SIZE32 + 7 ] = _h [4 ];
76
92
}
77
93
78
94
}
@@ -81,7 +97,8 @@ __device__ __noinline__ void CheckPoint(uint32_t *_h, int32_t incr, int32_t endo
81
97
82
98
// -----------------------------------------------------------------------------------------
83
99
84
- #define CHECK_POINT (_h ,incr ,endo ,mode ) CheckPoint(_h,incr,endo,mode,prefix,lookup32,maxFound,out)
100
+ #define CHECK_POINT (_h ,incr ,endo ,mode ) CheckPoint(_h,incr,endo,mode,prefix,lookup32,maxFound,out,P2PKH)
101
+ #define CHECK_POINT_P2SH (_h ,incr ,endo ,mode ) CheckPoint(_h,incr,endo,mode,prefix,lookup32,maxFound,out,P2SH)
85
102
86
103
__device__ __noinline__ void CheckHashComp (prefix_t * prefix , uint64_t * px , uint8_t isOdd , int32_t incr ,
87
104
uint32_t * lookup32 , uint32_t maxFound , uint32_t * out ) {
@@ -106,6 +123,7 @@ __device__ __noinline__ void CheckHashComp(prefix_t *prefix, uint64_t *px, uint8
106
123
_GetHash160Comp (pe2x , !isOdd , (uint8_t * )h );
107
124
CHECK_POINT (h , - incr , 2 , true);
108
125
126
+
109
127
}
110
128
111
129
__device__ __noinline__ void CheckHashP2SHComp (prefix_t * prefix , uint64_t * px , uint8_t isOdd , int32_t incr ,
@@ -116,20 +134,20 @@ __device__ __noinline__ void CheckHashP2SHComp(prefix_t *prefix, uint64_t *px, u
116
134
uint64_t pe2x [4 ];
117
135
118
136
_GetHash160P2SHComp (px , isOdd , (uint8_t * )h );
119
- CHECK_POINT (h , incr , 0 , true);
137
+ CHECK_POINT_P2SH (h , incr , 0 , true);
120
138
_ModMult (pe1x , px , _beta );
121
139
_GetHash160P2SHComp (pe1x , isOdd , (uint8_t * )h );
122
- CHECK_POINT (h , incr , 1 , true);
140
+ CHECK_POINT_P2SH (h , incr , 1 , true);
123
141
_ModMult (pe2x , px , _beta2 );
124
142
_GetHash160P2SHComp (pe2x , isOdd , (uint8_t * )h );
125
- CHECK_POINT (h , incr , 2 , true);
143
+ CHECK_POINT_P2SH (h , incr , 2 , true);
126
144
127
145
_GetHash160P2SHComp (px , !isOdd , (uint8_t * )h );
128
- CHECK_POINT (h , - incr , 0 , true);
146
+ CHECK_POINT_P2SH (h , - incr , 0 , true);
129
147
_GetHash160P2SHComp (pe1x , !isOdd , (uint8_t * )h );
130
- CHECK_POINT (h , - incr , 1 , true);
148
+ CHECK_POINT_P2SH (h , - incr , 1 , true);
131
149
_GetHash160P2SHComp (pe2x , !isOdd , (uint8_t * )h );
132
- CHECK_POINT (h , - incr , 2 , true);
150
+ CHECK_POINT_P2SH (h , - incr , 2 , true);
133
151
134
152
}
135
153
@@ -172,22 +190,22 @@ __device__ __noinline__ void CheckHashP2SHUncomp(prefix_t *prefix, uint64_t *px,
172
190
uint64_t pyn [4 ];
173
191
174
192
_GetHash160P2SHUncomp (px , py , (uint8_t * )h );
175
- CHECK_POINT (h , incr , 0 , false);
193
+ CHECK_POINT_P2SH (h , incr , 0 , false);
176
194
_ModMult (pe1x , px , _beta );
177
195
_GetHash160P2SHUncomp (pe1x , py , (uint8_t * )h );
178
- CHECK_POINT (h , incr , 1 , false);
196
+ CHECK_POINT_P2SH (h , incr , 1 , false);
179
197
_ModMult (pe2x , px , _beta2 );
180
198
_GetHash160P2SHUncomp (pe2x , py , (uint8_t * )h );
181
- CHECK_POINT (h , incr , 2 , false);
199
+ CHECK_POINT_P2SH (h , incr , 2 , false);
182
200
183
201
ModNeg256 (pyn , py );
184
202
185
203
_GetHash160P2SHUncomp (px , pyn , (uint8_t * )h );
186
- CHECK_POINT (h , - incr , 0 , false);
204
+ CHECK_POINT_P2SH (h , - incr , 0 , false);
187
205
_GetHash160P2SHUncomp (pe1x , pyn , (uint8_t * )h );
188
- CHECK_POINT (h , - incr , 1 , false);
206
+ CHECK_POINT_P2SH (h , - incr , 1 , false);
189
207
_GetHash160P2SHUncomp (pe2x , pyn , (uint8_t * )h );
190
- CHECK_POINT (h , - incr , 2 , false);
208
+ CHECK_POINT_P2SH (h , - incr , 2 , false);
191
209
192
210
}
193
211
@@ -245,6 +263,7 @@ __device__ void ComputeKeys(uint32_t mode, uint64_t *startx, uint64_t *starty,
245
263
uint64_t dy [4 ];
246
264
uint64_t _s [4 ];
247
265
uint64_t _p2 [4 ];
266
+ char pattern [48 ];
248
267
249
268
// Load starting key
250
269
__syncthreads ();
@@ -253,6 +272,11 @@ __device__ void ComputeKeys(uint32_t mode, uint64_t *startx, uint64_t *starty,
253
272
Load256 (px , sx );
254
273
Load256 (py , sy );
255
274
275
+ if (sPrefix == NULL ) {
276
+ memcpy (pattern ,lookup32 ,48 );
277
+ lookup32 = (uint32_t * )pattern ;
278
+ }
279
+
256
280
for (uint32_t j = 0 ; j < STEP_SIZE / GRP_SIZE ; j ++ ) {
257
281
258
282
// Fill group with delta x
@@ -370,6 +394,7 @@ __device__ void ComputeKeysP2SH(uint32_t mode, uint64_t *startx, uint64_t *start
370
394
uint64_t dy [4 ];
371
395
uint64_t _s [4 ];
372
396
uint64_t _p2 [4 ];
397
+ char pattern [48 ];
373
398
374
399
// Load starting key
375
400
__syncthreads ();
@@ -378,6 +403,11 @@ __device__ void ComputeKeysP2SH(uint32_t mode, uint64_t *startx, uint64_t *start
378
403
Load256 (px , sx );
379
404
Load256 (py , sy );
380
405
406
+ if (sPrefix == NULL ) {
407
+ memcpy (pattern , lookup32 , 48 );
408
+ lookup32 = (uint32_t * )pattern ;
409
+ }
410
+
381
411
for (uint32_t j = 0 ; j < STEP_SIZE / GRP_SIZE ; j ++ ) {
382
412
383
413
// Fill group with delta x
0 commit comments