forked from JeanLucPons/VanitySearch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vanity.h
151 lines (125 loc) · 3.96 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
/*
* 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
#define CPU_GRP_SIZE 1024
class VanitySearch;
typedef struct {
VanitySearch *obj;
int threadId;
bool isRunning;
bool hasStarted;
bool rekeyRequest;
int gridSizeX;
int gridSizeY;
int gpuId;
} TH_PARAM;
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, std::string seed, int searchMode,
bool useGpu,bool stop,std::string outputFile, bool useSSE,uint32_t maxFound,uint64_t rekey,
bool caseSensitive,Point &startPubKey,bool paranoiacSeed);
void Search(int nbThread,std::vector<int> gpuId,std::vector<int> gridSize);
void FindKeyCPU(TH_PARAM *p);
void FindKeyGPU(TH_PARAM *p);
private:
std::string GetHex(std::vector<unsigned char> &buffer);
std::string GetExpectedTime(double keyRate, double keyCount);
bool checkPrivKey(std::string addr, Int &key, int32_t incr, int endomorphism, bool mode);
void checkAddr(int prefIdx, uint8_t *hash160, Int &key, int32_t incr, int endomorphism, bool mode);
void checkAddrSSE(uint8_t *h1, uint8_t *h2, uint8_t *h3, uint8_t *h4,
int32_t incr1, int32_t incr2, int32_t incr3, int32_t incr4,
Int &key, int endomorphism, bool mode);
void checkAddresses(bool compressed, Int key, int i, Point p1);
void checkAddressesSSE(bool compressed, Int key, int i, Point p1, Point p2, Point p3, Point p4);
void output(std::string addr, std::string pAddr, std::string pAddrHex);
bool isAlive(TH_PARAM *p);
bool isSingularPrefix(std::string pref);
bool hasStarted(TH_PARAM *p);
void rekeyRequest(TH_PARAM *p);
uint64_t getGPUCount();
uint64_t getCPUCount();
bool initPrefix(std::string &prefix, PREFIX_ITEM *it);
void dumpPrefixes();
double getDiffuclty();
void updateFound();
void getCPUStartingKey(int thId, Int& key, Point& startP);
void getGPUStartingKeys(int thId, int groupSize, int nbThread, Int *keys, Point *p);
void enumCaseUnsentivePrefix(std::string s, std::vector<std::string> &list);
bool prefixMatch(char *prefix, char *addr);
Secp256K1 *secp;
Int startKey;
Point startPubKey;
bool startPubKeySpecified;
uint64_t counters[256];
double startTime;
int searchType;
int searchMode;
bool hasPattern;
bool caseSensitive;
bool useGpu;
bool stopWhenFound;
bool endOfSearch;
int nbCPUThread;
int nbGPUThread;
int nbFoundKey;
uint64_t rekey;
uint64_t lastRekey;
uint32_t nbPrefix;
std::string outputFile;
bool useSSE;
bool onlyFull;
uint32_t maxFound;
double _difficulty;
bool *patternFound;
std::vector<PREFIX_TABLE_ITEM> prefixes;
std::vector<prefix_t> usedPrefix;
std::vector<LPREFIX> usedPrefixL;
std::vector<std::string> &inputPrefixes;
Int beta;
Int lambda;
Int beta2;
Int lambda2;
#ifdef WIN64
HANDLE ghMutex;
#else
pthread_mutex_t ghMutex;
#endif
};
#endif // VANITYH