concrete_core/specification/engines/
lwe_ciphertext_plaintext_fusing_addition.rs

1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::{LweCiphertextEntity, PlaintextEntity};
4
5engine_error! {
6    LweCiphertextPlaintextFusingAdditionError for LweCiphertextPlaintextFusingAdditionEngine @
7}
8
9/// A trait for engines adding (fusing) plaintexts to LWE ciphertexts.
10///
11/// # Semantics
12///
13/// This [fusing](super#operation-semantics) operation adds the `input` plaintext to the `output`
14/// LWE ciphertext.
15///
16/// # Formal Definition
17pub trait LweCiphertextPlaintextFusingAdditionEngine<Ciphertext, Plaintext>:
18    AbstractEngine
19where
20    Plaintext: PlaintextEntity,
21    Ciphertext: LweCiphertextEntity,
22{
23    /// Add a plaintext to an LWE ciphertext.
24    fn fuse_add_lwe_ciphertext_plaintext(
25        &mut self,
26        output: &mut Ciphertext,
27        input: &Plaintext,
28    ) -> Result<(), LweCiphertextPlaintextFusingAdditionError<Self::EngineError>>;
29
30    /// Unsafely add a plaintext to an LWE ciphertext.
31    ///
32    /// # Safety
33    /// For the _general_ safety concerns regarding this operation, refer to the different variants
34    /// of [`LweCiphertextPlaintextFusingAdditionError`]. For safety concerns _specific_ to an
35    /// engine, refer to the implementer safety section.
36    unsafe fn fuse_add_lwe_ciphertext_plaintext_unchecked(
37        &mut self,
38        output: &mut Ciphertext,
39        input: &Plaintext,
40    );
41}