actually make the secret

This commit is contained in:
mehbark 2026-04-22 23:04:56 -04:00
parent cfc01650b3
commit b214eb6099
Signed by: mbk
GPG key ID: E333EC1335FFCCDB
2 changed files with 14 additions and 4 deletions

View file

@ -3,7 +3,6 @@
, stdenv
, clangStdenv
, hostPlatform
, targetPlatform
, pkg-config
, libiconv
, rustfmt
@ -17,7 +16,7 @@ let
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
in
naersk.lib."${targetPlatform.system}".buildPackage rec {
naersk.lib."${stdenv.targetPlatform.system}".buildPackage rec {
src = ./.;
buildInputs = [

View file

@ -1,4 +1,4 @@
use std::env;
use std::{env, thread, time::Duration};
use ntt::{mod_exp, primitive_root};
use primes::is_prime;
@ -11,7 +11,18 @@ fn main() {
let a = rpassword::prompt_password("a = ").unwrap();
let a = a.parse::<u32>().unwrap();
println!("gª mod p = {}", mod_exp(i64::from(g), i64::from(a), i64::from(p)));
if let Some(Ok(gb)) = env::args().nth(3).map(|s| s.parse::<u32>()) {
let s = mod_exp(i64::from(gb), i64::from(a), i64::from(p));
println!("SECRET IN FIVE SECONDS");
thread::sleep(Duration::from_secs(5));
println!("s = {s}");
} else {
println!(
"gª mod p = {}",
mod_exp(i64::from(g), i64::from(a), i64::from(p))
);
}
} else {
let rng = rand::rng();