mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Traits reduction, file + structs renaming
This commit is contained in:
@@ -5,12 +5,12 @@ use poulpy_hal::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
AutomorphismKeyAutomorphism, AutomorphismKeyEncryptSk, GLWEDecrypt, ScratchTakeCore,
|
||||
AutomorphismKeyEncryptSk, GLWEAutomorphismKeyAutomorphism, GLWEDecrypt, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyLayout, AutomorphismKeyPrepare, AutomorphismKeyPreparedAlloc, GGLWEInfos, GLWEPlaintext,
|
||||
GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
AutomorphismKey, AutomorphismKeyLayout, GGLWEInfos, GLWEAutomorphismKeyPreparedApi, GLWEPlaintext, GLWESecret,
|
||||
GLWESecretPreparedApi,
|
||||
prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::log2_std_noise_gglwe_product,
|
||||
};
|
||||
@@ -19,14 +19,12 @@ use crate::{
|
||||
pub fn test_gglwe_automorphism_key_automorphism<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyAutomorphism<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GLWEAutomorphismKeyAutomorphism<BE>
|
||||
+ VecZnxAutomorphism
|
||||
+ GaloisElement
|
||||
+ VecZnxSubScalarInplace
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWEDecrypt<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
@@ -117,8 +115,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut auto_key_apply_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_apply_infos);
|
||||
let mut auto_key_apply_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_apply_infos);
|
||||
|
||||
auto_key_apply_prepared.prepare(module, &auto_key_apply, scratch.borrow());
|
||||
|
||||
@@ -190,14 +188,12 @@ where
|
||||
pub fn test_gglwe_automorphism_key_automorphism_inplace<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyAutomorphism<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GLWEAutomorphismKeyAutomorphism<BE>
|
||||
+ VecZnxAutomorphism
|
||||
+ GaloisElement
|
||||
+ VecZnxSubScalarInplace
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWEDecrypt<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
@@ -271,8 +267,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut auto_key_apply_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_apply_layout);
|
||||
let mut auto_key_apply_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_apply_layout);
|
||||
|
||||
auto_key_apply_prepared.prepare(module, &auto_key_apply, scratch.borrow());
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ use crate::{
|
||||
AutomorphismKeyEncryptSk, GGSWAutomorphism, GGSWEncryptSk, GGSWNoise, ScratchTakeCore, TensorKeyEncryptSk,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyPrepare, AutomorphismKeyPreparedAlloc, GGSW, GGSWLayout, GLWESecret, GLWESecretPrepare,
|
||||
GLWESecretPreparedAlloc, TensorKey, TensorKeyLayout, TensorKeyPrepare, TensorKeyPreparedAlloc,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared, TensorKeyPrepared},
|
||||
AutomorphismKey, GGSW, GGSWLayout, GLWEAutomorphismKeyPreparedApi, GLWESecret, GLWESecretPreparedApi, TensorKey,
|
||||
TensorKeyLayout, TensorKeyPreparedAlloc,
|
||||
prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared, TensorKeyPrepared},
|
||||
},
|
||||
noise::noise_ggsw_keyswitch,
|
||||
};
|
||||
@@ -19,14 +19,11 @@ pub fn test_ggsw_automorphism<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GGSWAutomorphism<BE>
|
||||
+ TensorKeyPrepare<BE>
|
||||
+ TensorKeyPreparedAlloc<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxAutomorphismInplace<BE>
|
||||
+ GGSWNoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -137,8 +134,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut auto_key_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_layout);
|
||||
let mut auto_key_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_layout);
|
||||
auto_key_prepared.prepare(module, &auto_key, scratch.borrow());
|
||||
|
||||
let mut tsk_prepared: TensorKeyPrepared<Vec<u8>, BE> =
|
||||
@@ -181,14 +178,11 @@ pub fn test_ggsw_automorphism_inplace<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GGSWAutomorphism<BE>
|
||||
+ TensorKeyPrepare<BE>
|
||||
+ TensorKeyPreparedAlloc<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxAutomorphismInplace<BE>
|
||||
+ GGSWNoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -286,8 +280,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut auto_key_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_layout);
|
||||
let mut auto_key_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &auto_key_layout);
|
||||
auto_key_prepared.prepare(module, &auto_key, scratch.borrow());
|
||||
|
||||
let mut tsk_prepared: TensorKeyPrepared<Vec<u8>, BE> =
|
||||
|
||||
@@ -8,9 +8,9 @@ use crate::{
|
||||
AutomorphismKeyEncryptSk, GLWEAutomorphism, GLWEDecrypt, GLWEEncryptSk, GLWENoise, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyLayout, AutomorphismKeyPrepare, AutomorphismKeyPreparedAlloc, GLWE, GLWELayout,
|
||||
GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
AutomorphismKey, AutomorphismKeyLayout, GLWE, GLWEAutomorphismKeyPreparedApi, GLWELayout, GLWEPlaintext, GLWESecret,
|
||||
GLWESecretPreparedApi,
|
||||
prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::log2_std_noise_gglwe_product,
|
||||
};
|
||||
@@ -18,14 +18,12 @@ use crate::{
|
||||
pub fn test_glwe_automorphism<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWEAutomorphism<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GLWENoise<BE>
|
||||
+ VecZnxAutomorphismInplace<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -108,8 +106,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut autokey_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &autokey_infos);
|
||||
let mut autokey_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &autokey_infos);
|
||||
autokey_prepared.prepare(module, &autokey, scratch.borrow());
|
||||
|
||||
ct_out.automorphism(module, &ct_in, &autokey_prepared, scratch.borrow());
|
||||
@@ -138,14 +136,12 @@ where
|
||||
pub fn test_glwe_automorphism_inplace<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWEAutomorphism<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GLWENoise<BE>
|
||||
+ VecZnxAutomorphismInplace<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -219,8 +215,8 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut autokey_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
AutomorphismKeyPrepared::alloc_from_infos(module, &autokey);
|
||||
let mut autokey_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &autokey);
|
||||
autokey_prepared.prepare(module, &autokey, scratch.borrow());
|
||||
|
||||
ct.automorphism_inplace(module, &autokey_prepared, scratch.borrow());
|
||||
|
||||
@@ -8,10 +8,9 @@ use crate::{
|
||||
GLWEDecrypt, GLWEEncryptSk, GLWEFromLWE, GLWEToLWESwitchingKeyEncryptSk, LWEDecrypt, LWEEncryptSk,
|
||||
LWEToGLWESwitchingKeyEncryptSk, ScratchTakeCore,
|
||||
layouts::{
|
||||
Base2K, Degree, Dnum, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
GLWEToLWEKeyLayout, GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyPrepare, GLWEToLWESwitchingKeyPreparedAlloc, LWE,
|
||||
LWELayout, LWEPlaintext, LWESecret, LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyLayout, LWEToGLWESwitchingKeyPrepare,
|
||||
LWEToGLWESwitchingKeyPreparedAlloc, Rank, TorusPrecision,
|
||||
Base2K, Degree, Dnum, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPreparedApi, GLWEToLWEKeyLayout,
|
||||
GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyPreparedAlloc, LWE, LWELayout, LWEPlaintext, LWESecret,
|
||||
LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyLayout, LWEToGLWESwitchingKeyPreparedAlloc, Rank, TorusPrecision,
|
||||
prepared::{GLWESecretPrepared, GLWEToLWESwitchingKeyPrepared, LWEToGLWESwitchingKeyPrepared},
|
||||
},
|
||||
};
|
||||
@@ -21,11 +20,9 @@ where
|
||||
Module<BE>: GLWEFromLWE<BE>
|
||||
+ LWEToGLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ LWEEncryptSk<BE>
|
||||
+ LWEToGLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ LWEToGLWESwitchingKeyPrepare<BE>,
|
||||
+ LWEToGLWESwitchingKeyPreparedAlloc<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -115,10 +112,8 @@ where
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ LWEDecrypt<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWEToLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWEToLWESwitchingKeyPrepare<BE>
|
||||
+ GLWEToLWESwitchingKeyPreparedAlloc<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
|
||||
@@ -9,8 +9,8 @@ use crate::{
|
||||
GLWESwitchingKeyEncryptSk, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyDecompress, AutomorphismKeyLayout, GLWEInfos, GLWESecret, GLWESecretPrepare,
|
||||
GLWESecretPreparedAlloc, GLWESwitchingKeyDecompress, compressed::AutomorphismKeyCompressed, prepared::GLWESecretPrepared,
|
||||
AutomorphismKey, AutomorphismKeyDecompress, AutomorphismKeyLayout, GLWEInfos, GLWESecret, GLWESecretPreparedApi,
|
||||
GLWESwitchingKeyDecompress, compressed::GLWEAutomorphismKeyCompressed, prepared::GLWESecretPrepared,
|
||||
},
|
||||
noise::GGLWENoise,
|
||||
};
|
||||
@@ -19,8 +19,7 @@ pub fn test_gglwe_automorphism_key_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: AutomorphismKeyEncryptSk<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWESwitchingKeyCompressedEncryptSk<BE>
|
||||
+ GLWESwitchingKeyDecompress
|
||||
@@ -92,8 +91,7 @@ pub fn test_gglwe_automorphism_key_compressed_encrypt_sk<BE: Backend>(module: &M
|
||||
where
|
||||
Module<BE>: AutomorphismKeyCompressedEncryptSk<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWESwitchingKeyCompressedEncryptSk<BE>
|
||||
+ AutomorphismKeyDecompress
|
||||
@@ -120,12 +118,13 @@ where
|
||||
rank: rank.into(),
|
||||
};
|
||||
|
||||
let mut atk_compressed: AutomorphismKeyCompressed<Vec<u8>> = AutomorphismKeyCompressed::alloc_from_infos(&atk_infos);
|
||||
let mut atk_compressed: GLWEAutomorphismKeyCompressed<Vec<u8>> =
|
||||
GLWEAutomorphismKeyCompressed::alloc_from_infos(&atk_infos);
|
||||
|
||||
let mut source_xs: Source = Source::new([0u8; 32]);
|
||||
let mut source_xe: Source = Source::new([0u8; 32]);
|
||||
|
||||
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(AutomorphismKeyCompressed::encrypt_sk_tmp_bytes(
|
||||
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(GLWEAutomorphismKeyCompressed::encrypt_sk_tmp_bytes(
|
||||
module, &atk_infos,
|
||||
));
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@ use crate::{
|
||||
decryption::GLWEDecrypt,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGLWELayout, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, GLWESwitchingKey, GLWESwitchingKeyCompressed,
|
||||
GLWESwitchingKeyDecompress,
|
||||
prepared::{GGLWEPrepare, GGLWEPreparedAlloc, GLWESecretPrepared},
|
||||
GGLWELayout, GLWESecret, GLWESecretPreparedApi, GLWESwitchingKey, GLWESwitchingKeyCompressed, GLWESwitchingKeyDecompress,
|
||||
prepared::{GGLWEPreparedAlloc, GLWESecretPrepared},
|
||||
},
|
||||
noise::GGLWENoise,
|
||||
};
|
||||
@@ -19,12 +18,10 @@ use crate::{
|
||||
pub fn test_gglwe_switching_key_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGLWEEncryptSk<BE>
|
||||
+ GGLWEPrepare<BE>
|
||||
+ GGLWEPreparedAlloc<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GGLWENoise<BE>,
|
||||
@@ -86,12 +83,10 @@ where
|
||||
pub fn test_gglwe_switching_key_compressed_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGLWEEncryptSk<BE>
|
||||
+ GGLWEPrepare<BE>
|
||||
+ GGLWEPreparedAlloc<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWESwitchingKeyCompressedEncryptSk<BE>
|
||||
+ GLWESwitchingKeyDecompress
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
GGSWCompressedEncryptSk, GGSWEncryptSk, GGSWNoise, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGSW, GGSWDecompress, GGSWLayout, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, compressed::GGSWCompressed,
|
||||
GGSW, GGSWDecompress, GGSWLayout, GLWESecret, GLWESecretPreparedApi, compressed::GGSWCompressed,
|
||||
prepared::GLWESecretPrepared,
|
||||
},
|
||||
};
|
||||
@@ -17,7 +17,7 @@ pub fn test_ggsw_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
Module<BE>: GGSWEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + GGSWNoise<BE>,
|
||||
Module<BE>: GGSWEncryptSk<BE> + GLWESecretPreparedApi<BE> + GGSWNoise<BE>,
|
||||
{
|
||||
let base2k: usize = 12;
|
||||
let k: usize = 54;
|
||||
@@ -74,8 +74,7 @@ pub fn test_ggsw_compressed_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
Module<BE>:
|
||||
GGSWCompressedEncryptSk<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + GGSWNoise<BE> + GGSWDecompress,
|
||||
Module<BE>: GGSWCompressedEncryptSk<BE> + GLWESecretPreparedApi<BE> + GGSWNoise<BE> + GGSWDecompress,
|
||||
{
|
||||
let base2k: usize = 12;
|
||||
let k: usize = 54;
|
||||
|
||||
@@ -9,8 +9,8 @@ use crate::{
|
||||
decryption::GLWEDecrypt,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWEPublicKey, GLWEPublicKeyPrepare, GLWEPublicKeyPreparedAlloc,
|
||||
GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, LWEInfos,
|
||||
GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWEPublicKey, GLWEPublicKeyPreparedAlloc, GLWESecret,
|
||||
GLWESecretPreparedApi, LWEInfos,
|
||||
compressed::GLWECompressed,
|
||||
prepared::{GLWEPublicKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
@@ -18,8 +18,7 @@ use crate::{
|
||||
|
||||
pub fn test_glwe_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>:
|
||||
GLWEEncryptSk<BE> + GLWEDecrypt<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + VecZnxFillUniform + GLWESub,
|
||||
Module<BE>: GLWEEncryptSk<BE> + GLWEDecrypt<BE> + GLWESecretPreparedApi<BE> + VecZnxFillUniform + GLWESub,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -84,12 +83,7 @@ where
|
||||
|
||||
pub fn test_glwe_compressed_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWECompressedEncryptSk<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWESub,
|
||||
Module<BE>: GLWECompressedEncryptSk<BE> + GLWEDecrypt<BE> + GLWESecretPreparedApi<BE> + VecZnxFillUniform + GLWESub,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -166,8 +160,7 @@ where
|
||||
|
||||
pub fn test_glwe_encrypt_zero_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>:
|
||||
GLWEEncryptSk<BE> + GLWEDecrypt<BE> + GLWESecretPreparedAlloc<BE> + GLWESecretPrepare<BE> + VecZnxFillUniform + GLWESub,
|
||||
Module<BE>: GLWEEncryptSk<BE> + GLWEDecrypt<BE> + GLWESecretPreparedApi<BE> + VecZnxFillUniform + GLWESub,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -217,12 +210,10 @@ where
|
||||
pub fn test_glwe_encrypt_pk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptPk<BE>
|
||||
+ GLWEPublicKeyPrepare<BE>
|
||||
+ GLWEPublicKeyPreparedAlloc<BE>
|
||||
+ GLWEPublicKeyGenerate<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWESub,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
|
||||
@@ -13,16 +13,15 @@ use crate::{
|
||||
decryption::GLWEDecrypt,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
Dsize, GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, TensorKey, TensorKeyCompressed,
|
||||
TensorKeyLayout, prepared::GLWESecretPrepared,
|
||||
Dsize, GLWEPlaintext, GLWESecret, GLWESecretPreparedApi, GLWETensorKeyCompressed, TensorKey, TensorKeyLayout,
|
||||
prepared::GLWESecretPrepared,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn test_gglwe_tensor_key_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: TensorKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ VecZnxDftAlloc<BE>
|
||||
+ VecZnxBigAlloc<BE>
|
||||
@@ -113,8 +112,7 @@ where
|
||||
pub fn test_gglwe_tensor_key_compressed_encrypt_sk<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: TensorKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GGLWETensorKeyCompressedEncryptSk<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ VecZnxDftAlloc<BE>
|
||||
@@ -144,12 +142,13 @@ where
|
||||
rank: rank.into(),
|
||||
};
|
||||
|
||||
let mut tensor_key_compressed: TensorKeyCompressed<Vec<u8>> = TensorKeyCompressed::alloc_from_infos(&tensor_key_infos);
|
||||
let mut tensor_key_compressed: GLWETensorKeyCompressed<Vec<u8>> =
|
||||
GLWETensorKeyCompressed::alloc_from_infos(&tensor_key_infos);
|
||||
|
||||
let mut source_xs: Source = Source::new([0u8; 32]);
|
||||
let mut source_xe: Source = Source::new([0u8; 32]);
|
||||
|
||||
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(TensorKeyCompressed::encrypt_sk_tmp_bytes(
|
||||
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(GLWETensorKeyCompressed::encrypt_sk_tmp_bytes(
|
||||
module,
|
||||
&tensor_key_infos,
|
||||
));
|
||||
|
||||
@@ -8,8 +8,7 @@ use crate::{
|
||||
GGLWEExternalProduct, GGLWENoise, GGSWEncryptSk, GLWESwitchingKeyEncryptSk, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGSW, GGSWLayout, GGSWPrepare, GGSWPreparedAlloc, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
GGSW, GGSWLayout, GGSWPreparedAlloc, GLWESecret, GLWESecretPreparedApi, GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
prepared::{GGSWPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::noise_ggsw_product,
|
||||
@@ -21,10 +20,8 @@ where
|
||||
Module<BE>: GGLWEExternalProduct<BE>
|
||||
+ GGSWEncryptSk<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ GGLWENoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -172,10 +169,8 @@ where
|
||||
Module<BE>: GGLWEExternalProduct<BE>
|
||||
+ GGSWEncryptSk<BE>
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ GGLWENoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
GGSWEncryptSk, GGSWExternalProduct, GGSWNoise, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGSW, GGSWLayout, GGSWPrepare, GGSWPreparedAlloc, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
GGSW, GGSWLayout, GGSWPreparedAlloc, GLWESecret, GLWESecretPreparedApi,
|
||||
prepared::{GGSWPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::noise_ggsw_product,
|
||||
@@ -19,9 +19,7 @@ pub fn test_ggsw_external_product<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ GGSWExternalProduct<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GGSWNoise<BE>,
|
||||
@@ -155,9 +153,7 @@ pub fn test_ggsw_external_product_inplace<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ GGSWExternalProduct<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GGSWNoise<BE>,
|
||||
|
||||
@@ -8,8 +8,7 @@ use crate::{
|
||||
GGSWEncryptSk, GLWEEncryptSk, GLWEExternalProduct, GLWENoise, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGSW, GGSWLayout, GGSWPrepare, GGSWPreparedAlloc, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPrepare,
|
||||
GLWESecretPreparedAlloc,
|
||||
GGSW, GGSWLayout, GGSWPreparedAlloc, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPreparedApi,
|
||||
prepared::{GGSWPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::noise_ggsw_product,
|
||||
@@ -19,15 +18,13 @@ use crate::{
|
||||
pub fn test_glwe_external_product<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWEExternalProduct<BE>
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ GLWENoise<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>,
|
||||
+ GLWESecretPreparedApi<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -151,15 +148,13 @@ where
|
||||
pub fn test_glwe_external_product_inplace<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GGSWEncryptSk<BE>
|
||||
+ GGSWPrepare<BE>
|
||||
+ GGSWPreparedAlloc<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWEExternalProduct<BE>
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ GLWENoise<BE>
|
||||
+ VecZnxRotateInplace<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>,
|
||||
+ GLWESecretPreparedApi<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
|
||||
@@ -8,8 +8,7 @@ use crate::{
|
||||
GGLWEKeyswitch, GGLWENoise, GLWESwitchingKeyEncryptSk, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
GLWESwitchingKeyPrepare, GLWESwitchingKeyPreparedAlloc,
|
||||
GLWESecret, GLWESecretPreparedApi, GLWESwitchingKey, GLWESwitchingKeyLayout, GLWESwitchingKeyPreparedAlloc,
|
||||
prepared::{GLWESecretPrepared, GLWESwitchingKeyPrepared},
|
||||
},
|
||||
noise::log2_std_noise_gglwe_product,
|
||||
@@ -19,10 +18,8 @@ pub fn test_gglwe_switching_key_keyswitch<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GGLWENoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
@@ -165,9 +162,7 @@ pub fn test_gglwe_switching_key_keyswitch_inplace<BE: Backend>(module: &Module<B
|
||||
where
|
||||
Module<BE>: GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GGLWEKeyswitch<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GGLWENoise<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
|
||||
@@ -8,9 +8,8 @@ use crate::{
|
||||
GGSWEncryptSk, GGSWKeyswitch, GGSWNoise, GLWESwitchingKeyEncryptSk, ScratchTakeCore, TensorKeyEncryptSk,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GGSW, GGSWLayout, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
GLWESwitchingKeyPrepare, GLWESwitchingKeyPreparedAlloc, TensorKey, TensorKeyLayout, TensorKeyPrepare,
|
||||
TensorKeyPreparedAlloc,
|
||||
GGSW, GGSWLayout, GLWESecret, GLWESecretPreparedApi, GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
GLWESwitchingKeyPreparedAlloc, TensorKey, TensorKeyLayout, TensorKeyPreparedAlloc,
|
||||
prepared::{GLWESecretPrepared, GLWESwitchingKeyPrepared, TensorKeyPrepared},
|
||||
},
|
||||
noise::noise_ggsw_keyswitch,
|
||||
@@ -23,13 +22,10 @@ where
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ GGSWKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ TensorKeyPreparedAlloc<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ GGSWNoise<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ TensorKeyPrepare<BE>,
|
||||
+ GGSWNoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
@@ -191,13 +187,10 @@ where
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ GGSWKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ TensorKeyPreparedAlloc<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ GGSWNoise<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ TensorKeyPrepare<BE>,
|
||||
+ GGSWNoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
|
||||
@@ -8,8 +8,8 @@ use crate::{
|
||||
GLWEEncryptSk, GLWEKeyswitch, GLWENoise, GLWESwitchingKeyEncryptSk, ScratchTakeCore,
|
||||
encryption::SIGMA,
|
||||
layouts::{
|
||||
GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, GLWESwitchingKey,
|
||||
GLWESwitchingKeyLayout, GLWESwitchingKeyPrepare, GLWESwitchingKeyPreparedAlloc,
|
||||
GLWE, GLWELayout, GLWEPlaintext, GLWESecret, GLWESecretPreparedApi, GLWESwitchingKey, GLWESwitchingKeyLayout,
|
||||
GLWESwitchingKeyPreparedAlloc,
|
||||
prepared::{GLWESecretPrepared, GLWESwitchingKeyPrepared},
|
||||
},
|
||||
noise::log2_std_noise_gglwe_product,
|
||||
@@ -22,9 +22,7 @@ where
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ GLWEKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ GLWENoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -145,9 +143,7 @@ where
|
||||
+ GLWESwitchingKeyEncryptSk<BE>
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ GLWEKeyswitch<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESwitchingKeyPrepare<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESwitchingKeyPreparedAlloc<BE>
|
||||
+ GLWENoise<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
|
||||
@@ -7,19 +7,15 @@ use poulpy_hal::{
|
||||
use crate::{
|
||||
LWEDecrypt, LWEEncryptSk, LWEKeySwitch, LWESwitchingKeyEncrypt, ScratchTakeCore,
|
||||
layouts::{
|
||||
LWE, LWELayout, LWEPlaintext, LWESecret, LWESwitchingKey, LWESwitchingKeyLayout, LWESwitchingKeyPrepare,
|
||||
LWESwitchingKeyPreparedAlloc, prepared::LWESwitchingKeyPrepared,
|
||||
LWE, LWELayout, LWEPlaintext, LWESecret, LWESwitchingKey, LWESwitchingKeyLayout, LWESwitchingKeyPreparedAlloc,
|
||||
prepared::LWESwitchingKeyPrepared,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn test_lwe_keyswitch<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: LWEKeySwitch<BE>
|
||||
+ LWESwitchingKeyEncrypt<BE>
|
||||
+ LWEEncryptSk<BE>
|
||||
+ LWESwitchingKeyPreparedAlloc<BE>
|
||||
+ LWEDecrypt<BE>
|
||||
+ LWESwitchingKeyPrepare<BE>,
|
||||
Module<BE>:
|
||||
LWEKeySwitch<BE> + LWESwitchingKeyEncrypt<BE> + LWEEncryptSk<BE> + LWESwitchingKeyPreparedAlloc<BE> + LWEDecrypt<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchAvailable + ScratchTakeCore<BE>,
|
||||
{
|
||||
|
||||
@@ -9,9 +9,9 @@ use poulpy_hal::{
|
||||
use crate::{
|
||||
AutomorphismKeyEncryptSk, GLWEDecrypt, GLWEEncryptSk, GLWEPacker, GLWEPacking, GLWERotate, GLWESub, ScratchTakeCore,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyLayout, AutomorphismKeyPrepare, AutomorphismKeyPreparedAlloc, GLWE, GLWELayout,
|
||||
GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
AutomorphismKey, AutomorphismKeyLayout, GLWE, GLWEAutomorphismKeyPreparedApi, GLWELayout, GLWEPlaintext, GLWESecret,
|
||||
GLWESecretPreparedApi,
|
||||
prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -19,11 +19,9 @@ pub fn test_glwe_packing<BE: Backend>(module: &Module<BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptSk<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ GLWEPacking<BE>
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ GLWESub
|
||||
+ GLWEDecrypt<BE>
|
||||
+ GLWERotate<BE>,
|
||||
@@ -82,7 +80,7 @@ where
|
||||
|
||||
let gal_els: Vec<i64> = GLWEPacker::galois_elements(module);
|
||||
|
||||
let mut auto_keys: HashMap<i64, AutomorphismKeyPrepared<Vec<u8>, BE>> = HashMap::new();
|
||||
let mut auto_keys: HashMap<i64, GLWEAutomorphismKeyPrepared<Vec<u8>, BE>> = HashMap::new();
|
||||
let mut tmp: AutomorphismKey<Vec<u8>> = AutomorphismKey::alloc_from_infos(&key_infos);
|
||||
gal_els.iter().for_each(|gal_el| {
|
||||
tmp.encrypt_sk(
|
||||
@@ -93,7 +91,8 @@ where
|
||||
&mut source_xe,
|
||||
scratch.borrow(),
|
||||
);
|
||||
let mut atk_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> = AutomorphismKeyPrepared::alloc_from_infos(module, &tmp);
|
||||
let mut atk_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &tmp);
|
||||
atk_prepared.prepare(module, &tmp, scratch.borrow());
|
||||
auto_keys.insert(*gal_el, atk_prepared);
|
||||
});
|
||||
|
||||
@@ -11,9 +11,9 @@ use crate::{
|
||||
encryption::SIGMA,
|
||||
glwe_trace::GLWETrace,
|
||||
layouts::{
|
||||
AutomorphismKey, AutomorphismKeyLayout, AutomorphismKeyPrepare, AutomorphismKeyPreparedAlloc, GLWE, GLWELayout,
|
||||
GLWEPlaintext, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, LWEInfos,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
AutomorphismKey, AutomorphismKeyLayout, GLWE, GLWEAutomorphismKeyPreparedApi, GLWELayout, GLWEPlaintext, GLWESecret,
|
||||
GLWESecretPreparedApi, LWEInfos,
|
||||
prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
noise::var_noise_gglwe_product,
|
||||
};
|
||||
@@ -24,11 +24,9 @@ where
|
||||
+ GLWEEncryptSk<BE>
|
||||
+ GLWEDecrypt<BE>
|
||||
+ AutomorphismKeyEncryptSk<BE>
|
||||
+ AutomorphismKeyPrepare<BE>
|
||||
+ AutomorphismKeyPreparedAlloc<BE>
|
||||
+ GLWEAutomorphismKeyPreparedApi<BE>
|
||||
+ VecZnxFillUniform
|
||||
+ GLWESecretPrepare<BE>
|
||||
+ GLWESecretPreparedAlloc<BE>
|
||||
+ GLWESecretPreparedApi<BE>
|
||||
+ VecZnxSubInplace
|
||||
+ VecZnxNormalizeInplace<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
@@ -98,7 +96,7 @@ where
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
let mut auto_keys: HashMap<i64, AutomorphismKeyPrepared<Vec<u8>, BE>> = HashMap::new();
|
||||
let mut auto_keys: HashMap<i64, GLWEAutomorphismKeyPrepared<Vec<u8>, BE>> = HashMap::new();
|
||||
let gal_els: Vec<i64> = GLWE::trace_galois_elements(module);
|
||||
let mut tmp: AutomorphismKey<Vec<u8>> = AutomorphismKey::alloc_from_infos(&key_infos);
|
||||
gal_els.iter().for_each(|gal_el| {
|
||||
@@ -110,7 +108,8 @@ where
|
||||
&mut source_xe,
|
||||
scratch.borrow(),
|
||||
);
|
||||
let mut atk_prepared: AutomorphismKeyPrepared<Vec<u8>, BE> = AutomorphismKeyPrepared::alloc_from_infos(module, &tmp);
|
||||
let mut atk_prepared: GLWEAutomorphismKeyPrepared<Vec<u8>, BE> =
|
||||
GLWEAutomorphismKeyPrepared::alloc_from_infos(module, &tmp);
|
||||
atk_prepared.prepare(module, &tmp, scratch.borrow());
|
||||
auto_keys.insert(*gal_el, atk_prepared);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user