From 5d9659d118558c275231ea83322225d0902ef68c Mon Sep 17 00:00:00 2001 From: Agost Biro Date: Wed, 5 Jun 2024 22:48:20 +0200 Subject: [PATCH] Allow setting prime check iterations <256 --- crates/classgroup/src/gmp_classgroup/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/classgroup/src/gmp_classgroup/mod.rs b/crates/classgroup/src/gmp_classgroup/mod.rs index 1f032e4..f89d8b9 100644 --- a/crates/classgroup/src/gmp_classgroup/mod.rs +++ b/crates/classgroup/src/gmp_classgroup/mod.rs @@ -22,6 +22,8 @@ use std::{ mem::swap, ops::{Mul, MulAssign}, }; +use std::convert::TryInto; + mod congruence; pub(super) mod ffi; @@ -338,7 +340,8 @@ impl> MulAssign for GmpClassGroup { impl super::BigNum for Mpz { 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) {