Allow setting prime check iterations <256

This commit is contained in:
Agost Biro 2024-06-05 22:48:20 +02:00
parent 1a1554224a
commit 5d9659d118
No known key found for this signature in database

View File

@ -22,6 +22,8 @@ use std::{
mem::swap, mem::swap,
ops::{Mul, MulAssign}, ops::{Mul, MulAssign},
}; };
use std::convert::TryInto;
mod congruence; mod congruence;
pub(super) mod ffi; pub(super) mod ffi;
@ -338,7 +340,8 @@ impl<B: Borrow<GmpClassGroup>> MulAssign<B> for GmpClassGroup {
impl super::BigNum for Mpz { impl super::BigNum for Mpz {
fn probab_prime(&self, iterations: u32) -> bool { fn probab_prime(&self, iterations: u32) -> bool {
self.probab_prime(iterations.max(256) as _) != NotPrime let reps: i32 = iterations.try_into().expect("Iterations fits into i32");
self.probab_prime(reps) != NotPrime
} }
fn setbit(&mut self, bit_index: usize) { fn setbit(&mut self, bit_index: usize) {