Reduce prime check iterations to 1

This commit is contained in:
Agost Biro 2024-06-05 22:48:49 +02:00
parent 5d9659d118
commit a8f91fe50a
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View File

@ -112,7 +112,7 @@ pub fn create_discriminant<T: BigNumExt>(seed: &[u8], length: u16) -> T {
if !x { if !x {
let q = u64::from(M) * u64::from(i as u32); let q = u64::from(M) * u64::from(i as u32);
n = n + q; n = n + q;
if n.probab_prime(2) { if n.probab_prime(1) {
return -n; return -n;
} }
n = n - q; n = n - q;

View File

@ -119,7 +119,7 @@ fn hash_prime<T: BigNum>(seed: &[&[u8]]) -> T {
hasher.input(i); hasher.input(i);
} }
let n = T::from(&hasher.fixed_result()[..16]); let n = T::from(&hasher.fixed_result()[..16]);
if n.probab_prime(2) { if n.probab_prime(1) {
break n; break n;
} }
j += 1; j += 1;