diff --git a/rust/diffie-hellman/src/lib.rs b/rust/diffie-hellman/src/lib.rs index de7ff526..14a15169 100644 --- a/rust/diffie-hellman/src/lib.rs +++ b/rust/diffie-hellman/src/lib.rs @@ -12,5 +12,5 @@ pub fn public_key(p: u64, g: u64, a: u64) -> u64 { } pub fn secret(p: u64, b_pub: u64, a: u64) -> u64 { - return b_pub.pow(a.try_into().unwrap()) % p + b_pub.to_biguint().unwrap().modpow(&a.to_biguint().unwrap(), &p.to_biguint().unwrap()).try_into().unwrap() } diff --git a/rust/diffie-hellman/tests/diffie-hellman.rs b/rust/diffie-hellman/tests/diffie-hellman.rs index 17085a31..52b28a45 100644 --- a/rust/diffie-hellman/tests/diffie-hellman.rs +++ b/rust/diffie-hellman/tests/diffie-hellman.rs @@ -49,7 +49,6 @@ fn public_key_correct_big_numbers() { } #[test] -#[ignore] fn secret_key_correct_big_numbers() { let p: u64 = 4_294_967_927;