arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/rlwe/src/elem.rs
rlwe/src/elem.rsRaw
 1use base2k::ZnxInfos;
 2
 3use crate::utils::derive_size;
 4
 5pub trait Infos {
 6    type Inner: ZnxInfos;
 7
 8    fn inner(&self) -> &Self::Inner;
 9
10    /// Returns the ring degree of the polynomials.
11    fn n(&self) -> usize {
12        self.inner().n()
13    }
14
15    /// Returns the base two logarithm of the ring dimension of the polynomials.
16    fn log_n(&self) -> usize {
17        self.inner().log_n()
18    }
19
20    /// Returns the number of rows.
21    fn rows(&self) -> usize {
22        self.inner().rows()
23    }
24
25    /// Returns the number of polynomials in each row.
26    fn cols(&self) -> usize {
27        self.inner().cols()
28    }
29
30    /// Returns the number of size per polynomial.
31    fn size(&self) -> usize {
32        let size: usize = self.inner().size();
33        debug_assert_eq!(size, derive_size(self.log_base2k(), self.log_k()));
34        size
35    }
36
37    /// Returns the total number of small polynomials.
38    fn poly_count(&self) -> usize {
39        self.rows() * self.cols() * self.size()
40    }
41
42    /// Returns the base 2 logarithm of the ciphertext base.
43    fn log_base2k(&self) -> usize;
44
45    /// Returns the bit precision of the ciphertext.
46    fn log_k(&self) -> usize;
47}