mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Add take_ggsw_prepared_slice
This commit is contained in:
@@ -57,6 +57,12 @@ pub trait TakeGGSWPrepared<B: Backend> {
|
|||||||
A: GGSWInfos;
|
A: GGSWInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait TakeGGSWPreparedSlice<B: Backend> {
|
||||||
|
fn take_ggsw_prepared_slice<A>(&mut self, size: usize, infos: &A) -> (Vec<GGSWCiphertextPrepared<&mut [u8], B>>, &mut Self)
|
||||||
|
where
|
||||||
|
A: GGSWInfos;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait TakeGLWESecret {
|
pub trait TakeGLWESecret {
|
||||||
fn take_glwe_secret(&mut self, n: Degree, rank: Rank) -> (GLWESecret<&mut [u8]>, &mut Self);
|
fn take_glwe_secret(&mut self, n: Degree, rank: Rank) -> (GLWESecret<&mut [u8]>, &mut Self);
|
||||||
}
|
}
|
||||||
@@ -286,6 +292,25 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<B: Backend> TakeGGSWPreparedSlice<B> for Scratch<B>
|
||||||
|
where
|
||||||
|
Scratch<B>: TakeGGSWPrepared<B>,
|
||||||
|
{
|
||||||
|
fn take_ggsw_prepared_slice<A>(&mut self, size: usize, infos: &A) -> (Vec<GGSWCiphertextPrepared<&mut [u8], B>>, &mut Self)
|
||||||
|
where
|
||||||
|
A: GGSWInfos,
|
||||||
|
{
|
||||||
|
let mut scratch: &mut Scratch<B> = self;
|
||||||
|
let mut cts: Vec<GGSWCiphertextPrepared<&mut [u8], B>> = Vec::with_capacity(size);
|
||||||
|
for _ in 0..size {
|
||||||
|
let (ct, new_scratch) = scratch.take_ggsw_prepared(infos);
|
||||||
|
scratch = new_scratch;
|
||||||
|
cts.push(ct)
|
||||||
|
}
|
||||||
|
(cts, scratch)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<B: Backend> TakeGLWEPk for Scratch<B>
|
impl<B: Backend> TakeGLWEPk for Scratch<B>
|
||||||
where
|
where
|
||||||
Scratch<B>: TakeVecZnx,
|
Scratch<B>: TakeVecZnx,
|
||||||
|
|||||||
Reference in New Issue
Block a user