use super::engine_error;
use crate::specification::engines::AbstractEngine;
use crate::specification::entities::LweCiphertextEntity;
engine_error! {
LweCiphertextDiscardingSubtractionError for LweCiphertextDiscardingSubtractionEngine @
LweDimensionMismatch => "All the ciphertext LWE dimensions must be the same."
}
impl<EngineError: std::error::Error> LweCiphertextDiscardingSubtractionError<EngineError> {
pub fn perform_generic_checks<InputCiphertext, OutputCiphertext>(
output: &OutputCiphertext,
input_1: &InputCiphertext,
input_2: &InputCiphertext,
) -> Result<(), Self>
where
InputCiphertext: LweCiphertextEntity,
OutputCiphertext: LweCiphertextEntity,
{
if output.lwe_dimension() != input_1.lwe_dimension()
|| output.lwe_dimension() != input_2.lwe_dimension()
{
return Err(Self::LweDimensionMismatch);
}
Ok(())
}
}
pub trait LweCiphertextDiscardingSubtractionEngine<InputCiphertext, OutputCiphertext>:
AbstractEngine
where
InputCiphertext: LweCiphertextEntity,
OutputCiphertext: LweCiphertextEntity,
{
fn discard_sub_lwe_ciphertext(
&mut self,
output: &mut OutputCiphertext,
input_1: &InputCiphertext,
input_2: &InputCiphertext,
) -> Result<(), LweCiphertextDiscardingSubtractionError<Self::EngineError>>;
unsafe fn discard_sub_lwe_ciphertext_unchecked(
&mut self,
output: &mut OutputCiphertext,
input_1: &InputCiphertext,
input_2: &InputCiphertext,
);
}