concrete_core/specification/engines/glwe_ciphertext_conversion.rs
1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::GlweCiphertextEntity;
4
5engine_error! {
6 GlweCiphertextConversionError for GlweCiphertextConversionEngine @
7}
8
9/// A trait for engines converting GLWE ciphertexts.
10///
11/// # Semantics
12///
13/// This [pure](super#operation-semantics) operation generates a GLWE ciphertext containing the
14/// conversion of the `input` GLWE ciphertext to a type with a different representation (for
15/// instance from cpu to gpu memory).
16///
17/// # Formal Definition
18pub trait GlweCiphertextConversionEngine<Input, Output>: AbstractEngine
19where
20 Input: GlweCiphertextEntity,
21 Output: GlweCiphertextEntity,
22{
23 /// Converts a GLWE ciphertext.
24 fn convert_glwe_ciphertext(
25 &mut self,
26 input: &Input,
27 ) -> Result<Output, GlweCiphertextConversionError<Self::EngineError>>;
28
29 /// Unsafely converts a GLWE ciphertext.
30 ///
31 /// # Safety
32 /// For the _general_ safety concerns regarding this operation, refer to the different variants
33 /// of [`GlweCiphertextConversionError`]. For safety concerns _specific_ to an engine, refer to
34 /// the implementer safety section.
35 unsafe fn convert_glwe_ciphertext_unchecked(&mut self, input: &Input) -> Output;
36}