poulpy_core/layouts/
infos.rs

1use poulpy_hal::layouts::ZnxInfos;
2
3pub trait Infos {
4    type Inner: ZnxInfos;
5
6    fn inner(&self) -> &Self::Inner;
7
8    /// Returns the ring degree of the polynomials.
9    fn n(&self) -> usize {
10        self.inner().n()
11    }
12
13    /// Returns the base two logarithm of the ring dimension of the polynomials.
14    fn log_n(&self) -> usize {
15        self.inner().log_n()
16    }
17
18    /// Returns the number of rows.
19    fn rows(&self) -> usize {
20        self.inner().rows()
21    }
22
23    /// Returns the number of polynomials in each row.
24    fn cols(&self) -> usize {
25        self.inner().cols()
26    }
27
28    fn rank(&self) -> usize {
29        self.cols() - 1
30    }
31
32    /// Returns the number of size per polynomial.
33    fn size(&self) -> usize {
34        let size: usize = self.inner().size();
35        debug_assert!(size >= self.k().div_ceil(self.basek()));
36        size
37    }
38
39    /// Returns the total number of small polynomials.
40    fn poly_count(&self) -> usize {
41        self.rows() * self.cols() * self.size()
42    }
43
44    /// Returns the base 2 logarithm of the ciphertext base.
45    fn basek(&self) -> usize;
46
47    /// Returns the bit precision of the ciphertext.
48    fn k(&self) -> usize;
49}
50
51pub trait SetMetaData {
52    fn set_basek(&mut self, basek: usize);
53    fn set_k(&mut self, k: usize);
54}