concrete_core/specification/engines/
lwe_ciphertext_creation.rs1use super::engine_error;
2use crate::specification::engines::AbstractEngine;
3use crate::specification::entities::LweCiphertextEntity;
4
5engine_error! {
6 LweCiphertextCreationError for LweCiphertextCreationEngine @
7 EmptyContainer => "The container used to create the LWE ciphertext is of length 0!"
8}
9
10impl<EngineError: std::error::Error> LweCiphertextCreationError<EngineError> {
11 pub fn perform_generic_checks(container_length: usize) -> Result<(), Self> {
13 if container_length == 0 {
14 return Err(Self::EmptyContainer);
15 }
16 Ok(())
17 }
18}
19
20pub trait LweCiphertextCreationEngine<Container, Ciphertext>: AbstractEngine
28where
29 Ciphertext: LweCiphertextEntity,
30{
31 fn create_lwe_ciphertext_from(
33 &mut self,
34 container: Container,
35 ) -> Result<Ciphertext, LweCiphertextCreationError<Self::EngineError>>;
36
37 unsafe fn create_lwe_ciphertext_from_unchecked(&mut self, container: Container) -> Ciphertext;
44}