mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
update BDD circuits & fix non-zero scratch related bug
This commit is contained in:
@@ -8,7 +8,7 @@ use poulpy_core::{
|
||||
#[cfg(test)]
|
||||
use poulpy_core::GLWEEncryptSk;
|
||||
use poulpy_core::ScratchTakeCore;
|
||||
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
|
||||
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, ZnxZero};
|
||||
#[cfg(test)]
|
||||
#[cfg(test)]
|
||||
use poulpy_hal::source::Source;
|
||||
@@ -80,6 +80,7 @@ impl<D: DataMut, T: UnsignedInteger + ToBits> FheUintBlocks<D, T> {
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
use poulpy_core::layouts::GLWEPlaintextLayout;
|
||||
use poulpy_hal::layouts::ZnxZero;
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
@@ -95,6 +96,7 @@ impl<D: DataMut, T: UnsignedInteger + ToBits> FheUintBlocks<D, T> {
|
||||
};
|
||||
|
||||
let (mut pt, scratch_1) = scratch.take_glwe_plaintext(&pt_infos);
|
||||
pt.data.zero();
|
||||
|
||||
for i in 0..T::WORD_SIZE {
|
||||
pt.encode_coeff_i64(value.bit(i) as i64, TorusPrecision(2), 0);
|
||||
@@ -159,6 +161,7 @@ impl<D: DataRef, T: UnsignedInteger + FromBits + ToBits> FheUintBlocks<D, T> {
|
||||
};
|
||||
|
||||
let (mut pt_want, scratch_1) = scratch.take_glwe_plaintext(&pt_infos);
|
||||
pt_want.data.zero();
|
||||
|
||||
let mut noise: Vec<f64> = vec![0f64; T::WORD_SIZE];
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ impl<D: DataRef, T: UnsignedInteger> GGSWInfos for FheUintBlocksPreparedDebug<D,
|
||||
}
|
||||
|
||||
impl<D: DataRef, T: UnsignedInteger + ToBits> FheUintBlocksPreparedDebug<D, T> {
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn noise<S, M, BE: Backend>(&self, module: &M, sk: &S, want: T)
|
||||
where
|
||||
S: GLWESecretPreparedToRef<BE>,
|
||||
@@ -129,6 +130,7 @@ where
|
||||
}
|
||||
|
||||
impl<D: DataMut, T: UnsignedInteger> FheUintBlocksPreparedDebug<D, T> {
|
||||
#[allow(dead_code)]
|
||||
pub fn prepare<BRA, M, O, K, BE: Backend>(
|
||||
&mut self,
|
||||
module: &M,
|
||||
|
||||
@@ -107,7 +107,7 @@ where
|
||||
S: GLWESecretPreparedToRef<BE> + GLWEInfos,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
use poulpy_hal::api::ScratchTakeBasic;
|
||||
use poulpy_hal::{api::ScratchTakeBasic, layouts::ZnxZero};
|
||||
|
||||
assert!(self.n().is_multiple_of(T::WORD_SIZE));
|
||||
assert_eq!(res.n(), self.n() as u32);
|
||||
@@ -115,10 +115,10 @@ where
|
||||
|
||||
let (mut tmp_ggsw, scratch_1) = scratch.take_ggsw(res);
|
||||
let (mut pt, scratch_2) = scratch_1.take_scalar_znx(self.n(), 1);
|
||||
pt.zero();
|
||||
|
||||
for i in 0..T::WORD_SIZE {
|
||||
use poulpy_hal::layouts::ZnxViewMut;
|
||||
|
||||
pt.at_mut(0, 0)[0] = value.bit(i) as i64;
|
||||
tmp_ggsw.encrypt_sk(self, &pt, sk, source_xa, source_xe, scratch_2);
|
||||
res.blocks[i].prepare(self, &tmp_ggsw, scratch_2);
|
||||
|
||||
Reference in New Issue
Block a user