From c49db0688f971e2057a82e40c95066bf40caf455 Mon Sep 17 00:00:00 2001 From: Pro7ech Date: Fri, 10 Oct 2025 12:52:48 +0200 Subject: [PATCH] Add take_ggsw_prepared_slice --- poulpy-core/src/scratch.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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,