mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
fix remaining issues before fixing tests
This commit is contained in:
@@ -61,7 +61,7 @@ pub trait AutomorphismKeyCompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> AutomorphismKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: ModuleN + GaloisElement + VecZnxAutomorphism + GLWESwitchingKeyCompressedEncryptSk<BE>,
|
||||
Self: ModuleN + GaloisElement + VecZnxAutomorphism + GLWESwitchingKeyCompressedEncryptSk<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
@@ -99,7 +99,7 @@ where
|
||||
let (mut sk_out, scratch_1) = scratch.take_glwe_secret(self, sk.rank());
|
||||
|
||||
{
|
||||
for i in 0..res.rank_out().into(){
|
||||
for i in 0..res.rank_out().into() {
|
||||
self.vec_znx_automorphism(
|
||||
self.galois_element_inv(p),
|
||||
&mut sk_out.data.as_vec_znx_mut(),
|
||||
@@ -107,7 +107,7 @@ where
|
||||
&sk.data.as_vec_znx(),
|
||||
i,
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
self.glwe_switching_key_compressed_encrypt_sk(&mut res.key, sk, &sk_out, seed_xa, source_xe, scratch_1);
|
||||
|
||||
@@ -67,7 +67,7 @@ pub trait GGLWECompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> GGLWECompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: ModuleN
|
||||
Self: ModuleN
|
||||
+ GLWEEncryptSkInternal<BE>
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ VecZnxDftBytesOf
|
||||
|
||||
@@ -64,7 +64,7 @@ pub trait GLWESwitchingKeyCompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> GLWESwitchingKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: ModuleN + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + VecZnxSwitchRing,
|
||||
Self: ModuleN + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + VecZnxSwitchRing,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn glwe_switching_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use poulpy_hal::{
|
||||
api::{
|
||||
ModuleN, ScratchTakeBasic, SvpApplyDftToDft, SvpPPolAlloc, SvpPPolBytesOf, SvpPrepare, VecZnxBigBytesOf,
|
||||
VecZnxBigNormalize, VecZnxDftApply, VecZnxDftBytesOf, VecZnxIdftApplyTmpA, VecZnxNormalizeTmpBytes,
|
||||
ModuleN, ScratchTakeBasic, SvpApplyDftToDft, SvpPPolBytesOf, SvpPrepare, VecZnxBigBytesOf, VecZnxBigNormalize,
|
||||
VecZnxDftApply, VecZnxDftBytesOf, VecZnxIdftApplyTmpA,
|
||||
},
|
||||
layouts::{Backend, DataMut, DataRef, Module, Scratch},
|
||||
layouts::{Backend, DataMut, Module, Scratch},
|
||||
oep::{SvpPPolAllocBytesImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl},
|
||||
source::Source,
|
||||
};
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
encryption::compressed::gglwe_ksk::GLWESwitchingKeyCompressedEncryptSk,
|
||||
encryption::gglwe_tsk::TensorKeyEncryptSk,
|
||||
layouts::{
|
||||
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, GetDist, LWEInfos, Rank, TensorKey,
|
||||
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, GetDist, LWEInfos, Rank,
|
||||
compressed::{TensorKeyCompressed, TensorKeyCompressedToMut},
|
||||
},
|
||||
};
|
||||
@@ -29,23 +29,22 @@ impl TensorKeyCompressed<Vec<u8>> {
|
||||
}
|
||||
|
||||
impl<DataSelf: DataMut> TensorKeyCompressed<DataSelf> {
|
||||
pub fn encrypt_sk<DataSk: DataRef, BE: Backend>(
|
||||
pub fn encrypt_sk<S, M, BE: Backend>(
|
||||
&mut self,
|
||||
module: &Module<BE>,
|
||||
sk: &GLWESecret<DataSk>,
|
||||
module: &M,
|
||||
sk: &S,
|
||||
seed_xa: [u8; 32],
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
GLWESecret<DataSk>: GetDist,
|
||||
Module<BE>: GGLWETensorKeyCompressedEncryptSk<BE>,
|
||||
S: GLWESecretToRef + GetDist,
|
||||
M: GGLWETensorKeyCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.gglwe_tensor_key_encrypt_sk(self, sk, seed_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GGLWETensorKeyCompressedEncryptSk<BE: Backend> {
|
||||
|
||||
fn gglwe_tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
@@ -64,7 +63,7 @@ pub trait GGLWETensorKeyCompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> GGLWETensorKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: ModuleN
|
||||
Self: ModuleN
|
||||
+ GLWESwitchingKeyCompressedEncryptSk<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ VecZnxDftApply<BE>
|
||||
@@ -82,7 +81,7 @@ where
|
||||
{
|
||||
fn gglwe_tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
self.tensor_key_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
@@ -154,4 +153,4 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use poulpy_hal::{
|
||||
api::{ModuleN, VecZnxAddScalarInplace, VecZnxNormalizeInplace},
|
||||
layouts::{Backend, DataMut, DataRef, Module, ScalarZnx, ScalarZnxToRef, Scratch, ZnxZero},
|
||||
layouts::{Backend, DataMut, Module, ScalarZnx, ScalarZnxToRef, Scratch, ZnxZero},
|
||||
source::Source,
|
||||
};
|
||||
|
||||
@@ -26,22 +26,23 @@ impl GGSWCompressed<Vec<u8>> {
|
||||
|
||||
impl<DataSelf: DataMut> GGSWCompressed<DataSelf> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn encrypt_sk<DataPt: DataRef, DataSk: DataRef, BE: Backend>(
|
||||
pub fn encrypt_sk<P, S, M, BE: Backend>(
|
||||
&mut self,
|
||||
module: &Module<BE>,
|
||||
pt: &ScalarZnx<DataPt>,
|
||||
sk: &GLWESecretPrepared<DataSk, BE>,
|
||||
module: &M,
|
||||
pt: &P,
|
||||
sk: &S,
|
||||
seed_xa: [u8; 32],
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
Module<BE>: GGSWCompressedEncryptSk<BE>,
|
||||
P: ScalarZnxToRef,
|
||||
S: GLWESecretPreparedToRef<BE>,
|
||||
M: GGSWCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.ggsw_compressed_encrypt_sk(self, pt, sk, seed_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub trait GGSWCompressedEncryptSk<BE: Backend> {
|
||||
fn ggsw_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
@@ -63,11 +64,12 @@ pub trait GGSWCompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> GGSWCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: ModuleN + GLWEEncryptSkInternal<BE> + GGSWEncryptSk<BE> + VecZnxAddScalarInplace + VecZnxNormalizeInplace<BE>,
|
||||
Self: ModuleN + GLWEEncryptSkInternal<BE> + GGSWEncryptSk<BE> + VecZnxAddScalarInplace + VecZnxNormalizeInplace<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn ggsw_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where A: GGSWInfos,
|
||||
where
|
||||
A: GGSWInfos,
|
||||
{
|
||||
self.ggsw_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
@@ -139,4 +141,4 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
use poulpy_hal::{
|
||||
api::{VecZnxDftBytesOf, VecZnxNormalizeTmpBytes},
|
||||
layouts::{Backend, DataMut, DataRef, Module, Scratch},
|
||||
layouts::{Backend, DataMut, Module, Scratch},
|
||||
source::Source,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
encryption::{SIGMA, glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal}},
|
||||
encryption::{
|
||||
SIGMA,
|
||||
glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
|
||||
},
|
||||
layouts::{
|
||||
GLWE, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, LWEInfos,
|
||||
GLWEInfos, GLWEPlaintextToRef, LWEInfos,
|
||||
compressed::{GLWECompressed, GLWECompressedToMut},
|
||||
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
|
||||
prepared::GLWESecretPreparedToRef,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -25,22 +27,23 @@ impl GLWECompressed<Vec<u8>> {
|
||||
|
||||
impl<D: DataMut> GLWECompressed<D> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn encrypt_sk<DataPt: DataRef, DataSk: DataRef, BE: Backend>(
|
||||
pub fn encrypt_sk<M, P, S, BE: Backend>(
|
||||
&mut self,
|
||||
module: &Module<BE>,
|
||||
pt: &GLWEPlaintext<DataPt>,
|
||||
sk: &GLWESecretPrepared<DataSk, BE>,
|
||||
module: &M,
|
||||
pt: &P,
|
||||
sk: &S,
|
||||
seed_xa: [u8; 32],
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
Module<BE>: GLWECompressedEncryptSk<BE>,
|
||||
M: GLWECompressedEncryptSk<BE>,
|
||||
P: GLWEPlaintextToRef,
|
||||
S: GLWESecretPreparedToRef<BE>,
|
||||
{
|
||||
module.glwe_compressed_encrypt_sk(self, pt, sk, seed_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub trait GLWECompressedEncryptSk<BE: Backend> {
|
||||
fn glwe_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
@@ -62,9 +65,8 @@ pub trait GLWECompressedEncryptSk<BE: Backend> {
|
||||
|
||||
impl<BE: Backend> GLWECompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Module<BE>: GLWEEncryptSkInternal<BE> + GLWEEncryptSk<BE>,
|
||||
Self: GLWEEncryptSkInternal<BE> + GLWEEncryptSk<BE>,
|
||||
{
|
||||
|
||||
fn glwe_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GLWEInfos,
|
||||
@@ -105,4 +107,4 @@ where
|
||||
|
||||
res.seed = seed_xa;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user