mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Working schemes
This commit is contained in:
@@ -52,8 +52,8 @@ where
|
|||||||
{
|
{
|
||||||
let (mut pt_have, scratch_1) = scratch.take_glwe_plaintext(res);
|
let (mut pt_have, scratch_1) = scratch.take_glwe_plaintext(res);
|
||||||
self.glwe_decrypt(res, &mut pt_have, sk_prepared, scratch_1);
|
self.glwe_decrypt(res, &mut pt_have, sk_prepared, scratch_1);
|
||||||
// println!("pt_have: {pt_have}");
|
//println!("pt_have: {pt_have}");
|
||||||
// println!("pt_want: {}", pt_want.to_ref());
|
//println!("pt_want: {}", pt_want.to_ref());
|
||||||
self.glwe_sub_inplace(&mut pt_have, pt_want);
|
self.glwe_sub_inplace(&mut pt_have, pt_want);
|
||||||
self.glwe_normalize_inplace(&mut pt_have, scratch_1);
|
self.glwe_normalize_inplace(&mut pt_have, scratch_1);
|
||||||
pt_have.data.stats(pt_have.base2k().into(), 0)
|
pt_have.data.stats(pt_have.base2k().into(), 0)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use poulpy_core::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use poulpy_hal::api::{ModuleN, ScratchTakeBasic};
|
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 struct FheUintPreparedDebug<D: Data, T: UnsignedInteger> {
|
||||||
pub(crate) bits: Vec<GGSW<D>>,
|
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() {
|
for (i, ggsw) in self.bits.iter().enumerate() {
|
||||||
use poulpy_hal::layouts::ZnxViewMut;
|
use poulpy_hal::layouts::ZnxViewMut;
|
||||||
let (mut pt_want, scratch_1) = scratch.take_scalar_znx(self.n().into(), 1);
|
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;
|
pt_want.at_mut(0, 0)[0] = want.bit(i) as i64;
|
||||||
stats.push(ggsw.noise(module, row, col, &pt_want, sk, scratch_1));
|
stats.push(ggsw.noise(module, row, col, &pt_want, sk, scratch_1));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,8 +84,10 @@ where
|
|||||||
for row in 0..c_enc_prep_debug.dnum().as_usize() {
|
for row in 0..c_enc_prep_debug.dnum().as_usize() {
|
||||||
for col in 0..c_enc_prep_debug.rank().as_usize() + 1 {
|
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());
|
let stats: Vec<Stats> = c_enc_prep_debug.noise(module, row, col, value, sk_glwe_prep, scratch.borrow());
|
||||||
for stat in &stats {
|
for (i, stat) in stats.iter().enumerate() {
|
||||||
assert!(stat.std().log2() <= max_noise(col))
|
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}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user