Compare commits
No commits in common. "main" and "c691accd65e0eb09d56fcffc6f369abe4d7a9541" have entirely different histories.
main
...
c691accd65
|
@ -1,2 +1 @@
|
||||||
/target
|
/target
|
||||||
/keys.log
|
|
||||||
|
|
58
src/main.rs
58
src/main.rs
|
@ -1,7 +1,4 @@
|
||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
|
||||||
io::Write,
|
|
||||||
pin::Pin,
|
|
||||||
thread::{spawn, JoinHandle},
|
thread::{spawn, JoinHandle},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
@ -13,9 +10,9 @@ struct ProgressCounter(pub *mut u64);
|
||||||
unsafe impl Send for ProgressCounter {}
|
unsafe impl Send for ProgressCounter {}
|
||||||
unsafe impl Sync for ProgressCounter {}
|
unsafe impl Sync for ProgressCounter {}
|
||||||
impl ProgressCounter {
|
impl ProgressCounter {
|
||||||
fn incr(&mut self, n: u64) {
|
fn incr(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
*self.0 += n;
|
*self.0 += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,76 +24,49 @@ fn work(mut progress: ProgressCounter) -> JoinHandle<()> {
|
||||||
rand_xoshiro::Xoshiro256StarStar::from_rng(rand::thread_rng()).unwrap()
|
rand_xoshiro::Xoshiro256StarStar::from_rng(rand::thread_rng()).unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
const ITERS: u64 = 256;
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for _ in 0..ITERS {
|
|
||||||
let key = cpu::generate_privkey(&mut rng);
|
let key = cpu::generate_privkey(&mut rng);
|
||||||
let pub_key = cpu::get_pubkey(&key);
|
let pub_key = cpu::get_pubkey(&key);
|
||||||
|
|
||||||
// b64(pub_key).starts_with("char") && b64(pub_key)[4] in ["+", "/"]
|
progress.incr();
|
||||||
if pub_key[0] == 0x72
|
|
||||||
&& pub_key[1] == 0x16
|
// b64(pub_key).starts_with("char/")
|
||||||
&& pub_key[2] == 0xab
|
if pub_key[0] == 0x72 && pub_key[1] == 0x16 && pub_key[2] == 0xab && pub_key[3] >= 0xfc
|
||||||
&& pub_key[3] >= 0xf8
|
|
||||||
{
|
{
|
||||||
let key_str = base64::encode(key);
|
let key_str = base64::encode(key);
|
||||||
let pub_key_str = base64::encode(pub_key);
|
let pub_key_str = base64::encode(pub_key);
|
||||||
println!("{} -> {}", key_str, pub_key_str);
|
println!("{} -> {}", key_str, pub_key_str);
|
||||||
|
|
||||||
{
|
|
||||||
let mut file = OpenOptions::new()
|
|
||||||
.create(true)
|
|
||||||
.append(true)
|
|
||||||
.open("keys.log")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let _ = writeln!(file, "{} -> {}", key_str, pub_key_str);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
progress.incr(ITERS);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const NUM_THREADS: usize = 24;
|
const NUM_THREADS: usize = 32;
|
||||||
|
|
||||||
struct Progress(Pin<Box<[u64; NUM_THREADS]>>);
|
struct Progress([u64; NUM_THREADS]);
|
||||||
impl Progress {
|
impl Progress {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Progress(Box::pin([0; NUM_THREADS]))
|
Progress([0; NUM_THREADS])
|
||||||
}
|
|
||||||
|
|
||||||
unsafe fn the_pointer(&mut self) -> *mut u64 {
|
|
||||||
self.0.as_mut_ptr()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn total(&self) -> u64 {
|
|
||||||
self.0.iter().sum()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut progress = Progress::new();
|
let mut progress = Box::pin(Progress::new());
|
||||||
let _handles: Vec<_> = (0..NUM_THREADS)
|
let _handles: Vec<_> = (0..NUM_THREADS)
|
||||||
.map(|id| {
|
.map(|id| {
|
||||||
let ptr = unsafe { progress.the_pointer().add(id) };
|
let ptr = unsafe { progress.0.as_mut_ptr().add(id) };
|
||||||
let progress = ProgressCounter(ptr);
|
let progress = ProgressCounter(ptr);
|
||||||
work(progress)
|
work(progress)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut last_total_progress = 0;
|
let mut last_total_progress = 0;
|
||||||
let mut sleep_secs = 1.0;
|
|
||||||
loop {
|
loop {
|
||||||
let total_progress = progress.total();
|
let total_progress = progress.0.iter().sum();
|
||||||
let delta = total_progress - last_total_progress;
|
let delta = total_progress - last_total_progress;
|
||||||
last_total_progress = total_progress;
|
last_total_progress = total_progress;
|
||||||
|
|
||||||
println!("Guesses/sec ≈ {:.0}", delta as f64 / sleep_secs);
|
println!("Guess/sec ≈ {}", delta);
|
||||||
std::thread::sleep(Duration::from_secs_f64(sleep_secs));
|
std::thread::sleep(Duration::from_millis(1000));
|
||||||
sleep_secs *= 1.05;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue