0% found this document useful (0 votes)
9 views2 pages

Prefix 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Prefix 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <string>
#include <openssl/sha.h>
#include <iomanip>
#include <sstream>
#include <thread>
#include <vector>

using namespace std;

// Funkcija za heširanje SHA256


string sha256(const string& input) {
unsigned char hash[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256Context;
SHA256_Init(&sha256Context);
SHA256_Update(&sha256Context, input.c_str(), input.length());
SHA256_Final(hash, &sha256Context);

stringstream ss;
for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
ss << hex << setw(2) << setfill('0') << (int)hash[i];
}
return ss.str();
}

// Funkcija za generisanje Bitcoin adrese iz javnog ključa


string pubkey_to_address(const string& pubkey) {
string sha256_hash = sha256(pubkey); // SHA-256 heširanje
// Dalja obrada se može obaviti pomoću drugih algoritama
return sha256_hash.substr(0, 34); // Pretpostavimo da se Bitcoin adresa
koristi ovako
}

void find_address_with_prefix(const string& start_private_key, const string&


target_prefix, uint64_t start_value, uint64_t end_value) {
string base_key = start_private_key.substr(0, start_private_key.length() - 8);

for (uint64_t i = start_value; i < end_value; i++) {


string hex_suffix = to_string(i);
string private_key = base_key + hex_suffix;

// Pretpostavimo da imamo javni ključ na osnovu privatnog ključa


string pubkey = private_key; // Ovde bi trebalo da implementirate
generisanje javnog ključa
string address = pubkey_to_address(pubkey);

if (address.rfind(target_prefix, 0) == 0) {
cout << "\nFound address: " << address << endl;
cout << "Private Key: " << private_key << endl;
return;
}
}
}

void search_with_threads(const string& start_private_key, const string&


target_prefix, int num_threads) {
uint64_t start_value = 0;
uint64_t end_value = 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16; // 16^8
uint64_t range_size = (end_value - start_value) / num_threads;
vector<thread> threads;

for (int i = 0; i < num_threads; i++) {


uint64_t thread_start = start_value + i * range_size;
uint64_t thread_end = start_value + (i + 1) * range_size;

threads.push_back(thread(find_address_with_prefix, start_private_key,
target_prefix, thread_start, thread_end));
}

// Čekanje da sve niti završe


for (auto& t : threads) {
t.join();
}
}

int main() {
string start_private_key =
"000000000000000000000000000000000000000000000007545bf10859946eca";
string target_prefix = "1BY8GQbnueYofwSuFAT3USAhGjPrkxDdW9"; // Prefiks koji
tražimo (može biti duži niz)
int num_threads = 12; // Broj niti koje želimo da koristimo

// Pokretanje pretrage
search_with_threads(start_private_key, target_prefix, num_threads);

return 0;
}

You might also like