minimal changes to reproduce printing ci_big at encrypt_pk

This commit is contained in:
2026-01-16 14:32:20 +00:00
parent dc1b13b9b3
commit f075ba444b
2 changed files with 27 additions and 5 deletions

View File

@@ -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<Vec<u8>, 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<Vec<u8>, 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(),

View File

@@ -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);