Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0312a4

Browse files
committed
Fix
1 parentfe6b1ed commitf0312a4

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

‎SECP256K1.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ Point Secp256K1::NextKey(Point &key) {
205205
IntSecp256K1::DecodePrivateKey(char *key,bool *compressed) {
206206

207207
Int ret;
208+
ret.SetInt32(0);
208209
std::vector<unsignedchar> privKey;
209210

210211
if(key[0] =='5') {

‎main.cpp‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include"hash/sha512.h"
2626
#include"hash/sha256.h"
2727

28-
#defineRELEASE"1.12"
28+
#defineRELEASE"1.13"
2929

3030
usingnamespacestd;
3131

@@ -48,16 +48,16 @@ void printUsage() {
4848
printf(" -o outputfile: Output results to the specified file\n");
4949
printf(" -gpu gpuId1,gpuId2,...: List of GPU(s) to use, default is 0\n");
5050
printf(" -g gridSize1,gridSize2,...: Specify GPU(s) kernel gridsize, default is 8*(MP number)\n");
51-
printf(" -m: Specify maximun number of prefixes found by each kernel call\n");
51+
printf(" -m: Specify maximun number of prefixes found by each kernel call\n");
5252
printf(" -s seed: Specify a seed for the base key, default is random\n");
5353
printf(" -t threadNumber: Specify number of CPU thread, default is number of core\n");
54-
printf(" -nosse: Disable SSE hash function\n");
55-
printf(" -l: List cuda enabled devices\n");
54+
printf(" -nosse: Disable SSE hash function\n");
55+
printf(" -l: List cuda enabled devices\n");
5656
printf(" -check: Check CPU and GPU kernel vs CPU\n");
5757
printf(" -kp: Generate key pair\n");
5858
printf(" -rp privkey partialkeyfile: Reconstruct final private key(s) from partial key(s) info.\n");
5959
printf(" -sp startPubKey: Start the search with a pubKey (for private key splitting)\n");
60-
printf(" -r[keynumber]: Rekey interval in MegaKey, default is disabled\n");
60+
printf(" -rrekey: Rekey interval in MegaKey, default is disabled\n");
6161
exit(-1);
6262

6363
}
@@ -228,21 +228,22 @@ void outputAdd(string outputFile, int addrType, string addr, string pAddr, strin
228228
}
229229

230230
// ------------------------------------------------------------------------------------------
231-
#defineCHECK_ADDR() \
232-
p = secp->ComputePublicKey(&fullPriv); \
233-
cAddr = secp->GetAddress(addrType, compressed, p); \
234-
if (cAddr == addr) { \
235-
found =true; \
231+
#defineCHECK_ADDR() \
232+
fullPriv.ModAddK1order(&e, &partialPrivKey); \
233+
p = secp->ComputePublicKey(&fullPriv); \
234+
cAddr = secp->GetAddress(addrType, compressed, p); \
235+
if (cAddr == addr) { \
236+
found =true; \
236237
string pAddr = secp->GetPrivAddress(compressed, fullPriv); \
237-
string pAddrHex = fullPriv.GetBase16(); \
238-
outputAdd(outputFile, addrType, addr, pAddr, pAddrHex); \
238+
string pAddrHex = fullPriv.GetBase16();\
239+
outputAdd(outputFile, addrType, addr, pAddr, pAddrHex);\
239240
}
240241

241242
voidreconstructAdd(Secp256K1 *secp, string fileName, string outputFile, string privAddr) {
242243

243244
bool compressed;
244245
int addrType;
245-
Int lambda;
246+
Int lambda;
246247
Int lambda2;
247248
lambda.SetBase16("5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72");
248249
lambda2.SetBase16("ac9c52b33fa3cf1f5ad9e3fd77ed9ba4a880b9fc8ec739c2e0cfc810b51283ce");
@@ -304,50 +305,44 @@ void reconstructAdd(Secp256K1 *secp, string fileName, string outputFile, string
304305
}else {
305306

306307
// Reconstruct the address
308+
Int fullPriv;
307309
Point p;
308310
Int e;
309-
Int kn;
310-
Int fullPriv;
311311
string cAddr;
312312
bool found =false;
313313

314314
// No sym, no endo
315-
fullPriv.ModAddK1order(&privKey, &partialPrivKey);
315+
e.Set(&privKey);
316316
CHECK_ADDR();
317317

318318
// No sym, endo 1
319319
e.Set(&privKey);
320320
e.ModMulK1order(&lambda);
321-
fullPriv.ModAddK1order(&e, &partialPrivKey);
322321
CHECK_ADDR();
323322

324323
// No sym, endo 2
325324
e.Set(&privKey);
326325
e.ModMulK1order(&lambda2);
327-
fullPriv.ModAddK1order(&e, &partialPrivKey);
328326
CHECK_ADDR();
329327

330328
// sym, no endo
331-
kn.Set(&privKey);
332-
kn.Neg();
333-
kn.Add(&secp->order);
334-
fullPriv.ModAddK1order(&kn, &partialPrivKey);
329+
e.Set(&privKey);
330+
e.Neg();
331+
e.Add(&secp->order);
335332
CHECK_ADDR();
336333

337334
// sym, endo 1
338335
e.Set(&privKey);
339336
e.ModMulK1order(&lambda);
340337
e.Neg();
341338
e.Add(&secp->order);
342-
fullPriv.ModAddK1order(&e, &partialPrivKey);
343339
CHECK_ADDR();
344340

345341
// sym, endo 2
346342
e.Set(&privKey);
347343
e.ModMulK1order(&lambda2);
348344
e.Neg();
349345
e.Add(&secp->order);
350-
fullPriv.ModAddK1order(&e, &partialPrivKey);
351346
CHECK_ADDR();
352347

353348
if (!found) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp