make primes bigger and print them out with their bits

This commit is contained in:
jacekpoz 2024-05-14 12:21:02 +02:00
parent 98adfff871
commit 2e90d0076f
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -3,7 +3,7 @@ use std::str::FromStr;
use rand::thread_rng;
use num_bigint::{BigInt, BigUint, RandBigInt, ToBigInt};
use num_traits::{One, Zero};
use num_prime::nt_funcs::is_prime;
use num_prime::{nt_funcs::is_prime};
#[derive(Clone, Debug, PartialEq)]
struct Key {
@ -141,12 +141,15 @@ fn find_private_key(n: &BigUint, e: &BigUint, d: &BigUint) -> (BigUint, BigUint)
fn main() {
let p1 = BigUint::from_str(
"4749005082931655265795279207137334688882888522100146336507022668451002460179375611672565276762330501"
"80353963887486953626439737501036193744308574563815397761973788538684560185111095141165260778449032965268316772055966296398163469889376958493550853540573632322112195295938996103319728902397296099637159"
).unwrap();
let p2 = BigUint::from_str(
"9310861498193275957242744132472955539605730477090317642199650992920633866919589011169367627123252973"
"18707457233710475044596570043325625715877772749687051686334062888982480658954207253640261724015606783212967786089821646723516736894450402336628560527280204032761778998110299572045953802247226060133919"
).unwrap();
println!("p1 ({b} bits): {p1}", b = p1.bits());
println!("p2 ({b} bits): {p2}", b = p1.bits());
let pair_a = generate_key_pair(&p1, &p2)
.expect("failed to generate key pair a");