Skip to main content

poulpy_ckks/delegates/
neg.rs

1use anyhow::Result;
2use poulpy_core::{
3    GLWENegate, GLWEShift,
4    layouts::{GLWEToBackendMut, GLWEToBackendRef},
5};
6use poulpy_hal::layouts::{Backend, Module, ScratchArena};
7
8use crate::{CKKSCtBounds, SetCKKSInfos, oep::CKKSNegImpl};
9
10use crate::api::CKKSNegOps;
11
12impl<BE: Backend + CKKSNegImpl<BE>> CKKSNegOps<BE> for Module<BE>
13where
14    Module<BE>: GLWENegate<BE> + GLWEShift<BE>,
15{
16    fn ckks_neg_tmp_bytes(&self) -> usize {
17        BE::ckks_neg_tmp_bytes(self)
18    }
19
20    fn ckks_neg_into<Dst, Src>(&self, dst: &mut Dst, src: &Src, scratch: &mut ScratchArena<'_, BE>) -> Result<()>
21    where
22        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
23        Src: GLWEToBackendRef<BE> + CKKSCtBounds,
24    {
25        BE::ckks_neg_into(self, dst, src, scratch)
26    }
27
28    fn ckks_neg_assign<Dst>(&self, dst: &mut Dst) -> Result<()>
29    where
30        Dst: GLWEToBackendMut<BE> + CKKSCtBounds + SetCKKSInfos,
31    {
32        BE::ckks_neg_assign(self, dst)
33    }
34}