Crate kctf_pow

Source
Expand description

A library to solve, check, and generate proof-of-work challenges using kCTF’s scheme.

use kctf_pow::ChallengeParams;

// decoding then solving a challenge
let chall = ChallengeParams::decode_challenge("s.AAAAMg==.H+fPiuL32DPbfN97cpd0nA==").unwrap();
println!("{}", chall.solve());
// decoding then checking a challenge
let chall = ChallengeParams::decode_challenge("s.AAAAMg==.NDtqORW1uZlIgzszbdMGZA==").unwrap();
let sol = "s.NUH3arymnKB+ysUGdv+67ypDamn4wOKCPORB2ivWE1Yhinam2v4S6q4nAoC5LP97LScdVoq+NuFVF++Win5mNRYZS6bJAs8fk0h8XgvfcC/7JfmFISqeCIo/CIUgIucVAM+eGDjqitRULGXqIOyviJoJjW8DMouMRuJM/3eg/z18kutQHkX0N3sqPeF7Nzkk8S3Bs6aiHUORM30syUKYug==";
assert_eq!(chall.check(sol), Ok(true));
assert_eq!(chall.check("s.asdf"), Ok(false));
// generating a random challenge of difficulty 50
let chall = ChallengeParams::generate_challenge(50);
println!("{}", chall);

Structs§

ChallengeParams
The parameters for a proof-of-work challenge.