actually make the secret
This commit is contained in:
parent
cfc01650b3
commit
b214eb6099
2 changed files with 14 additions and 4 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
, stdenv
|
, stdenv
|
||||||
, clangStdenv
|
, clangStdenv
|
||||||
, hostPlatform
|
, hostPlatform
|
||||||
, targetPlatform
|
|
||||||
, pkg-config
|
, pkg-config
|
||||||
, libiconv
|
, libiconv
|
||||||
, rustfmt
|
, rustfmt
|
||||||
|
|
@ -17,7 +16,7 @@ let
|
||||||
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
|
||||||
in
|
in
|
||||||
|
|
||||||
naersk.lib."${targetPlatform.system}".buildPackage rec {
|
naersk.lib."${stdenv.targetPlatform.system}".buildPackage rec {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
|
|
||||||
15
src/main.rs
15
src/main.rs
|
|
@ -1,4 +1,4 @@
|
||||||
use std::env;
|
use std::{env, thread, time::Duration};
|
||||||
|
|
||||||
use ntt::{mod_exp, primitive_root};
|
use ntt::{mod_exp, primitive_root};
|
||||||
use primes::is_prime;
|
use primes::is_prime;
|
||||||
|
|
@ -11,7 +11,18 @@ fn main() {
|
||||||
let a = rpassword::prompt_password("a = ").unwrap();
|
let a = rpassword::prompt_password("a = ").unwrap();
|
||||||
let a = a.parse::<u32>().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 {
|
} else {
|
||||||
let rng = rand::rng();
|
let rng = rand::rng();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue