Traits reduction, file + structs renaming

This commit is contained in:
Pro7ech
2025-10-21 10:17:52 +02:00
parent 77b49ea530
commit db3b20b8f6
106 changed files with 1026 additions and 1108 deletions

View File

@@ -6,10 +6,7 @@ use poulpy_hal::{
use crate::{
ScratchTakeCore,
encryption::{
SIGMA,
glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
},
encryption::{GLWEEncryptSk, GLWEEncryptSkInternal, SIGMA},
layouts::{
GGLWECompressedSeedMut, GGLWEInfos, GLWEPlaintext, GLWESecretPrepared, LWEInfos,
compressed::{GGLWECompressed, GGLWECompressedToMut},
@@ -145,7 +142,7 @@ where
let mut source_xa = Source::new(seed);
let (mut tmp_pt, scrach_1) = scratch.take_glwe_pt(self, res);
let (mut tmp_pt, scrach_1) = scratch.take_glwe_plaintext(self, res);
for col_i in 0..rank_in {
for d_i in 0..dnum {
// Adds the scalar_znx_pt to the i-th limb of the vec_znx_pt

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
use crate::{
ScratchTakeCore,
encryption::{SIGMA, ggsw_ct::GGSWEncryptSk, glwe_ct::GLWEEncryptSkInternal},
encryption::{GGSWEncryptSk, GLWEEncryptSkInternal, SIGMA},
layouts::{
GGSWCompressedSeedMut, GGSWInfos, GLWEInfos, LWEInfos,
compressed::{GGSWCompressed, GGSWCompressedToMut},
@@ -107,7 +107,7 @@ where
println!("res.seed: {:?}", res.seed);
let (mut tmp_pt, scratch_1) = scratch.take_glwe_pt(self, &res.glwe_layout());
let (mut tmp_pt, scratch_1) = scratch.take_glwe_plaintext(self, &res.glwe_layout());
let mut source = Source::new(seed_xa);

View File

@@ -7,12 +7,12 @@ use poulpy_hal::{
use crate::{
GGLWECompressedEncryptSk, ScratchTakeCore,
layouts::{
GGLWECompressedSeedMut, GGLWECompressedToMut, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepare, GLWESecretPrepared,
GLWESecretPreparedAlloc, GLWESecretToRef, LWEInfos, SetAutomorphismGaloisElement, compressed::AutomorphismKeyCompressed,
GGLWECompressedSeedMut, GGLWECompressedToMut, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepared,
GLWESecretPreparedApi, GLWESecretToRef, LWEInfos, SetGaloisElement, compressed::GLWEAutomorphismKeyCompressed,
},
};
impl AutomorphismKeyCompressed<Vec<u8>> {
impl GLWEAutomorphismKeyCompressed<Vec<u8>> {
pub fn encrypt_sk_tmp_bytes<M, BE: Backend, A>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
@@ -22,7 +22,7 @@ impl AutomorphismKeyCompressed<Vec<u8>> {
}
}
impl<DataSelf: DataMut> AutomorphismKeyCompressed<DataSelf> {
impl<DataSelf: DataMut> GLWEAutomorphismKeyCompressed<DataSelf> {
#[allow(clippy::too_many_arguments)]
pub fn encrypt_sk<M, S, BE: Backend>(
&mut self,
@@ -54,18 +54,13 @@ pub trait AutomorphismKeyCompressedEncryptSk<BE: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<BE>,
) where
R: GGLWECompressedToMut + GGLWECompressedSeedMut + SetAutomorphismGaloisElement + GGLWEInfos,
R: GGLWECompressedToMut + GGLWECompressedSeedMut + SetGaloisElement + GGLWEInfos,
S: GLWESecretToRef + GLWEInfos;
}
impl<BE: Backend> AutomorphismKeyCompressedEncryptSk<BE> for Module<BE>
where
Self: ModuleN
+ GaloisElement
+ VecZnxAutomorphism
+ GGLWECompressedEncryptSk<BE>
+ GLWESecretPreparedAlloc<BE>
+ GLWESecretPrepare<BE>,
Self: ModuleN + GaloisElement + VecZnxAutomorphism + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedApi<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
@@ -87,7 +82,7 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<BE>,
) where
R: GGLWECompressedToMut + GGLWECompressedSeedMut + SetAutomorphismGaloisElement + GGLWEInfos,
R: GGLWECompressedToMut + GGLWECompressedSeedMut + SetGaloisElement + GGLWEInfos,
S: GLWESecretToRef + GLWEInfos,
{
let sk: &GLWESecret<&[u8]> = &sk.to_ref();
@@ -95,10 +90,10 @@ where
assert_eq!(res.rank_out(), res.rank_in());
assert_eq!(sk.rank(), res.rank_out());
assert!(
scratch.available() >= AutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res),
scratch.available() >= GLWEAutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res),
"scratch.available(): {} < AutomorphismKey::encrypt_sk_tmp_bytes: {}",
scratch.available(),
AutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res)
GLWEAutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res)
);
let (mut sk_out_prepared, scratch_1) = scratch.take_glwe_secret_prepared(self, sk.rank());

View File

@@ -4,10 +4,7 @@ use poulpy_hal::{
};
use crate::{
encryption::{
SIGMA,
glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
},
encryption::{GLWEEncryptSk, GLWEEncryptSkInternal, SIGMA},
layouts::{
GLWECompressedSeedMut, GLWEInfos, GLWEPlaintextToRef, LWEInfos,
compressed::{GLWECompressed, GLWECompressedToMut},

View File

@@ -5,13 +5,12 @@ use poulpy_hal::{
};
use crate::{
ScratchTakeCore,
encryption::compressed::gglwe_ct::GGLWECompressedEncryptSk,
GGLWECompressedEncryptSk, ScratchTakeCore,
layouts::{
GGLWECompressedSeedMut, GGLWECompressedToMut, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef,
GLWESwitchingKeyDegreesMut, LWEInfos,
compressed::GLWESwitchingKeyCompressed,
prepared::{GLWESecretPrepare, GLWESecretPrepared, GLWESecretPreparedAlloc},
prepared::{GLWESecretPrepared, GLWESecretPreparedApi},
},
};
@@ -65,7 +64,7 @@ pub trait GLWESwitchingKeyCompressedEncryptSk<BE: Backend> {
impl<BE: Backend> GLWESwitchingKeyCompressedEncryptSk<BE> for Module<BE>
where
Self: ModuleN + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + VecZnxSwitchRing,
Self: ModuleN + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedApi<BE> + VecZnxSwitchRing,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn glwe_switching_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize

View File

@@ -8,15 +8,14 @@ use poulpy_hal::{
};
use crate::{
GGLWECompressedEncryptSk, GetDistribution, ScratchTakeCore,
encryption::gglwe_tsk::TensorKeyEncryptSk,
GGLWECompressedEncryptSk, GetDistribution, ScratchTakeCore, TensorKeyEncryptSk,
layouts::{
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepared, GLWESecretPreparedAlloc, GLWESecretToRef, LWEInfos, Rank,
TensorKeyCompressedAtMut, compressed::TensorKeyCompressed,
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepared, GLWESecretPreparedApi, GLWESecretToRef, LWEInfos, Rank,
TensorKeyCompressedAtMut, compressed::GLWETensorKeyCompressed,
},
};
impl TensorKeyCompressed<Vec<u8>> {
impl GLWETensorKeyCompressed<Vec<u8>> {
pub fn encrypt_sk_tmp_bytes<M, A, BE: Backend>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
@@ -26,7 +25,7 @@ impl TensorKeyCompressed<Vec<u8>> {
}
}
impl<DataSelf: DataMut> TensorKeyCompressed<DataSelf> {
impl<DataSelf: DataMut> GLWETensorKeyCompressed<DataSelf> {
pub fn encrypt_sk<S, M, BE: Backend>(
&mut self,
module: &M,
@@ -73,7 +72,7 @@ where
+ SvpPPolBytesOf
+ VecZnxDftBytesOf
+ VecZnxBigBytesOf
+ GLWESecretPreparedAlloc<BE>,
+ GLWESecretPreparedApi<BE>,
Scratch<BE>: ScratchTakeBasic + ScratchTakeCore<BE>,
{
fn tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize

View File

@@ -1,13 +1,13 @@
mod gglwe_atk;
mod gglwe_ct;
mod gglwe_ksk;
mod gglwe_tsk;
mod ggsw_ct;
mod gglwe;
mod ggsw;
mod glwe_automorphism_key;
mod glwe_ct;
mod glwe_switching_key;
mod glwe_tensor_key;
pub use gglwe_atk::*;
pub use gglwe_ct::*;
pub use gglwe_ksk::*;
pub use gglwe_tsk::*;
pub use ggsw_ct::*;
pub use gglwe::*;
pub use ggsw::*;
pub use glwe_automorphism_key::*;
pub use glwe_ct::*;
pub use glwe_switching_key::*;
pub use glwe_tensor_key::*;

View File

@@ -5,8 +5,7 @@ use poulpy_hal::{
};
use crate::{
ScratchTakeCore,
encryption::glwe_ct::GLWEEncryptSk,
GLWEEncryptSk, ScratchTakeCore,
layouts::GLWEInfos,
layouts::{
GGLWE, GGLWEInfos, GGLWEToMut, GLWEPlaintext, LWEInfos,
@@ -144,7 +143,7 @@ where
let base2k: usize = res.base2k().into();
let rank_in: usize = res.rank_in().into();
let (mut tmp_pt, scrach_1) = scratch.take_glwe_pt(self, &res.glwe_layout());
let (mut tmp_pt, scrach_1) = scratch.take_glwe_plaintext(self, &res.glwe_layout());
// For each input column (i.e. rank) produces a GGLWE of rank_out+1 columns
//
// Example for ksk rank 2 to rank 3:

View File

@@ -5,8 +5,7 @@ use poulpy_hal::{
};
use crate::{
SIGMA, ScratchTakeCore,
encryption::glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
GLWEEncryptSk, GLWEEncryptSkInternal, SIGMA, ScratchTakeCore,
layouts::{
GGSW, GGSWInfos, GGSWToMut, GLWEInfos, GLWEPlaintext, LWEInfos,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
@@ -110,7 +109,7 @@ where
let dsize: usize = res.dsize().into();
let cols: usize = (rank + 1).into();
let (mut tmp_pt, scratch_1) = scratch.take_glwe_pt(self, res);
let (mut tmp_pt, scratch_1) = scratch.take_glwe_plaintext(self, res);
for row_i in 0..res.dnum().into() {
tmp_pt.data.zero();

View File

@@ -10,12 +10,12 @@ use poulpy_hal::{
};
use crate::{
ScratchTakeCore,
GetDistribution, ScratchTakeCore,
dist::Distribution,
encryption::{SIGMA, SIGMA_BOUND},
layouts::{
GLWE, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, GLWEToMut, LWEInfos,
prepared::{GLWEPublicKeyPrepared, GLWEPublicKeyPreparedToRef, GLWESecretPrepared, GLWESecretPreparedToRef},
GLWE, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, GLWEPrepared, GLWEPreparedToRef, GLWEToMut, LWEInfos,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -80,7 +80,7 @@ impl<D: DataMut> GLWE<D> {
scratch: &mut Scratch<BE>,
) where
P: GLWEPlaintextToRef + GLWEInfos,
K: GLWEPublicKeyPreparedToRef<BE>,
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos,
M: GLWEEncryptPk<BE>,
{
module.glwe_encrypt_pk(self, pt, pk, source_xu, source_xe, scratch);
@@ -94,7 +94,7 @@ impl<D: DataMut> GLWE<D> {
source_xe: &mut Source,
scratch: &mut Scratch<BE>,
) where
K: GLWEPublicKeyPreparedToRef<BE>,
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos,
M: GLWEEncryptPk<BE>,
{
module.glwe_encrypt_zero_pk(self, pk, source_xu, source_xe, scratch);
@@ -246,7 +246,7 @@ pub trait GLWEEncryptPk<BE: Backend> {
) where
R: GLWEToMut,
P: GLWEPlaintextToRef + GLWEInfos,
K: GLWEPublicKeyPreparedToRef<BE>;
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos;
fn glwe_encrypt_zero_pk<R, K>(
&self,
@@ -257,7 +257,7 @@ pub trait GLWEEncryptPk<BE: Backend> {
scratch: &mut Scratch<BE>,
) where
R: GLWEToMut,
K: GLWEPublicKeyPreparedToRef<BE>;
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos;
}
impl<BE: Backend> GLWEEncryptPk<BE> for Module<BE>
@@ -286,7 +286,7 @@ where
) where
R: GLWEToMut,
P: GLWEPlaintextToRef + GLWEInfos,
K: GLWEPublicKeyPreparedToRef<BE>,
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos,
{
self.glwe_encrypt_pk_internal(res, Some((pt, 0)), pk, source_xu, source_xe, scratch);
}
@@ -300,7 +300,7 @@ where
scratch: &mut Scratch<BE>,
) where
R: GLWEToMut,
K: GLWEPublicKeyPreparedToRef<BE>,
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos,
{
self.glwe_encrypt_pk_internal(
res,
@@ -325,7 +325,7 @@ pub(crate) trait GLWEEncryptPkInternal<BE: Backend> {
) where
R: GLWEToMut,
P: GLWEPlaintextToRef + GLWEInfos,
K: GLWEPublicKeyPreparedToRef<BE>;
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos;
}
impl<BE: Backend> GLWEEncryptPkInternal<BE> for Module<BE>
@@ -352,10 +352,9 @@ where
) where
R: GLWEToMut,
P: GLWEPlaintextToRef + GLWEInfos,
K: GLWEPublicKeyPreparedToRef<BE>,
K: GLWEPreparedToRef<BE> + GetDistribution + GLWEInfos,
{
let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();
let pk: &GLWEPublicKeyPrepared<&[u8], BE> = &pk.to_ref();
assert_eq!(res.base2k(), pk.base2k());
assert_eq!(res.n(), pk.n());
@@ -374,52 +373,56 @@ where
{
let (mut u, _) = scratch_1.take_scalar_znx(self, 1);
match pk.dist {
match pk.dist() {
Distribution::NONE => panic!(
"invalid public key: SecretDistribution::NONE, ensure it has been correctly intialized through \
Self::generate"
),
Distribution::TernaryFixed(hw) => u.fill_ternary_hw(0, hw, source_xu),
Distribution::TernaryProb(prob) => u.fill_ternary_prob(0, prob, source_xu),
Distribution::BinaryFixed(hw) => u.fill_binary_hw(0, hw, source_xu),
Distribution::BinaryProb(prob) => u.fill_binary_prob(0, prob, source_xu),
Distribution::BinaryBlock(block_size) => u.fill_binary_block(0, block_size, source_xu),
Distribution::TernaryFixed(hw) => u.fill_ternary_hw(0, *hw, source_xu),
Distribution::TernaryProb(prob) => u.fill_ternary_prob(0, *prob, source_xu),
Distribution::BinaryFixed(hw) => u.fill_binary_hw(0, *hw, source_xu),
Distribution::BinaryProb(prob) => u.fill_binary_prob(0, *prob, source_xu),
Distribution::BinaryBlock(block_size) => u.fill_binary_block(0, *block_size, source_xu),
Distribution::ZERO => {}
}
self.svp_prepare(&mut u_dft, 0, &u, 0);
}
// ct[i] = pk[i] * u + ei (+ m if col = i)
(0..cols).for_each(|i| {
let (mut ci_dft, scratch_2) = scratch_1.take_vec_znx_dft(self, 1, size_pk);
// ci_dft = DFT(u) * DFT(pk[i])
self.svp_apply_dft_to_dft(&mut ci_dft, 0, &u_dft, 0, &pk.data, i);
{
let pk: &GLWEPrepared<&[u8], BE> = &pk.to_ref();
// ci_big = u * p[i]
let mut ci_big = self.vec_znx_idft_apply_consume(ci_dft);
// ct[i] = pk[i] * u + ei (+ m if col = i)
for i in 0..cols {
let (mut ci_dft, scratch_2) = scratch_1.take_vec_znx_dft(self, 1, size_pk);
// ci_dft = DFT(u) * DFT(pk[i])
self.svp_apply_dft_to_dft(&mut ci_dft, 0, &u_dft, 0, &pk.data, i);
// ci_big = u * pk[i] + e
self.vec_znx_big_add_normal(
base2k,
&mut ci_big,
0,
pk.k().into(),
source_xe,
SIGMA,
SIGMA_BOUND,
);
// ci_big = u * p[i]
let mut ci_big = self.vec_znx_idft_apply_consume(ci_dft);
// ci_big = u * pk[i] + e + m (if col = i)
if let Some((pt, col)) = pt
&& col == i
{
self.vec_znx_big_add_small_inplace(&mut ci_big, 0, &pt.to_ref().data, 0);
// ci_big = u * pk[i] + e
self.vec_znx_big_add_normal(
base2k,
&mut ci_big,
0,
pk.k().into(),
source_xe,
SIGMA,
SIGMA_BOUND,
);
// ci_big = u * pk[i] + e + m (if col = i)
if let Some((pt, col)) = pt
&& col == i
{
self.vec_znx_big_add_small_inplace(&mut ci_big, 0, &pt.to_ref().data, 0);
}
// ct[i] = norm(ci_big)
self.vec_znx_big_normalize(base2k, &mut res.data, i, base2k, &ci_big, 0, scratch_2);
}
// ct[i] = norm(ci_big)
self.vec_znx_big_normalize(base2k, &mut res.data, i, base2k, &ci_big, 0, scratch_2);
});
}
}
}

View File

@@ -7,8 +7,8 @@ use poulpy_hal::{
use crate::{
GGLWEEncryptSk, ScratchTakeCore,
layouts::{
AutomorphismKey, GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWEInfos, GLWESecret, GLWESecretPrepare, GLWESecretPrepared,
GLWESecretPreparedAlloc, GLWESecretToRef, LWEInfos, SetAutomorphismGaloisElement,
AutomorphismKey, GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWEInfos, GLWESecret, GLWESecretPrepared, GLWESecretPreparedApi,
GLWESecretToRef, LWEInfos, SetGaloisElement,
},
};
@@ -64,18 +64,13 @@ pub trait AutomorphismKeyEncryptSk<BE: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<BE>,
) where
R: GGLWEToMut + SetAutomorphismGaloisElement + GGLWEInfos,
R: GGLWEToMut + SetGaloisElement + GGLWEInfos,
S: GLWESecretToRef;
}
impl<BE: Backend> AutomorphismKeyEncryptSk<BE> for Module<BE>
where
Self: GGLWEEncryptSk<BE>
+ VecZnxAutomorphism
+ GaloisElement
+ SvpPPolBytesOf
+ GLWESecretPrepare<BE>
+ GLWESecretPreparedAlloc<BE>,
Self: GGLWEEncryptSk<BE> + VecZnxAutomorphism + GaloisElement + SvpPPolBytesOf + GLWESecretPreparedApi<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
@@ -102,7 +97,7 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<BE>,
) where
R: GGLWEToMut + SetAutomorphismGaloisElement + GGLWEInfos,
R: GGLWEToMut + SetGaloisElement + GGLWEInfos,
S: GLWESecretToRef,
{
let sk: &GLWESecret<&[u8]> = &sk.to_ref();

View File

@@ -5,10 +5,9 @@ use poulpy_hal::{
};
use crate::{
Distribution, GetDistribution, GetDistributionMut, ScratchTakeCore,
encryption::glwe_ct::GLWEEncryptSk,
Distribution, GLWEEncryptSk, GetDistribution, GetDistributionMut, ScratchTakeCore,
layouts::{
GLWE, GLWEPublicKey, GLWEPublicKeyToMut, LWEInfos,
GLWE, GLWEInfos, GLWEPublicKey, GLWEToMut,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -26,7 +25,7 @@ impl<D: DataMut> GLWEPublicKey<D> {
pub trait GLWEPublicKeyGenerate<BE: Backend> {
fn glwe_public_key_generate<R, S>(&self, res: &mut R, sk: &S, source_xa: &mut Source, source_xe: &mut Source)
where
R: GLWEPublicKeyToMut + GetDistributionMut,
R: GLWEToMut + GetDistributionMut + GLWEInfos,
S: GLWESecretPreparedToRef<BE> + GetDistribution;
}
@@ -38,11 +37,10 @@ where
{
fn glwe_public_key_generate<R, S>(&self, res: &mut R, sk: &S, source_xa: &mut Source, source_xe: &mut Source)
where
R: GLWEPublicKeyToMut + GetDistributionMut,
R: GLWEToMut + GetDistributionMut + GLWEInfos,
S: GLWESecretPreparedToRef<BE> + GetDistribution,
{
{
let res: &mut GLWEPublicKey<&mut [u8]> = &mut res.to_mut();
let sk: &GLWESecretPrepared<&[u8], BE> = &sk.to_ref();
assert_eq!(res.n(), self.n() as u32);

View File

@@ -6,10 +6,10 @@ use poulpy_hal::{
use crate::{
ScratchTakeCore,
encryption::gglwe_ct::GGLWEEncryptSk,
encryption::gglwe::GGLWEEncryptSk,
layouts::{
GGLWEInfos, GGLWEToMut, GLWEInfos, GLWESecret, GLWESecretToRef, GLWESwitchingKey, GLWESwitchingKeyDegreesMut, LWEInfos,
prepared::GLWESecretPreparedAlloc,
prepared::GLWESecretPreparedApi,
},
};
@@ -71,7 +71,7 @@ pub trait GLWESwitchingKeyEncryptSk<BE: Backend> {
impl<BE: Backend> GLWESwitchingKeyEncryptSk<BE> for Module<BE>
where
Self: ModuleN + GGLWEEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + VecZnxSwitchRing + SvpPrepare<BE>,
Self: ModuleN + GGLWEEncryptSk<BE> + GLWESecretPreparedApi<BE> + VecZnxSwitchRing + SvpPrepare<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn glwe_switching_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize

View File

@@ -11,7 +11,7 @@ use crate::{
GGLWEEncryptSk, GetDistribution, ScratchTakeCore,
layouts::{
GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, Rank, TensorKey, TensorKeyToMut,
prepared::{GLWESecretPrepare, GLWESecretPrepared, GLWESecretPreparedAlloc},
prepared::{GLWESecretPrepared, GLWESecretPreparedApi},
},
};
@@ -65,8 +65,7 @@ where
+ GGLWEEncryptSk<BE>
+ VecZnxDftBytesOf
+ VecZnxBigBytesOf
+ GLWESecretPreparedAlloc<BE>
+ GLWESecretPrepare<BE>
+ GLWESecretPreparedApi<BE>
+ VecZnxDftApply<BE>
+ SvpApplyDftToDft<BE>
+ VecZnxIdftApplyTmpA<BE>

View File

@@ -7,9 +7,9 @@ use poulpy_hal::{
use crate::{
GGLWEEncryptSk, ScratchTakeCore,
layouts::{
GGLWE, GGLWEInfos, GGLWEToMut, GLWESecret, GLWESecretPrepare, GLWESecretToRef, GLWEToLWESwitchingKey, LWEInfos,
LWESecret, LWESecretToRef, Rank,
prepared::{GLWESecretPrepared, GLWESecretPreparedAlloc},
GGLWE, GGLWEInfos, GGLWEToMut, GLWESecret, GLWESecretToRef, GLWEToLWESwitchingKey, LWEInfos, LWESecret, LWESecretToRef,
Rank,
prepared::{GLWESecretPrepared, GLWESecretPreparedApi},
},
};
@@ -65,10 +65,9 @@ impl<BE: Backend> GLWEToLWESwitchingKeyEncryptSk<BE> for Module<BE>
where
Self: ModuleN
+ GGLWEEncryptSk<BE>
+ GLWESecretPreparedAlloc<BE>
+ GLWESecretPreparedApi<BE>
+ VecZnxAutomorphismInplace<BE>
+ VecZnxAutomorphismInplaceTmpBytes
+ GLWESecretPrepare<BE>,
+ VecZnxAutomorphismInplaceTmpBytes,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn glwe_to_lwe_switching_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize

View File

@@ -6,11 +6,11 @@ use poulpy_hal::{
use crate::{
ScratchTakeCore,
encryption::gglwe_ksk::GLWESwitchingKeyEncryptSk,
encryption::glwe_switching_key::GLWESwitchingKeyEncryptSk,
layouts::{
GGLWEInfos, GGLWEToMut, GLWESecret, GLWESwitchingKey, GLWESwitchingKeyDegreesMut, LWEInfos, LWESecret, LWESecretToRef,
LWESwitchingKey, Rank,
prepared::{GLWESecretPrepared, GLWESecretPreparedAlloc},
prepared::{GLWESecretPrepared, GLWESecretPreparedApi},
},
};
@@ -63,7 +63,7 @@ pub trait LWESwitchingKeyEncrypt<BE: Backend> {
impl<BE: Backend> LWESwitchingKeyEncrypt<BE> for Module<BE>
where
Self: ModuleN + GLWESwitchingKeyEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + VecZnxAutomorphismInplace<BE>,
Self: ModuleN + GLWESwitchingKeyEncryptSk<BE> + GLWESecretPreparedApi<BE> + VecZnxAutomorphismInplace<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
{
fn lwe_switching_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize

View File

@@ -7,7 +7,7 @@ use poulpy_hal::{
use crate::{
GGLWEEncryptSk, ScratchTakeCore,
layouts::{
GGLWE, GGLWEInfos, GGLWEToMut, GLWESecret, GLWESecretPreparedAlloc, GLWESecretPreparedToRef, LWEInfos, LWESecret,
GGLWE, GGLWEInfos, GGLWEToMut, GLWESecret, GLWESecretPreparedApi, GLWESecretPreparedToRef, LWEInfos, LWESecret,
LWESecretToRef, LWEToGLWESwitchingKey, Rank,
},
};
@@ -65,7 +65,7 @@ where
Self: ModuleN
+ GGLWEEncryptSk<BE>
+ VecZnxAutomorphismInplace<BE>
+ GLWESecretPreparedAlloc<BE>
+ GLWESecretPreparedApi<BE>
+ VecZnxAutomorphismInplaceTmpBytes,
Scratch<BE>: ScratchTakeCore<BE>,
{

View File

@@ -1,28 +1,28 @@
mod compressed;
mod gglwe_atk;
mod gglwe_ct;
mod gglwe_ksk;
mod gglwe_tsk;
mod ggsw_ct;
mod glwe_ct;
mod glwe_pk;
mod glwe_to_lwe_ksk;
mod lwe_ct;
mod lwe_ksk;
mod lwe_to_glwe_ksk;
mod gglwe;
mod ggsw;
mod glwe;
mod glwe_automorphism_key;
mod glwe_public_key;
mod glwe_switching_key;
mod glwe_tensor_key;
mod glwe_to_lwe_switching_key;
mod lwe;
mod lwe_switching_key;
mod lwe_to_glwe_switching_key;
pub use compressed::*;
pub use gglwe_atk::*;
pub use gglwe_ct::*;
pub use gglwe_ksk::*;
pub use gglwe_tsk::*;
pub use ggsw_ct::*;
pub use glwe_ct::*;
pub use glwe_pk::*;
pub use glwe_to_lwe_ksk::*;
pub use lwe_ct::*;
pub use lwe_ksk::*;
pub use lwe_to_glwe_ksk::*;
pub use gglwe::*;
pub use ggsw::*;
pub use glwe::*;
pub use glwe_automorphism_key::*;
pub use glwe_public_key::*;
pub use glwe_switching_key::*;
pub use glwe_tensor_key::*;
pub use glwe_to_lwe_switching_key::*;
pub use lwe::*;
pub use lwe_switching_key::*;
pub use lwe_to_glwe_switching_key::*;
pub const SIGMA: f64 = 3.2;
pub(crate) const SIGMA_BOUND: f64 = 6.0 * SIGMA;