diff --git a/poulpy-core/src/noise/glwe.rs b/poulpy-core/src/noise/glwe.rs index 5cfb512..8c24d80 100644 --- a/poulpy-core/src/noise/glwe.rs +++ b/poulpy-core/src/noise/glwe.rs @@ -52,8 +52,8 @@ where { let (mut pt_have, scratch_1) = scratch.take_glwe_plaintext(res); self.glwe_decrypt(res, &mut pt_have, sk_prepared, scratch_1); - // println!("pt_have: {pt_have}"); - // println!("pt_want: {}", pt_want.to_ref()); + //println!("pt_have: {pt_have}"); + //println!("pt_want: {}", pt_want.to_ref()); self.glwe_sub_inplace(&mut pt_have, pt_want); self.glwe_normalize_inplace(&mut pt_have, scratch_1); pt_have.data.stats(pt_have.base2k().into(), 0) diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint_prepared_debug.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint_prepared_debug.rs index 1953803..f527218 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint_prepared_debug.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint_prepared_debug.rs @@ -14,7 +14,7 @@ use poulpy_core::{ }; use poulpy_hal::api::{ModuleN, ScratchTakeBasic}; -use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, Stats}; +use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, Stats, ZnxZero}; pub struct FheUintPreparedDebug { pub(crate) bits: Vec>, @@ -99,6 +99,7 @@ impl FheUintPreparedDebug { for (i, ggsw) in self.bits.iter().enumerate() { use poulpy_hal::layouts::ZnxViewMut; let (mut pt_want, scratch_1) = scratch.take_scalar_znx(self.n().into(), 1); + pt_want.zero(); pt_want.at_mut(0, 0)[0] = want.bit(i) as i64; stats.push(ggsw.noise(module, row, col, &pt_want, sk, scratch_1)); } diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/prepare.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/prepare.rs index 722b11b..fa39f90 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/prepare.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/prepare.rs @@ -84,8 +84,10 @@ where for row in 0..c_enc_prep_debug.dnum().as_usize() { for col in 0..c_enc_prep_debug.rank().as_usize() + 1 { let stats: Vec = c_enc_prep_debug.noise(module, row, col, value, sk_glwe_prep, scratch.borrow()); - for stat in &stats { - assert!(stat.std().log2() <= max_noise(col)) + for (i, stat) in stats.iter().enumerate() { + let noise_have: f64 = stat.std().log2(); + let noise_max: f64 = max_noise(col); + assert!(noise_have <= noise_max, "bit: {i} noise_have: {noise_have} > noise_max: {noise_max}") } } }