share with us sir
I can share puzzle search app in Rust. I'm sick of code in Python.

extern crate bitcoin;
extern crate rand;
extern crate reqwest;
extern crate secp256k1;
extern crate num_cpus;
extern crate thousands;
use bitcoin::network::Network;
use bitcoin::address::Address;
use bitcoin::key::PrivateKey;
use rand::Rng;
use std::env;
use std::fs::File;
use std::io::Write;
use std::thread;
const POWER: u32 = 15;
const TARGET: &str = "1QCbW9HWnwQWiQqVo5exhAnmfqKRrCRsvW";
fn main() {
let args: Vec<String> = env::args().collect();
let num_threads: u32 = if args.len() < 2 {
num_cpus::get() as u32
} else {
args[1].parse().expect("Failed to parse number of threads")
};
let begin = 2u128.pow(POWER - 1);
let end: u128 = 2u128.pow(POWER);
println!(
"[+] Puzzle 66 search.\n[+] concurrency:{}\n[+] search space:2^{}\n[+] {}~{}\n[+] target:{}",
num_threads,
POWER,
begin,
end,
TARGET
);
let mut handles = vec![];
for _ in 0..num_threads {
let handle = thread::spawn(move || {
let mut rng = rand::thread_rng();
random_lookfor(rng.gen_range(begin..end), end);
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap();
}
}
fn random_lookfor(begin: u128, end: u128) {
let secp = bitcoin::secp256k1::Secp256k1::new();
loop {
let value: u128 = rand::thread_rng().gen_range(begin..end);
let private_key_hex = format!("{:0>64x}", value);
let private_key_bytes = hex::decode(private_key_hex.clone()).unwrap();
let private_key: PrivateKey = PrivateKey {
compressed: true,
network: Network::Bitcoin,
inner: bitcoin::secp256k1::SecretKey::from_slice(&private_key_bytes).unwrap(),
};
let public_key = private_key.public_key(&secp);
let address = Address::p2pkh(&public_key, Network::Bitcoin).to_string();
// Print all generated addresses
print!(
"\r[+] address: {}",
address
);
if address == TARGET {
println!(
"\n[+] [{:?}] value: {} private key: {} address: {} - KEY FOUND!",
thread::current().id(),
value,
private_key,
address
);
// Save the result to a file
if let Ok(mut file) = File::create("KEYFOUNDKEYFOUND.txt") {
writeln!(
&mut file,
"[{:?}] value: {} private key: {} address: {} - KEY FOUND!",
thread::current().id(),
value,
private_key,
address
)
.expect("Failed to write to file");
} else {
eprintln!("Error: Failed to create or write to KEYFOUNDKEYFOUND.txt");
}
break;
}
}
println!("\r[+] [{:?}] finished.", thread::current().id());
}
Cargo.toml
[package]
name = "puzzle"
version = "0.1.0"
edition = "2021"
Cargo.toml
[dependencies]
bitcoin_hashes = "0.13.0"
bitcoin = "0.31.1"
hex = "0.4.3"
rand = "0.8.5"
reqwest = "0.11.23"
secp256k1 = "0.28.1"
num_cpus = "1.16.0"
thousands = "0.2.0"
- [ThreadId(13)] value: 26867 private key: KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFY5iMZbuRxj address: 1QCbW9HWnwQWiQqVo5exhAnmfqKRrCRsvW - KEY FOUND!