Added base for Montgomery arithmetic

This commit is contained in:
Jean-Philippe Bossuat
2024-12-04 12:53:13 +01:00
parent a957701614
commit ee96c2f904
9 changed files with 353 additions and 0 deletions

19
src/modulus/prime.rs Normal file
View File

@@ -0,0 +1,19 @@
use primality_test::is_prime;
pub struct Prime {
q: u64,
}
impl Prime {
pub fn new(q: u64) -> Self{
assert!(is_prime(q) && q > 2);
Self::new_unchecked(q)
}
pub fn new_unchecked(q: u64) -> Self {
assert!(q.next_power_of_two().ilog2() <= 61);
Self {
q,
}
}
}