poulpy/poulpy-core/src/external_product/gglwe_atk.rs
poulpy-core/src/external_product/gglwe_atk.rsRaw
1use poulpy_hal::layouts::{Backend, DataMut, Scratch};
2
3use crate::{
4 ScratchTakeCore,
5 external_product::gglwe_ksk::GGLWEExternalProduct,
6 layouts::{AutomorphismKey, AutomorphismKeyToRef, GGLWEInfos, GGSWInfos, prepared::GGSWPreparedToRef},
7};
8
9impl AutomorphismKey<Vec<u8>> {
10 pub fn external_product_tmp_bytes<R, A, B, M, BE: Backend>(
11 &self,
12 module: &M,
13 res_infos: &R,
14 a_infos: &A,
15 b_infos: &B,
16 ) -> usize
17 where
18 R: GGLWEInfos,
19 A: GGLWEInfos,
20 B: GGSWInfos,
21 M: GGLWEExternalProduct<BE>,
22 {
23 module.gglwe_external_product_tmp_bytes(res_infos, a_infos, b_infos)
24 }
25}
26
27impl<DataSelf: DataMut> AutomorphismKey<DataSelf> {
28 pub fn external_product<A, B, M, BE: Backend>(&mut self, module: &M, a: &A, b: &B, scratch: &mut Scratch<BE>)
29 where
30 M: GGLWEExternalProduct<BE>,
31 A: AutomorphismKeyToRef,
32 B: GGSWPreparedToRef<BE>,
33 Scratch<BE>: ScratchTakeCore<BE>,
34 {
35 module.gglwe_external_product(&mut self.key.key, &a.to_ref().key.key, b, scratch);
36 }
37
38 pub fn external_product_inplace<A, M, BE: Backend>(&mut self, module: &M, a: &A, scratch: &mut Scratch<BE>)
39 where
40 M: GGLWEExternalProduct<BE>,
41 A: GGSWPreparedToRef<BE>,
42 Scratch<BE>: ScratchTakeCore<BE>,
43 {
44 module.gglwe_external_product_inplace(&mut self.key.key, a, scratch);
45 }
46}