This commit is contained in:
Pro7ech
2025-10-15 10:48:14 +02:00
parent a5df85170d
commit 008b800c01
74 changed files with 890 additions and 871 deletions

View File

@@ -116,29 +116,34 @@ where
impl<B: Backend> LWESwitchingKeyPreparedAlloc<B> for Module<B> where Self: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: LWESwitchingKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_lwe_switching_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> Self
where
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_lwe_switching_key_prepared(base2k, k, dnum)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_lwe_switching_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize
where
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_lwe_switching_key_prepared(base2k, k, dnum)
}
}
@@ -165,20 +170,20 @@ where
impl<B: Backend> LWESwitchingKeyPrepare<B> for Module<B> where Self: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A>(&self, module: &Module<B>, infos: &A)
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A)
where
A: GGLWEInfos,
Module<B>: LWESwitchingKeyPrepare<B>,
M: LWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_switching_key_tmp_bytes(infos);
}
}
impl<D: DataMut, B: Backend> LWESwitchingKeyPrepared<D, B> {
fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: LWESwitchingKeyToRef,
Module<B>: LWESwitchingKeyPrepare<B>,
M: LWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_switching_key(self, other, scratch);
}