mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
Traits reduction, file + structs renaming
This commit is contained in:
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
@@ -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},
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user