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 {
let q = u64::from(M) * u64::from(i as u32);
n = n + q;
if n.probab_prime(2) {
if n.probab_prime(1) {
return -n;
}
n = n - q;

View File

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