Skip to main content

poulpy_ckks/delegates/
conjugate.rs

1use anyhow::Result;
2use poulpy_core::{
3    GLWEAutomorphism, GLWEShift,
4    layouts::{
5        GGLWEInfos, GGLWEPreparedToBackendRef, GLWEToBackendMut, GLWEToBackendRef, GetGaloisElement,
6        prepared::GLWEAutomorphismKeyPreparedToBackendRef,
7    },
8};
9use poulpy_hal::layouts::{Backend, Module, ScratchArena};
10
11use crate::{CKKSCtBounds, SetCKKSInfos, oep::CKKSConjugateImpl};
12
13use crate::api::CKKSConjugateOps;
14
15impl<BE: Backend + CKKSConjugateImpl<BE>> CKKSConjugateOps<BE> for Module<BE>
16where
17    Module<BE>: GLWEAutomorphism<BE> + GLWEShift<BE>,
18{
19    fn ckks_conjugate_tmp_bytes<C, K>(&self, ct_infos: &C, key_infos: &K) -> usize
20    where
21        C: CKKSCtBounds,
22        K: GGLWEInfos,
23    {
24        BE::ckks_conjugate_tmp_bytes(self, ct_infos, key_infos)
25    }
26
27    fn ckks_conjugate_into<Dst, Src, K>(
28        &self,
29        dst: &mut Dst,
30        src: &Src,
31        key: &K,
32        scratch: &mut ScratchArena<'_, BE>,
33    ) -> Result<()>
34    where
35        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
36        Src: GLWEToBackendRef<BE> + CKKSCtBounds,
37        K: GLWEAutomorphismKeyPreparedToBackendRef<BE> + GGLWEPreparedToBackendRef<BE> + GetGaloisElement + GGLWEInfos,
38    {
39        BE::ckks_conjugate_into(self, dst, src, key, scratch)
40    }
41
42    fn ckks_conjugate_assign<Dst, K>(&self, dst: &mut Dst, key: &K, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
43    where
44        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
45        K: GLWEAutomorphismKeyPreparedToBackendRef<BE> + GGLWEPreparedToBackendRef<BE> + GetGaloisElement + GGLWEInfos,
46    {
47        BE::ckks_conjugate_assign(self, dst, key, scratch)
48    }
49}