Working schemes

This commit is contained in:
Pro7ech
2025-11-19 09:26:52 +01:00
parent 48757fac7c
commit c23cf7803b
3 changed files with 8 additions and 5 deletions

View File

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

View File

@@ -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<D: Data, T: UnsignedInteger> {
pub(crate) bits: Vec<GGSW<D>>,
@@ -99,6 +99,7 @@ impl<D: DataRef, T: UnsignedInteger + ToBits> FheUintPreparedDebug<D, T> {
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));
}

View File

@@ -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<Stats> = 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}")
}
}
}