diff --git a/tfhe/src/core_crypto/commons/traits/container.rs b/tfhe/src/core_crypto/commons/traits/container.rs index eb35856e7..580baa24f 100644 --- a/tfhe/src/core_crypto/commons/traits/container.rs +++ b/tfhe/src/core_crypto/commons/traits/container.rs @@ -1,5 +1,7 @@ //! Module with traits pertaining to container manipulation. +use std::borrow::Cow; + /// A trait to manipulate various immutable container types transparently. pub trait Container: AsRef<[Self::Element]> { type Element; @@ -16,6 +18,10 @@ impl Container for [T] { type Element = T; } +impl Container for Cow<'_, [T]> { + type Element = T; +} + impl ContainerMut for [T] {} impl Container for Vec { diff --git a/tfhe/src/core_crypto/entities/modulus_switched_lwe_ciphertext.rs b/tfhe/src/core_crypto/entities/modulus_switched_lwe_ciphertext.rs index 169e63428..0eae0c5d3 100644 --- a/tfhe/src/core_crypto/entities/modulus_switched_lwe_ciphertext.rs +++ b/tfhe/src/core_crypto/entities/modulus_switched_lwe_ciphertext.rs @@ -81,6 +81,14 @@ where SwitchedScalar: UnsignedInteger, C: Container, { + pub fn into_raw_parts(self) -> (LweCiphertext, Scalar, CiphertextModulusLog) { + ( + self.lwe_in, + self.body_correction_to_add_before_switching, + self.log_modulus, + ) + } + #[track_caller] pub fn from_raw_parts( lwe_in: LweCiphertext,