1use poulpy_hal::layouts::{Backend, ScratchArena, VecZnxDft};
2
3use crate::layouts::{
4 GGLWEInfos, GGLWEToBackendMut, GGLWEToBackendRef, GGSWAtViewMut, GGSWAtViewRef, GGSWInfos, GGSWToBackendMut,
5 GGSWToBackendRef, GLWEInfos, GLWEToBackendMut, GLWEToBackendRef, prepared::GGSWPreparedToBackendRef,
6};
7
8pub trait GLWEExternalProduct<BE: Backend> {
9 fn glwe_external_product_tmp_bytes<R, A, B>(&self, res_infos: &R, a_infos: &A, b_infos: &B) -> usize
10 where
11 R: GLWEInfos,
12 A: GLWEInfos,
13 B: GGSWInfos;
14
15 fn glwe_external_product_assign<R, D>(&self, res: &mut R, a: &D, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
16 where
17 R: GLWEToBackendMut<BE> + GLWEInfos,
18 D: GGSWPreparedToBackendRef<BE> + GGSWInfos;
19
20 fn glwe_external_product<R, A, D>(&self, res: &mut R, lhs: &A, rhs: &D, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
21 where
22 R: GLWEToBackendMut<BE> + GLWEInfos,
23 A: GLWEToBackendRef<BE> + GLWEInfos,
24 D: GGSWPreparedToBackendRef<BE> + GGSWInfos;
25}
26
27pub trait GLWEExternalProductInternal<BE: Backend> {
28 fn glwe_external_product_internal_tmp_bytes<R, A, B>(&self, res_infos: &R, a_infos: &A, b_infos: &B) -> usize
29 where
30 R: GLWEInfos,
31 A: GLWEInfos,
32 B: GGSWInfos;
33
34 fn glwe_external_product_dft<'r, A, G>(
35 &self,
36 res_dft: &mut VecZnxDft<<BE as Backend>::BufMut<'r>, BE>,
37 a: &A,
38 ggsw: &G,
39 key_size: usize,
40 scratch: &mut ScratchArena<'_, BE>,
41 ) where
42 A: GLWEToBackendRef<BE>,
43 G: GGSWPreparedToBackendRef<BE>;
44}
45
46pub trait GGLWEExternalProduct<BE: Backend> {
47 fn gglwe_external_product_tmp_bytes<R, A, B>(&self, res_infos: &R, a_infos: &A, b_infos: &B) -> usize
48 where
49 R: GGLWEInfos,
50 A: GGLWEInfos,
51 B: GGSWInfos;
52
53 fn gglwe_external_product<R, A, B>(&self, res: &mut R, a: &A, b: &B, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
54 where
55 R: GGLWEToBackendMut<BE> + GGLWEInfos,
56 A: GGLWEToBackendRef<BE> + GGLWEInfos,
57 B: GGSWPreparedToBackendRef<BE> + GGSWInfos;
58
59 fn gglwe_external_product_assign<R, A>(&self, res: &mut R, a: &A, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
60 where
61 R: GGLWEToBackendMut<BE> + GGLWEInfos,
62 A: GGSWPreparedToBackendRef<BE> + GGSWInfos;
63}
64
65pub trait GGSWExternalProduct<BE: Backend> {
66 fn ggsw_external_product_tmp_bytes<R, A, B>(&self, res_infos: &R, a_infos: &A, b_infos: &B) -> usize
67 where
68 R: GGSWInfos,
69 A: GGSWInfos,
70 B: GGSWInfos;
71
72 fn ggsw_external_product<R, A, B>(&self, res: &mut R, a: &A, b: &B, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
73 where
74 R: GGSWToBackendMut<BE> + GGSWAtViewMut<BE> + GGSWInfos,
75 A: GGSWToBackendRef<BE> + GGSWAtViewRef<BE> + GGSWInfos,
76 B: GGSWPreparedToBackendRef<BE> + GGSWInfos;
77
78 fn ggsw_external_product_assign<R, A>(&self, res: &mut R, a: &A, key_size: usize, scratch: &mut ScratchArena<'_, BE>)
79 where
80 R: GGSWToBackendMut<BE> + GGSWAtViewMut<BE> + GGSWInfos,
81 A: GGSWPreparedToBackendRef<BE> + GGSWInfos;
82}