make primes bigger and print them out with their bits
This commit is contained in:
parent
98adfff871
commit
2e90d0076f
1 changed files with 6 additions and 3 deletions
|
@ -3,7 +3,7 @@ use std::str::FromStr;
|
||||||
use rand::thread_rng;
|
use rand::thread_rng;
|
||||||
use num_bigint::{BigInt, BigUint, RandBigInt, ToBigInt};
|
use num_bigint::{BigInt, BigUint, RandBigInt, ToBigInt};
|
||||||
use num_traits::{One, Zero};
|
use num_traits::{One, Zero};
|
||||||
use num_prime::nt_funcs::is_prime;
|
use num_prime::{nt_funcs::is_prime};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
struct Key {
|
struct Key {
|
||||||
|
@ -141,12 +141,15 @@ fn find_private_key(n: &BigUint, e: &BigUint, d: &BigUint) -> (BigUint, BigUint)
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let p1 = BigUint::from_str(
|
let p1 = BigUint::from_str(
|
||||||
"4749005082931655265795279207137334688882888522100146336507022668451002460179375611672565276762330501"
|
"80353963887486953626439737501036193744308574563815397761973788538684560185111095141165260778449032965268316772055966296398163469889376958493550853540573632322112195295938996103319728902397296099637159"
|
||||||
).unwrap();
|
).unwrap();
|
||||||
let p2 = BigUint::from_str(
|
let p2 = BigUint::from_str(
|
||||||
"9310861498193275957242744132472955539605730477090317642199650992920633866919589011169367627123252973"
|
"18707457233710475044596570043325625715877772749687051686334062888982480658954207253640261724015606783212967786089821646723516736894450402336628560527280204032761778998110299572045953802247226060133919"
|
||||||
).unwrap();
|
).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)
|
let pair_a = generate_key_pair(&p1, &p2)
|
||||||
.expect("failed to generate key pair a");
|
.expect("failed to generate key pair a");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue