concrete_core/specification/entities/
lwe_bootstrap_key.rs

1use crate::prelude::{
2    DecompositionBaseLog, DecompositionLevelCount, GlweDimension, LweDimension, PolynomialSize,
3};
4use crate::specification::entities::markers::LweBootstrapKeyKind;
5use crate::specification::entities::AbstractEntity;
6
7/// A trait implemented by types embodying an LWE bootstrap key.
8///
9/// # Formal Definition
10///
11/// ## Bootstrapping Key
12/// A bootstrapping key is a vector of
13/// [`GGSW ciphertexts`](`crate::specification::entities::GgswCiphertextEntity`). It encrypts the
14/// coefficients of the [`LWE secret key`](`crate::specification::entities::LweSecretKeyEntity`)
15/// $\vec{s}\_{\mathsf{in}}$ under the
16/// [GLWE secret key](`crate::specification::entities::GlweSecretKeyEntity`)
17/// $\vec{S}\_{\mathsf{out}}$.
18///
19/// $$\mathsf{BSK}\_{\vec{s}\_{\mathsf{in}}\rightarrow \vec{S}\_{\mathsf{out}}} = \left(
20/// \overline{\overline{\mathsf{CT}\_0}}, \cdots ,
21/// \overline{\overline{\mathsf{CT}\_{n\_{\mathsf{in}}-1}}}\right) \subseteq
22/// \mathbb{Z}\_q^{(n\_{\mathsf{out}}+1)\cdot n\_{\mathsf{in}}}$$
23///
24/// where $\vec{s}\_{\mathsf{in}} = \left( s\_0 , \cdots , s\_{\mathsf{in}-1} \right)$ and for all
25/// $0\le i <n\_{\mathsf{in}}$ we have $\overline{\overline{\mathsf{CT}\_i}} \in
26/// \mathsf{GGSW}\_{\vec{S}\_{\mathsf{out}}}^{\beta, \ell}\left(s\_i\right)$.
27///
28/// **Remark:** Observe that the GGSW secret key, which is a GLWE secret key,  can be easily seen as
29/// a LWE secret key by simply taking all the coefficients of the polynomials composing the secret
30/// key and putting them into a vector in order. We will call this LWE secret key derived from the
31/// GLWE secret key **_extracted LWE key_**.
32///
33/// Let $\vec{S}\_{\mathsf{out}} = (S\_{\mathsf{out},0}, \ldots,
34/// S\_{\mathsf{out},k\_{\mathsf{out}}-1}) \in \mathcal{R}^{k\_{\mathsf{out}}}$, such that
35/// $S\_{\mathsf{out},i} = \sum\_{j=0}^{N\_{\mathsf{out}}-1} s\_{\mathsf{out},i, j} \cdot X^j$.
36/// Then, the extracted LWE key will be $\vec{s}\_{\mathsf{out}} = (s\_{\mathsf{out},0,0}, \ldots,
37/// s\_{\mathsf{out},0,N\_{\mathsf{out}}-1}, \ldots, s\_{\mathsf{out},k\_{\mathsf{out}}-1,0},
38/// \ldots, s\_{\mathsf{out},k\_{\mathsf{out}}-1,N\_{\mathsf{out}}-1}) \in
39/// \mathbb{Z}^{n\_{\mathsf{out}}}$, where $n\_{\mathsf{out}} = k\_{\mathsf{out}} \cdot
40/// N\_{\mathsf{out}}$.
41pub trait LweBootstrapKeyEntity: AbstractEntity<Kind = LweBootstrapKeyKind> {
42    /// Returns the GLWE dimension of the key.
43    fn glwe_dimension(&self) -> GlweDimension;
44
45    /// Returns the polynomial size of the key.
46    fn polynomial_size(&self) -> PolynomialSize;
47
48    /// Returns the input LWE dimension of the key.
49    fn input_lwe_dimension(&self) -> LweDimension;
50
51    /// Returns the output LWE dimension of the key.
52    fn output_lwe_dimension(&self) -> LweDimension {
53        LweDimension(self.glwe_dimension().0 * self.polynomial_size().0)
54    }
55
56    /// Returns the number of decomposition levels of the key.
57    fn decomposition_base_log(&self) -> DecompositionBaseLog;
58
59    /// Returns the logarithm of the base used in the key.
60    fn decomposition_level_count(&self) -> DecompositionLevelCount;
61}