pub trait LweCiphertextEncryptionEngine<SecretKey, Plaintext, Ciphertext>: AbstractEngine{
// Required methods
fn encrypt_lwe_ciphertext(
&mut self,
key: &SecretKey,
input: &Plaintext,
noise: Variance,
) -> Result<Ciphertext, LweCiphertextEncryptionError<Self::EngineError>>;
unsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &SecretKey,
input: &Plaintext,
noise: Variance,
) -> Ciphertext;
}Expand description
A trait for engines encrypting LWE ciphertexts.
§Semantics
This pure operation generates an LWE ciphertext containing the
encryption of the input plaintext under the key secret key.
§Formal Definition
§LWE Encryption
§inputs:
- $\mathsf{pt}\in\mathbb{Z}_q$: a plaintext
- $\vec{s}\in\mathbb{Z}_q^n$: a secret key
- $\mathcal{D_{\sigma^2,\mu}}$: a normal distribution of variance $\sigma^2$ and a mean $\mu$
§outputs:
- $\mathsf{ct} = \left( \vec{a} , b\right) \in \mathsf{LWE}^n_{\vec{s}}( \mathsf{pt} )\subseteq \mathbb{Z}_q^{(n+1)}$: an LWE ciphertext
§algorithm:
- uniformly sample a vector $\vec{a}\in\mathbb{Z}_q^n$
- sample an integer error term $e \hookleftarrow \mathcal{D_{\sigma^2,\mu}}$
- compute $b = \left\langle \vec{a} , \vec{s} \right\rangle + \mathsf{pt} + e \in\mathbb{Z}_q$
- output $\left( \vec{a} , b\right)$
Required Methods§
Sourcefn encrypt_lwe_ciphertext(
&mut self,
key: &SecretKey,
input: &Plaintext,
noise: Variance,
) -> Result<Ciphertext, LweCiphertextEncryptionError<Self::EngineError>>
fn encrypt_lwe_ciphertext( &mut self, key: &SecretKey, input: &Plaintext, noise: Variance, ) -> Result<Ciphertext, LweCiphertextEncryptionError<Self::EngineError>>
Encrypts an LWE ciphertext.
Sourceunsafe fn encrypt_lwe_ciphertext_unchecked(
&mut self,
key: &SecretKey,
input: &Plaintext,
noise: Variance,
) -> Ciphertext
unsafe fn encrypt_lwe_ciphertext_unchecked( &mut self, key: &SecretKey, input: &Plaintext, noise: Variance, ) -> Ciphertext
Unsafely encrypts an LWE ciphertext.
§Safety
For the general safety concerns regarding this operation, refer to the different variants
of LweCiphertextEncryptionError. For safety concerns specific to an
engine, refer to the implementer safety section.
Implementors§
impl LweCiphertextEncryptionEngine<LweSecretKey32, Plaintext32, LweCiphertext32> for DefaultEngine
§Description:
Implementation of LweCiphertextEncryptionEngine for DefaultEngine that operates on
32 bits integers.
impl LweCiphertextEncryptionEngine<LweSecretKey64, Plaintext64, LweCiphertext64> for DefaultEngine
§Description:
Implementation of LweCiphertextEncryptionEngine for DefaultEngine that operates on
64 bits integers.