feat(core): add missing APIs

This commit is contained in:
Mayeul@Zama
2025-06-18 14:46:32 +02:00
committed by Nicolas Sarlin
parent fff86fb3b4
commit 802945fa52
2 changed files with 14 additions and 0 deletions

View File

@@ -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<T> Container for [T] {
type Element = T;
}
impl<T: Clone> Container for Cow<'_, [T]> {
type Element = T;
}
impl<T> ContainerMut for [T] {}
impl<T> Container for Vec<T> {

View File

@@ -81,6 +81,14 @@ where
SwitchedScalar: UnsignedInteger,
C: Container<Element = Scalar>,
{
pub fn into_raw_parts(self) -> (LweCiphertext<C>, 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<C>,