From 9f92bad8390932e5cd3827608a609b822671ec3a Mon Sep 17 00:00:00 2001 From: Andreas Schaek Date: Tue, 16 Mar 2021 13:28:13 +0100 Subject: [PATCH] loop over available searchKeys --- Backup.cpp | 22 ++++++++++++++-------- Constants.h | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Backup.cpp b/Backup.cpp index e90d74f..bb8aa2f 100644 --- a/Backup.cpp +++ b/Backup.cpp @@ -159,7 +159,7 @@ bool Kangaroo::LoadWork(string &fileName) { return false; keysToSearch.clear(); - Point key; + int keyCount = 0; // Read global param uint32_t dp; @@ -167,18 +167,21 @@ bool Kangaroo::LoadWork(string &fileName) { if(initDPSize < 0) initDPSize = dp; ::fread(&rangeStart.bits64,32,1,fRead); rangeStart.bits64[4] = 0; ::fread(&rangeEnd.bits64,32,1,fRead); rangeEnd.bits64[4] = 0; + ::fread(&keyCount,sizeof(int),1,fRead); + for(int i = 0; i < keyCount; i++){ + Point key; ::fread(&key.x.bits64,32,1,fRead); key.x.bits64[4] = 0; ::fread(&key.y.bits64,32,1,fRead); key.y.bits64[4] = 0; - ::fread(&offsetCount,sizeof(uint64_t),1,fRead); - ::fread(&offsetTime,sizeof(double),1,fRead); - key.z.SetInt32(1); if(!secp->EC(key)) { ::printf("LoadWork: key does not lie on elliptic curve\n"); return false; } - + key.z.SetInt32(1); keysToSearch.push_back(key); + } + ::fread(&offsetCount,sizeof(uint64_t),1,fRead); + ::fread(&offsetTime,sizeof(double),1,fRead); ::printf("Start:%s\n",rangeStart.GetBase16().c_str()); ::printf("Stop :%s\n",rangeEnd.GetBase16().c_str()); @@ -378,13 +381,16 @@ bool Kangaroo::SaveHeader(string fileName,FILE* f,int type,uint64_t totalCount,d ::fwrite(&version,sizeof(uint32_t),1,f); if(type==HEADW) { - + int keyCount = (int)keysToSearch.size(); // Save global param ::fwrite(&dpSize,sizeof(uint32_t),1,f); ::fwrite(&rangeStart.bits64,32,1,f); ::fwrite(&rangeEnd.bits64,32,1,f); - ::fwrite(&keysToSearch[keyIdx].x.bits64,32,1,f); - ::fwrite(&keysToSearch[keyIdx].y.bits64,32,1,f); + ::fwrite(&keyCount,sizeof(int),1,f); + for(int i = 0; i < keyCount; i++){ + ::fwrite(&keysToSearch[i].x.bits64,32,1,f); + ::fwrite(&keysToSearch[i].y.bits64,32,1,f); + } ::fwrite(&totalCount,sizeof(uint64_t),1,f); ::fwrite(&totalTime,sizeof(double),1,f); diff --git a/Constants.h b/Constants.h index 25ae043..c03f55a 100644 --- a/Constants.h +++ b/Constants.h @@ -19,7 +19,7 @@ #define CONSTANTSH // Release number -#define RELEASE "2.2" +#define RELEASE "2.2.1" // Use symmetry //#define USE_SYMMETRY