diff --git a/poulpy-core/examples/encryption.rs b/poulpy-core/examples/encryption.rs index 08e1595..898170f 100644 --- a/poulpy-core/examples/encryption.rs +++ b/poulpy-core/examples/encryption.rs @@ -1,9 +1,9 @@ use poulpy_core::{ - GLWESub, SIGMA, layouts::{ - Base2K, Degree, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, TorusPrecision, - prepared::GLWESecretPrepared, + prepared::GLWESecretPrepared, Base2K, Degree, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, + TorusPrecision, GLWE, }, + GLWESub, SIGMA, }; #[cfg(all(feature = "enable-avx", target_arch = "x86_64"))] @@ -71,14 +71,33 @@ fn main() { let mut sk_prepared: GLWESecretPrepared, BackendImpl> = GLWESecretPrepared::alloc(&module, rank); sk_prepared.prepare(&module, &sk); + // DBG: + // obtain pk from sk + let mut pk = poulpy_core::layouts::GLWEPublicKey::alloc_from_infos(&glwe_ct_infos); + pk.generate(&module, &sk_prepared, &mut source_xa, &mut source_xe); + // Backend-prepared publickey: + let mut pk_prepared: poulpy_core::layouts::GLWEPublicKeyPrepared, BackendImpl> = + poulpy_core::layouts::GLWEPublicKeyPrepared::alloc(&module, base2k, k_ct, rank); + pk_prepared.prepare(&module, &pk); + // Uniform plaintext module.vec_znx_fill_uniform(base2k.into(), &mut pt_want.data, 0, &mut source_xa); // Encryption - ct.encrypt_sk( + // ct.encrypt_sk( + // &module, + // &pt_want, + // &sk_prepared, + // &mut source_xa, + // &mut source_xe, + // scratch.borrow(), + // ); + + // DBG: encrypt with public key + ct.encrypt_pk( &module, &pt_want, - &sk_prepared, + &pk_prepared, &mut source_xa, &mut source_xe, scratch.borrow(), diff --git a/poulpy-core/src/encryption/glwe.rs b/poulpy-core/src/encryption/glwe.rs index 06b6426..ea83def 100644 --- a/poulpy-core/src/encryption/glwe.rs +++ b/poulpy-core/src/encryption/glwe.rs @@ -401,6 +401,9 @@ where // ci_big = u * p[i] let mut ci_big = self.vec_znx_idft_apply_consume(ci_dft); + // to print it run: cargo run --example encryption -- --nocapture + println!("DBG: ci_big before adding e: {:?}", &ci_big.data); + // 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);