2525#include " hash/sha512.h"
2626#include " hash/sha256.h"
2727
28- #define RELEASE " 1.12 "
28+ #define RELEASE " 1.13 "
2929
3030using namespace std ;
3131
@@ -48,16 +48,16 @@ void printUsage() {
4848printf (" -o outputfile: Output results to the specified file\n " );
4949printf (" -gpu gpuId1,gpuId2,...: List of GPU(s) to use, default is 0\n " );
5050printf (" -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 " );
5252printf (" -s seed: Specify a seed for the base key, default is random\n " );
5353printf (" -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 " );
5656printf (" -check: Check CPU and GPU kernel vs CPU\n " );
5757printf (" -kp: Generate key pair\n " );
5858printf (" -rp privkey partialkeyfile: Reconstruct final private key(s) from partial key(s) info.\n " );
5959printf (" -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 " );
6161exit (-1 );
6262
6363}
@@ -228,21 +228,22 @@ void outputAdd(string outputFile, int addrType, string addr, string pAddr, strin
228228}
229229
230230// ------------------------------------------------------------------------------------------
231- #define CHECK_ADDR () \
232- p = secp->ComputePublicKey (&fullPriv); \
233- cAddr = secp->GetAddress (addrType, compressed, p); \
234- if (cAddr == addr) { \
235- found =true ; \
231+ #define CHECK_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
241242void reconstructAdd (Secp256K1 *secp, string fileName, string outputFile, string privAddr) {
242243
243244bool compressed;
244245int 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;
312312bool found =false ;
313313
314314// No sym, no endo
315- fullPriv. ModAddK1order (&privKey, &partialPrivKey );
315+ e. Set (&privKey);
316316CHECK_ADDR ();
317317
318318// No sym, endo 1
319319 e.Set (&privKey);
320320 e.ModMulK1order (&lambda);
321- fullPriv.ModAddK1order (&e, &partialPrivKey);
322321CHECK_ADDR ();
323322
324323// No sym, endo 2
325324 e.Set (&privKey);
326325 e.ModMulK1order (&lambda2);
327- fullPriv.ModAddK1order (&e, &partialPrivKey);
328326CHECK_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 );
335332CHECK_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);
343339CHECK_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);
351346CHECK_ADDR ();
352347
353348if (!found) {