forked from keyjoke/vs-kangaroo-hybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vanity.h
209 lines (161 loc) · 4.69 KB
/
Vanity.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* This file is part of the VanitySearch distribution (https://github.com/JeanLucPons/VanitySearch).
* Copyright (c) 2019 Jean Luc PONS.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VANITYH
#define VANITYH
#include <string>
#include <vector>
#include "SECP256k1.h"
#include "GPU/GPUEngine.h"
#ifdef WIN64
#include <Windows.h>
#endif
class VanitySearch;
/////////////////////////////////////////////////
typedef struct {
VanitySearch *obj;
int threadId;
bool isRunning;
bool hasStarted;
bool rekeyRequest;
int gridSize;
int gpuId;
Int dK;
Point Kp;
bool type; // false - Tame, true - Wild
} TH_PARAM;
typedef struct {
Int bnL;
Int bnU;
Int bnW;
int pow2L;
int pow2U;
int pow2W;
Int bnM;
Int bnWsqrt;
int pow2Wsqrt;
} structW;
typedef struct {
uint64_t n0;
//uint64_t n1;
//uint64_t n2;
//uint64_t n3;
Int distance;
} hashtb_entry;
typedef struct {
char *prefix;
int prefixLength;
prefix_t sPrefix;
double difficulty;
bool *found;
// For dreamer ;)
bool isFull;
//prefixl_t lPrefix;
uint8_t hash160[20];
} PREFIX_ITEM;
typedef struct {
std::vector<PREFIX_ITEM> *items;
bool found;
} PREFIX_TABLE_ITEM;
/////////////////////////////////////////////////
class VanitySearch {
public:
VanitySearch(Secp256K1 *secp, std::vector<std::string> &prefix, Point targetPubKey, structW *stR, int nbThread, int KangPower, bool stop, std::string outputFile, int flag_verbose, uint32_t maxFound, uint64_t rekey, bool flag_comparator);
void Search(bool useGpu, std::vector<int> gpuId, std::vector<int> gridSize);
void FindKeyCPU(TH_PARAM *p);
void getGPUStartingKeys(int thId, int groupSize, int nbThread, Int *keys, Point *p, uint64_t *n_count);
void getGPUStartingWKeys(int thId, int groupSize, int nbThread, Point w_targetPubKey, Int *w_keys, Point *w_p);// Wild start keys and Wild point
bool File2save(Int px, Int key, int stype);
bool Comparator();
void ReWriteFiles();
bool TWSaveToDrive();
bool TWUpload();
void FindKeyGPU(TH_PARAM *p);
void SolverGPU(TH_PARAM *p);
private:
//std::string GetHex(std::vector<unsigned char> &buffer);
bool checkPrivKeyCPU(Int &checkPrvKey, Point &pSample);
//bool checkPrivKeyGPU(std::string addr, Int &key, int32_t incr, bool mode);
//bool checkPrivKeyGPU(std::string addr, Int &key, int32_t incr, bool mode, uint32_t itThId, Int *greckey);
//void checkAddr(int prefIdx, uint8_t *hash160, Int &key, int32_t incr, bool mode);
//void checkAddr(int prefIdx, uint8_t *hash160, Int &key, int32_t incr, bool mode, uint32_t itThId, Int *reckey);
bool output(std::string msg);
bool outputgpu(std::string msg);
bool isAlive(TH_PARAM *p);
bool hasStarted(TH_PARAM *p);
void rekeyRequest(TH_PARAM *p);
uint64_t getGPUCount();
uint64_t getCPUCount();
//bool initPrefix(std::string &prefix, PREFIX_ITEM *it);
//double getDiffuclty();
//void updateFound();
uint64_t getCountJ();
uint64_t getJmaxofSp(Int& optimalmeanjumpsize, Int * dS);
Secp256K1 *secp;
Int key2;
Int key3;
Int wkey;
uint32_t kadd_count;
//int searchType;
//int searchMode;
Point targetPubKey;
Int resultPrvKey;
uint64_t countj[256];
int nbThread;
int KangPower;
bool TWRevers;
bool flag_comparator;
int nbCPUThread;
int nbGPUThread;
//int nbFoundKey;
uint64_t rekey;
uint64_t lastRekey;
//uint32_t nbPrefix;
std::string outputFile;
//bool onlyFull;
uint32_t maxFound;
//double _difficulty;
std::vector<PREFIX_TABLE_ITEM> prefixes;
//std::vector<prefix_t> usedPrefix;
//std::vector<LPREFIX> usedPrefixL;
std::vector<std::string> &inputPrefixes;
int flag_verbose;
bool flag_endOfSearch;
bool flag_startGPU;
structW *stR;
Int bnL, bnU, bnW;
int pow2L, pow2U, pow2W;
Int bnM, bnWsqrt;
int pow2Wsqrt;
int xU, xV;
uint64_t xUV;
Int bxU, bxV, bxUV;
uint64_t DPmodule;
uint64_t JmaxofSp;
uint32_t GPUJmaxofSp;
Int sizeJmax;
uint64_t maxDP, countDT, countDW, countColl;
uint64_t HASH_SIZE;
hashtb_entry *DPht;
char buff_s32[32+1] = {0};
unsigned char buff_u32[32+1] = {0};
#ifdef WIN64
HANDLE ghMutex;
#else
pthread_mutex_t ghMutex;
#endif
};
#endif // VANITYH