58 lines
1.6 KiB
C++
58 lines
1.6 KiB
C++
//============================================================================
|
|
// Name : bfclient.cpp
|
|
// Author : Armin Friedl
|
|
// Version :
|
|
// Copyright : Public Domain
|
|
// Description : Hello World in C++, Ansi-style
|
|
//============================================================================
|
|
|
|
#include <bytestr.h>
|
|
#include <ec_pubkey_fast.h>
|
|
#include <cstdlib>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <thread>
|
|
|
|
#include "bf/Brainflyer.h"
|
|
|
|
using namespace std;
|
|
|
|
#define BATCH_MAX 4096
|
|
|
|
int main(int argc, char** argv) {
|
|
util::bytestr key("db53d9bbd1f3a83b094eeca7dd970bd85b492fa2");
|
|
|
|
if (argc < 4) {
|
|
cout << "Invalid argument count" << endl;
|
|
return (EXIT_FAILURE);
|
|
}
|
|
|
|
cout << "Computing private key for " << key << endl;
|
|
|
|
int win_size = stoi(argv[3]);
|
|
cout << "Window size: " << win_size << endl;
|
|
|
|
cout << "Initializing precomputation table" << endl;
|
|
// init with window size 16, not reading from file
|
|
if (secp256k1_ec_pubkey_precomp_table(win_size, nullptr) != 0) {
|
|
cout << "Initialization of precomputation table failed" << endl;
|
|
return (EXIT_FAILURE);
|
|
}
|
|
|
|
cout << "Initializing threads" << endl;
|
|
unsigned int numThreads = thread::hardware_concurrency();
|
|
cout << numThreads << " hardware threads available" << endl;
|
|
thread* threads = new thread[numThreads];
|
|
cout << "Starting " << numThreads << " threads" << endl;
|
|
|
|
//numThreads = 1;
|
|
for (unsigned int i = 0; i < numThreads; i++) {
|
|
threads[i] = thread{bf::Brainflyer(i, argv[1], stoi(argv[2]), key)};
|
|
}
|
|
|
|
for (unsigned int i = 0; i < numThreads; i++) threads[i].join();
|
|
|
|
delete[] threads;
|
|
|
|
return (EXIT_SUCCESS);
|
|
}
|