mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
Added base for Montgomery arithmetic
This commit is contained in:
19
src/modulus/prime.rs
Normal file
19
src/modulus/prime.rs
Normal 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user