diff --git a/poulpy-core/src/encryption/glwe_ct.rs b/poulpy-core/src/encryption/glwe_ct.rs index 0e684ac..a0328d3 100644 --- a/poulpy-core/src/encryption/glwe_ct.rs +++ b/poulpy-core/src/encryption/glwe_ct.rs @@ -510,7 +510,7 @@ where // ct[i] = uniform (+ pt) self.vec_znx_fill_uniform(base2k, ct, col_ct, source_xa); - println!("vec_znx_fill_uniform: {}", ct); + // println!("vec_znx_fill_uniform: {}", ct); let (mut ci_dft, scratch_3) = scratch_2.take_vec_znx_dft(self, 1, size); diff --git a/poulpy-core/src/noise/gglwe_ct.rs b/poulpy-core/src/noise/gglwe_ct.rs index 48c2df8..687b657 100644 --- a/poulpy-core/src/noise/gglwe_ct.rs +++ b/poulpy-core/src/noise/gglwe_ct.rs @@ -1,7 +1,6 @@ use poulpy_hal::{ - api::{ScratchOwnedAlloc, ScratchOwnedBorrow, ScratchTakeBasic, VecZnxSubScalarInplace}, + api::{ScratchAvailable, ScratchOwnedAlloc, ScratchOwnedBorrow, ScratchTakeBasic, VecZnxFillUniform, VecZnxSubScalarInplace}, layouts::{Backend, DataRef, Module, ScalarZnx, ScalarZnxToRef, Scratch, ScratchOwned, ZnxZero}, - oep::{ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, VecZnxSubScalarInplaceImpl}, }; use crate::decryption::GLWEDecrypt; @@ -11,7 +10,7 @@ use crate::layouts::{ }; impl GGLWE { - pub fn assert_noise( + pub fn assert_noise( &self, module: &M, sk_prepared: &GLWESecretPrepared, @@ -21,62 +20,12 @@ impl GGLWE { DataSk: DataRef, DataWant: DataRef, M: GGLWENoise, - BE: Backend - + ScratchOwnedAllocImpl - + ScratchOwnedBorrowImpl - + ScratchOwnedBorrow - + VecZnxSubScalarInplaceImpl, + Scratch: ScratchTakeBasic, { module.gglwe_assert_noise(self, sk_prepared, pt_want, max_noise); } - // pub fn assert_noise( - // &self, - // module: &Module, - // sk: &GLWESecretPrepared, - // pt_want: &ScalarZnx, - // max_noise: f64, - // ) where - // DataSk: DataRef, - // DataWant: DataRef, - // Module: VecZnxDftBytesOf - // + VecZnxBigBytesOf - // + VecZnxDftApply - // + SvpApplyDftToDftInplace - // + VecZnxIdftApplyConsume - // + VecZnxBigAddInplace - // + VecZnxBigAddSmallInplace - // + VecZnxBigNormalize - // + VecZnxNormalizeTmpBytes - // + VecZnxSubScalarInplace, - // B: Backend + ScratchOwnedAllocImpl + ScratchOwnedBorrowImpl, - // { - // let dsize: usize = self.dsize().into(); - // let base2k: usize = self.base2k().into(); - // let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWE::decrypt_tmp_bytes(module, self)); - // let mut pt: GLWEPlaintext> = GLWEPlaintext::alloc_from_infos(module, self); - - // (0..self.rank_in().into()).for_each(|col_i| { - // (0..self.dnum().into()).for_each(|row_i| { - // self.at(row_i, col_i) - // .decrypt(module, &mut pt, sk, scratch.borrow()); - - // module.vec_znx_sub_scalar_inplace(&mut pt.data, 0, (dsize - 1) + row_i * dsize, pt_want, col_i); - - // let noise_have: f64 = pt.data.std(base2k, 0).log2(); - - // println!("noise_have: {noise_have}"); - - // assert!( - // noise_have <= max_noise, - // "noise_have: {noise_have} > max_noise: {max_noise}" - // ); - - // pt.data.zero(); - // }); - // }); - // } } pub trait GGLWENoise { @@ -85,24 +34,22 @@ pub trait GGLWENoise { R: GGLWEToRef, S: GLWESecretPreparedToRef, P: ScalarZnxToRef, - BE: ScratchOwnedAllocImpl + ScratchOwnedBorrowImpl + ScratchOwnedBorrow + VecZnxSubScalarInplaceImpl; + Scratch: ScratchTakeBasic; } impl GGLWENoise for Module where - Module: GLWEDecrypt, - Scratch: ScratchTakeBasic - + ScratchOwnedAllocImpl - + ScratchOwnedBorrowImpl - + ScratchOwnedBorrowImpl - + ScratchOwnedBorrow, + Module: GLWEDecrypt + VecZnxFillUniform + VecZnxSubScalarInplace, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeBasic, { fn gglwe_assert_noise(&self, res: &R, sk_prepared: &S, pt_want: &P, max_noise: f64) where R: GGLWEToRef, S: GLWESecretPreparedToRef, P: ScalarZnxToRef, - BE: ScratchOwnedAllocImpl + ScratchOwnedBorrowImpl + ScratchOwnedBorrow + VecZnxSubScalarInplaceImpl, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeBasic, { let res: &GGLWE<&[u8]> = &res.to_ref(); @@ -125,7 +72,7 @@ where let noise_have: f64 = pt.data.std(base2k, 0).log2(); - println!("noise_have: {noise_have}"); + // println!("noise_have: {noise_have}"); assert!( noise_have <= max_noise, diff --git a/poulpy-core/src/noise/mod.rs b/poulpy-core/src/noise/mod.rs index 25e2b9b..aace6ad 100644 --- a/poulpy-core/src/noise/mod.rs +++ b/poulpy-core/src/noise/mod.rs @@ -2,6 +2,10 @@ mod gglwe_ct; mod ggsw_ct; mod glwe_ct; +pub use gglwe_ct::*; +pub use ggsw_ct::*; +pub use glwe_ct::*; + #[allow(clippy::too_many_arguments)] #[allow(dead_code)] pub(crate) fn var_noise_gglwe_product( diff --git a/poulpy-core/src/tests/mod.rs b/poulpy-core/src/tests/mod.rs index 874a879..9cad53d 100644 --- a/poulpy-core/src/tests/mod.rs +++ b/poulpy-core/src/tests/mod.rs @@ -30,8 +30,8 @@ backend_test_suite!( // glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, // glwe_packing => crate::tests::test_suite::test_glwe_packing, // GGLWE Encryption -// gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, -// gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk, +gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, +gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk, // gglwe_automorphisk_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_automorphisk_key_encrypt_sk, // gglwe_automorphisk_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_automorphisk_key_compressed_encrypt_sk, // gglwe_tensor_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_tensor_key_encrypt_sk, diff --git a/poulpy-core/src/tests/test_suite/encryption/gglwe_ct.rs b/poulpy-core/src/tests/test_suite/encryption/gglwe_ct.rs index 5e09781..ba19219 100644 --- a/poulpy-core/src/tests/test_suite/encryption/gglwe_ct.rs +++ b/poulpy-core/src/tests/test_suite/encryption/gglwe_ct.rs @@ -1,66 +1,32 @@ use poulpy_hal::{ api::{ - ScratchOwnedAlloc, ScratchOwnedBorrow, SvpApplyDftToDftInplace, SvpPPolAlloc, SvpPPolBytesOf, SvpPrepare, - VecZnxAddInplace, VecZnxAddNormal, VecZnxAddScalarInplace, VecZnxBigAddInplace, VecZnxBigAddSmallInplace, - VecZnxBigBytesOf, VecZnxBigNormalize, VecZnxCopy, VecZnxDftApply, VecZnxDftBytesOf, VecZnxFillUniform, - VecZnxIdftApplyConsume, VecZnxNormalize, VecZnxNormalizeInplace, VecZnxNormalizeTmpBytes, VecZnxSub, VecZnxSubInplace, - VecZnxSubScalarInplace, VecZnxSwitchRing, VmpPMatAlloc, VmpPrepare, - }, - layouts::{Backend, Module, ScratchOwned}, - oep::{ - ScratchAvailableImpl, ScratchOwnedAllocImpl, ScratchOwnedBorrowImpl, TakeScalarZnxImpl, TakeSvpPPolImpl, - TakeVecZnxBigImpl, TakeVecZnxDftImpl, TakeVecZnxImpl, VecZnxBigAllocBytesImpl, VecZnxDftAllocBytesImpl, + ScratchAvailable, ScratchOwnedAlloc, ScratchOwnedBorrow, VecZnxFillUniform, }, + layouts::{Backend, Module, Scratch, ScratchOwned}, source::Source, }; use crate::{ - encryption::SIGMA, - layouts::{ - GGLWECiphertextLayout, GLWESecret, GLWESwitchingKey, - compressed::{Decompress, GLWESwitchingKeyCompressed}, - prepared::{GLWESecretPrepared, PrepareAlloc}, - }, + decryption::GLWEDecrypt, encryption::SIGMA, layouts::{ + prepared::{GGLWEPrepare, GGLWEPreparedAlloc, GLWESecretPrepared}, GGLWELayout, GLWESecret, GLWESecretPrepare, GLWESecretPreparedAlloc, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyCompressed, GLWESwitchingKeyDecompress + }, noise::GGLWENoise, GGLWEEncryptSk, GGLWEKeyswitch, GLWESwitchingKeyCompressedEncryptSk, GLWESwitchingKeyEncryptSk, ScratchTakeCore }; -pub fn test_gglwe_switching_key_encrypt_sk(module: &Module) +pub fn test_gglwe_switching_key_encrypt_sk(module: &Module) where - Module: VecZnxDftBytesOf - + VecZnxBigNormalize - + VecZnxDftApply - + SvpApplyDftToDftInplace - + VecZnxIdftApplyConsume - + VecZnxNormalizeTmpBytes + Module: GGLWEEncryptSk + + GGLWEPrepare + + GGLWEPreparedAlloc + + GGLWEKeyswitch + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + + GLWESwitchingKeyAlloc + + GLWESwitchingKeyEncryptSk + VecZnxFillUniform - + VecZnxSubInplace - + VecZnxAddInplace - + VecZnxNormalizeInplace - + VecZnxAddNormal - + VecZnxNormalize - + VecZnxSub - + SvpPrepare - + SvpPPolBytesOf - + SvpPPolAlloc - + VecZnxBigAddSmallInplace - + VecZnxSwitchRing - + VecZnxAddScalarInplace - + VecZnxBigBytesOf - + VecZnxBigAddInplace - + VecZnxSubScalarInplace - + VecZnxCopy - + VmpPMatAlloc - + VmpPrepare, - B: Backend - + TakeVecZnxDftImpl - + TakeVecZnxBigImpl - + ScratchOwnedAllocImpl - + ScratchOwnedBorrowImpl - + ScratchAvailableImpl - + TakeScalarZnxImpl - + TakeVecZnxImpl - + VecZnxDftAllocBytesImpl - + VecZnxBigAllocBytesImpl - + TakeSvpPPolImpl, + + GGLWENoise, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 12; let k_ksk: usize = 54; @@ -71,7 +37,7 @@ where let n: usize = module.n(); let dnum: usize = (k_ksk - di * base2k) / (di * base2k); - let gglwe_infos: GGLWECiphertextLayout = GGLWECiphertextLayout { + let gglwe_infos: GGLWELayout = GGLWELayout { n: n.into(), base2k: base2k.into(), k: k_ksk.into(), @@ -81,23 +47,24 @@ where rank_out: rank_out.into(), }; - let mut ksk: GLWESwitchingKey> = GLWESwitchingKey::alloc_from_infos(&gglwe_infos); + let mut ksk: GLWESwitchingKey> = GLWESwitchingKey::alloc_from_infos(module, &gglwe_infos); let mut source_xs: Source = Source::new([0u8; 32]); let mut source_xe: Source = Source::new([0u8; 32]); let mut source_xa: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWESwitchingKey::encrypt_sk_tmp_bytes( + let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWESwitchingKey::encrypt_sk_tmp_bytes( module, &gglwe_infos, )); - let mut sk_in: GLWESecret> = GLWESecret::alloc(n.into(), rank_in.into()); + let mut sk_in: GLWESecret> = GLWESecret::alloc(module, rank_in.into()); sk_in.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_out: GLWESecret> = GLWESecret::alloc(n.into(), rank_out.into()); + let mut sk_out: GLWESecret> = GLWESecret::alloc(module, rank_out.into()); sk_out.fill_ternary_prob(0.5, &mut source_xs); - let sk_out_prepared: GLWESecretPrepared, B> = sk_out.prepare_alloc(module, scratch.borrow()); + let mut sk_out_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank_out.into()); + sk_out_prepared.prepare(module, &sk_out); ksk.encrypt_sk( module, @@ -115,44 +82,23 @@ where } } -pub fn test_gglwe_switching_key_compressed_encrypt_sk(module: &Module) +pub fn test_gglwe_switching_key_compressed_encrypt_sk(module: &Module) where - Module: VecZnxDftBytesOf - + VecZnxBigNormalize - + VecZnxDftApply - + SvpApplyDftToDftInplace - + VecZnxIdftApplyConsume - + VecZnxNormalizeTmpBytes - + VecZnxFillUniform - + VecZnxSubInplace - + VecZnxAddInplace - + VecZnxNormalizeInplace - + VecZnxAddNormal - + VecZnxNormalize - + VecZnxSub - + SvpPrepare - + SvpPPolBytesOf - + SvpPPolAlloc - + VecZnxBigAddSmallInplace - + VecZnxSwitchRing - + VecZnxAddScalarInplace - + VecZnxBigBytesOf - + VecZnxBigAddInplace - + VecZnxSubScalarInplace - + VecZnxCopy - + VmpPMatAlloc - + VmpPrepare, - B: Backend - + TakeVecZnxDftImpl - + TakeVecZnxBigImpl - + ScratchOwnedAllocImpl - + ScratchOwnedBorrowImpl - + ScratchAvailableImpl - + TakeScalarZnxImpl - + TakeVecZnxImpl - + VecZnxDftAllocBytesImpl - + VecZnxBigAllocBytesImpl - + TakeSvpPPolImpl, + Module: GGLWEEncryptSk + + GGLWEPrepare + + GGLWEPreparedAlloc + + GGLWEKeyswitch + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + + GLWESwitchingKeyAlloc + + GLWESwitchingKeyEncryptSk + + GLWESwitchingKeyCompressedEncryptSk + + GLWESwitchingKeyDecompress + + GGLWENoise + + VecZnxFillUniform, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 12; let k_ksk: usize = 54; @@ -163,7 +109,7 @@ where let n: usize = module.n(); let dnum: usize = (k_ksk - di * base2k) / (di * base2k); - let gglwe_infos: GGLWECiphertextLayout = GGLWECiphertextLayout { + let gglwe_infos: GGLWELayout = GGLWELayout { n: n.into(), base2k: base2k.into(), k: k_ksk.into(), @@ -174,22 +120,23 @@ where }; let mut ksk_compressed: GLWESwitchingKeyCompressed> = - GLWESwitchingKeyCompressed::alloc_from_infos(&gglwe_infos); + GLWESwitchingKeyCompressed::alloc_from_infos(module, &gglwe_infos); let mut source_xs: Source = Source::new([0u8; 32]); let mut source_xe: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWESwitchingKeyCompressed::encrypt_sk_tmp_bytes( + let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWESwitchingKeyCompressed::encrypt_sk_tmp_bytes( module, &gglwe_infos, )); - let mut sk_in: GLWESecret> = GLWESecret::alloc(n.into(), rank_in.into()); + let mut sk_in: GLWESecret> = GLWESecret::alloc(module, rank_in.into()); sk_in.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_out: GLWESecret> = GLWESecret::alloc(n.into(), rank_out.into()); + let mut sk_out: GLWESecret> = GLWESecret::alloc(module, rank_out.into()); sk_out.fill_ternary_prob(0.5, &mut source_xs); - let sk_out_prepared: GLWESecretPrepared, B> = sk_out.prepare_alloc(module, scratch.borrow()); + let mut sk_out_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank_out.into()); + sk_out_prepared.prepare(module, &sk_out); let seed_xa = [1u8; 32]; @@ -202,7 +149,7 @@ where scratch.borrow(), ); - let mut ksk: GLWESwitchingKey> = GLWESwitchingKey::alloc_from_infos(&gglwe_infos); + let mut ksk: GLWESwitchingKey> = GLWESwitchingKey::alloc_from_infos(module, &gglwe_infos); ksk.decompress(module, &ksk_compressed); ksk.key diff --git a/poulpy-core/src/tests/test_suite/encryption/glwe_ct.rs b/poulpy-core/src/tests/test_suite/encryption/glwe_ct.rs index 970002d..1d9d701 100644 --- a/poulpy-core/src/tests/test_suite/encryption/glwe_ct.rs +++ b/poulpy-core/src/tests/test_suite/encryption/glwe_ct.rs @@ -16,17 +16,17 @@ use crate::{ }, }; -pub fn test_glwe_encrypt_sk(module: &Module) +pub fn test_glwe_encrypt_sk(module: &Module) where - Module: GLWEAlloc - + GLWEEncryptSk - + GLWEDecrypt - + GLWESecretPreparedAlloc - + GLWESecretPrepare + Module: GLWEAlloc + + GLWEEncryptSk + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + VecZnxFillUniform + GLWESub, - ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, - Scratch: ScratchAvailable + ScratchTakeCore, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 8; let k_ct: usize = 54; @@ -56,13 +56,13 @@ where let mut source_xe: Source = Source::new([0u8; 32]); let mut source_xa: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = + let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWE::encrypt_sk_tmp_bytes(module, &glwe_infos) | GLWE::decrypt_tmp_bytes(module, &glwe_infos)); let mut sk: GLWESecret> = GLWESecret::alloc_from_infos(module, &glwe_infos); sk.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_prepared: GLWESecretPrepared, B> = GLWESecretPrepared::alloc(module, rank.into()); + let mut sk_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank.into()); sk_prepared.prepare(module, &sk); module.vec_znx_fill_uniform(base2k, &mut pt_want.data, 0, &mut source_xa); @@ -87,24 +87,24 @@ where } } -pub fn test_glwe_compressed_encrypt_sk(module: &Module) +pub fn test_glwe_compressed_encrypt_sk(module: &Module) where - Module: GLWEAlloc - + GLWECompressedEncryptSk - + GLWEDecrypt - + GLWESecretPreparedAlloc - + GLWESecretPrepare + Module: GLWEAlloc + + GLWECompressedEncryptSk + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + VecZnxFillUniform + GLWESub, - ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, - Scratch: ScratchAvailable + ScratchTakeCore, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 8; let k_ct: usize = 54; let k_pt: usize = 30; for rank in 1_usize..3 { - println!("rank: {}", rank); + // println!("rank: {}", rank); let n: usize = module.n(); let glwe_infos: GLWELayout = GLWELayout { @@ -129,14 +129,14 @@ where let mut source_xe: Source = Source::new([0u8; 32]); let mut source_xa: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = ScratchOwned::alloc( + let mut scratch: ScratchOwned = ScratchOwned::alloc( GLWECompressed::encrypt_sk_tmp_bytes(module, &glwe_infos) | GLWE::decrypt_tmp_bytes(module, &glwe_infos), ); let mut sk: GLWESecret> = GLWESecret::alloc_from_infos(module, &glwe_infos); sk.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_prepared: GLWESecretPrepared, B> = GLWESecretPrepared::alloc(module, rank.into()); + let mut sk_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank.into()); sk_prepared.prepare(module, &sk); module.vec_znx_fill_uniform(base2k, &mut pt_want.data, 0, &mut source_xa); @@ -170,17 +170,17 @@ where } } -pub fn test_glwe_encrypt_zero_sk(module: &Module) +pub fn test_glwe_encrypt_zero_sk(module: &Module) where - Module: GLWEAlloc - + GLWEEncryptSk - + GLWEDecrypt - + GLWESecretPreparedAlloc - + GLWESecretPrepare + Module: GLWEAlloc + + GLWEEncryptSk + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + VecZnxFillUniform + GLWESub, - ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, - Scratch: ScratchAvailable + ScratchTakeCore, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 8; let k_ct: usize = 54; @@ -201,13 +201,13 @@ where let mut source_xe: Source = Source::new([1u8; 32]); let mut source_xa: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = + let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWE::decrypt_tmp_bytes(module, &glwe_infos) | GLWE::encrypt_sk_tmp_bytes(module, &glwe_infos)); let mut sk: GLWESecret> = GLWESecret::alloc_from_infos(module, &glwe_infos); sk.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_prepared: GLWESecretPrepared, B> = GLWESecretPrepared::alloc(module, rank.into()); + let mut sk_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank.into()); sk_prepared.prepare(module, &sk); let mut ct: GLWE> = GLWE::alloc_from_infos(module, &glwe_infos); @@ -225,20 +225,20 @@ where } } -pub fn test_glwe_encrypt_pk(module: &Module) +pub fn test_glwe_encrypt_pk(module: &Module) where - Module: GLWEAlloc - + GLWEEncryptPk - + GLWEPublicKeyPrepare - + GLWEPublicKeyPreparedAlloc - + GLWEPublicKeyGenerate - + GLWEDecrypt - + GLWESecretPreparedAlloc - + GLWESecretPrepare + Module: GLWEAlloc + + GLWEEncryptPk + + GLWEPublicKeyPrepare + + GLWEPublicKeyPreparedAlloc + + GLWEPublicKeyGenerate + + GLWEDecrypt + + GLWESecretPreparedAlloc + + GLWESecretPrepare + VecZnxFillUniform + GLWESub, - ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, - Scratch: ScratchAvailable + ScratchTakeCore, + ScratchOwned: ScratchOwnedAlloc + ScratchOwnedBorrow, + Scratch: ScratchAvailable + ScratchTakeCore, { let base2k: usize = 8; let k_ct: usize = 54; @@ -262,13 +262,13 @@ where let mut source_xa: Source = Source::new([0u8; 32]); let mut source_xu: Source = Source::new([0u8; 32]); - let mut scratch: ScratchOwned = + let mut scratch: ScratchOwned = ScratchOwned::alloc(GLWE::decrypt_tmp_bytes(module, &glwe_infos) | GLWE::encrypt_pk_tmp_bytes(module, &glwe_infos)); let mut sk: GLWESecret> = GLWESecret::alloc_from_infos(module, &glwe_infos); sk.fill_ternary_prob(0.5, &mut source_xs); - let mut sk_prepared: GLWESecretPrepared, B> = GLWESecretPrepared::alloc(module, rank.into()); + let mut sk_prepared: GLWESecretPrepared, BE> = GLWESecretPrepared::alloc(module, rank.into()); sk_prepared.prepare(module, &sk); let mut pk: GLWEPublicKey> = GLWEPublicKey::alloc_from_infos(module, &glwe_infos); @@ -276,7 +276,7 @@ where module.vec_znx_fill_uniform(base2k, &mut pt_want.data, 0, &mut source_xa); - let mut pk_prepared: GLWEPublicKeyPrepared, B> = GLWEPublicKeyPrepared::alloc_from_infos(module, &glwe_infos); + let mut pk_prepared: GLWEPublicKeyPrepared, BE> = GLWEPublicKeyPrepared::alloc_from_infos(module, &glwe_infos); pk_prepared.prepare(module, &pk); ct.encrypt_pk( diff --git a/poulpy-core/src/tests/test_suite/encryption/mod.rs b/poulpy-core/src/tests/test_suite/encryption/mod.rs index 33fd5a1..2ed1147 100644 --- a/poulpy-core/src/tests/test_suite/encryption/mod.rs +++ b/poulpy-core/src/tests/test_suite/encryption/mod.rs @@ -1,11 +1,11 @@ // mod gglwe_atk; -// mod gglwe_ct; +mod gglwe_ct; // mod ggsw_ct; mod glwe_ct; // mod glwe_tsk; // pub use gglwe_atk::*; -// pub use gglwe_ct::*; +pub use gglwe_ct::*; // pub use ggsw_ct::*; pub use glwe_ct::*; // pub use glwe_tsk::*;