pub trait LweCiphertextEncryptionEngine<SecretKey, Plaintext, Ciphertext>: AbstractEngine where
    SecretKey: LweSecretKeyEntity,
    Plaintext: PlaintextEntity,
    Ciphertext: LweCiphertextEntity<KeyDistribution = SecretKey::KeyDistribution>, 
{ 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:
  1. uniformly sample a vector $\vec{a}\in\mathbb{Z}_q^n$
  2. sample an integer error term $e \hookleftarrow \mathcal{D_{\sigma^2,\mu}}$
  3. compute $b = \left\langle \vec{a} , \vec{s} \right\rangle + \mathsf{pt} + e \in\mathbb{Z}_q$
  4. output $\left( \vec{a} , b\right)$

Required Methods

Encrypts an LWE 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