| 247 | } |
| 248 | |
| 249 | void reconstructAdd(Secp256K1 *secp, string fileName, string outputFile, string privAddr) { |
| 250 | |
| 251 | bool compressed; |
| 252 | int addrType; |
| 253 | Int lambda; |
| 254 | Int lambda2; |
| 255 | lambda.SetBase16("5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72"); |
| 256 | lambda2.SetBase16("ac9c52b33fa3cf1f5ad9e3fd77ed9ba4a880b9fc8ec739c2e0cfc810b51283ce"); |
| 257 | |
| 258 | Int privKey = secp->DecodePrivateKey((char *)privAddr.c_str(),&compressed); |
| 259 | if(privKey.IsNegative()) |
| 260 | exit(-1); |
| 261 | |
| 262 | vector<string> lines; |
| 263 | parseFile(fileName,lines); |
| 264 | |
| 265 | for (int i = 0; i < (int)lines.size(); i+=2) { |
| 266 | |
| 267 | string addr; |
| 268 | string partialPrivAddr; |
| 269 | |
| 270 | if (lines[i].substr(0, 12) == "PubAddress: ") { |
| 271 | |
| 272 | addr = lines[i].substr(12); |
| 273 | |
| 274 | switch (addr.data()[0]) { |
| 275 | case '1': |
| 276 | addrType = P2PKH; break; |
| 277 | case '3': |
| 278 | addrType = P2SH; break; |
| 279 | case 'b': |
| 280 | case 'B': |
| 281 | addrType = BECH32; break; |
| 282 | default: |
| 283 | printf("Invalid partialkey info file at line %d\n", i); |
| 284 | printf("%s Address format not supported\n", addr.c_str()); |
| 285 | continue; |
| 286 | } |
| 287 | |
| 288 | } else { |
| 289 | printf("Invalid partialkey info file at line %d (\"PubAddress: \" expected)\n",i); |
| 290 | exit(-1); |
| 291 | } |
| 292 | |
| 293 | if (lines[i+1].substr(0, 13) == "PartialPriv: ") { |
| 294 | partialPrivAddr = lines[i+1].substr(13); |
| 295 | } else { |
| 296 | printf("Invalid partialkey info file at line %d (\"PartialPriv: \" expected)\n", i); |
| 297 | exit(-1); |
| 298 | } |
| 299 | |
| 300 | bool partialMode; |
| 301 | Int partialPrivKey = secp->DecodePrivateKey((char *)partialPrivAddr.c_str(), &partialMode); |
| 302 | if (privKey.IsNegative()) { |
| 303 | printf("Invalid partialkey info file at line %d\n", i); |
| 304 | exit(-1); |
| 305 | } |
| 306 |
no test coverage detected