diff --git a/poulpy-core/src/scratch.rs b/poulpy-core/src/scratch.rs index f1676d7..1a5a6ce 100644 --- a/poulpy-core/src/scratch.rs +++ b/poulpy-core/src/scratch.rs @@ -57,6 +57,12 @@ pub trait TakeGGSWPrepared { A: GGSWInfos; } +pub trait TakeGGSWPreparedSlice { + fn take_ggsw_prepared_slice(&mut self, size: usize, infos: &A) -> (Vec>, &mut Self) + where + A: GGSWInfos; +} + pub trait TakeGLWESecret { fn take_glwe_secret(&mut self, n: Degree, rank: Rank) -> (GLWESecret<&mut [u8]>, &mut Self); } @@ -286,6 +292,25 @@ where } } +impl TakeGGSWPreparedSlice for Scratch +where + Scratch: TakeGGSWPrepared, +{ + fn take_ggsw_prepared_slice(&mut self, size: usize, infos: &A) -> (Vec>, &mut Self) + where + A: GGSWInfos, + { + let mut scratch: &mut Scratch = self; + let mut cts: Vec> = 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 TakeGLWEPk for Scratch where Scratch: TakeVecZnx,