arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/src/ring/impl_u64/ring.rs
src/ring/impl_u64/ring.rsRaw
 1use crate::ring::Ring;
 2use crate::dft::ntt::Table;
 3use crate::modulus::prime::Prime;
 4use crate::modulus::montgomery::Montgomery;
 5use crate::poly::Poly;
 6
 7impl Ring<u64>{
 8    pub fn new(n:usize, q_base:u64, q_power:usize) -> Self{
 9        let prime: Prime<u64> = Prime::<u64>::new(q_base, q_power);
10        Self {
11            n: n,
12            modulus: prime.clone(),
13            dft: Box::new(Table::<u64>::new(prime, (2 * n) as u64)),
14        }
15    }
16
17    pub fn n(&self) -> usize{
18        return self.n
19    }
20
21    fn new_poly_core<O>(&self) -> Poly<O> where O: Default + Clone {
22        Poly::<O>::new(self.n())
23    }
24
25    pub fn new_poly(&self) -> Poly<u64>{
26        self.new_poly_core::<u64>()
27    }
28
29    pub fn new_poly_montgomery(&self) -> Poly<Montgomery<u64>>{
30        self.new_poly_core::<Montgomery<u64>>()
31    }
32}