use super::engine_error;
use crate::specification::engines::AbstractEngine;
use crate::specification::entities::LweCiphertextEntity;
engine_error! {
LweCiphertextFusingSubtractionError for LweCiphertextFusingSubtractionEngine @
LweDimensionMismatch => "The input and output LWE dimensions must be the same."
}
impl<EngineError: std::error::Error> LweCiphertextFusingSubtractionError<EngineError> {
pub fn perform_generic_checks<InputCiphertext, OutputCiphertext>(
output: &OutputCiphertext,
input: &InputCiphertext,
) -> Result<(), Self>
where
InputCiphertext: LweCiphertextEntity,
OutputCiphertext: LweCiphertextEntity,
{
if output.lwe_dimension() != input.lwe_dimension() {
return Err(Self::LweDimensionMismatch);
}
Ok(())
}
}
pub trait LweCiphertextFusingSubtractionEngine<InputCiphertext, OutputCiphertext>:
AbstractEngine
where
InputCiphertext: LweCiphertextEntity,
OutputCiphertext: LweCiphertextEntity,
{
fn fuse_sub_lwe_ciphertext(
&mut self,
output: &mut OutputCiphertext,
input: &InputCiphertext,
) -> Result<(), LweCiphertextFusingSubtractionError<Self::EngineError>>;
unsafe fn fuse_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut OutputCiphertext,
input: &InputCiphertext,
);
}