diff --git a/poulpy-core/src/glwe_packing.rs b/poulpy-core/src/glwe_packing.rs index e24ddb0..ecfcb92 100644 --- a/poulpy-core/src/glwe_packing.rs +++ b/poulpy-core/src/glwe_packing.rs @@ -6,15 +6,22 @@ use poulpy_hal::{ }; use crate::{ - GLWEAdd, GLWEAutomorphism, GLWECopy, GLWENormalize, GLWERotate, GLWEShift, GLWESub, ScratchTakeCore, + GLWEAdd, GLWEAutomorphism, GLWECopy, GLWENormalize, GLWERotate, GLWEShift, GLWESub, GLWETrace, ScratchTakeCore, layouts::{GGLWEInfos, GGLWEPreparedToRef, GLWEAutomorphismKeyHelper, GLWEInfos, GLWEToMut, GLWEToRef, GetGaloisElement}, }; pub trait GLWEPacking { /// Packs [x_0: GLWE(m_0), x_1: GLWE(m_1), ..., x_i: GLWE(m_i)] /// to [0: GLWE(m_0 * X^x_0 + m_1 * X^x_1 + ... + m_i * X^x_i)] - fn glwe_pack(&self, cts: &mut HashMap, log_gap_out: usize, keys: &H, scratch: &mut Scratch) - where - R: GLWEToMut + GLWEToRef + GLWEInfos, + fn glwe_pack( + &self, + res: &mut R, + a: HashMap, + log_gap_out: usize, + keys: &H, + scratch: &mut Scratch, + ) where + R: GLWEToMut, + A: GLWEToMut + GLWEToRef + GLWEInfos, K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, H: GLWEAutomorphismKeyHelper; } @@ -29,21 +36,26 @@ where + GLWEShift + GLWEAdd + GLWENormalize - + GLWECopy, + + GLWECopy + + GLWETrace, Scratch: ScratchTakeCore, { /// Packs [x_0: GLWE(m_0), x_1: GLWE(m_1), ..., x_i: GLWE(m_i)] /// to [0: GLWE(m_0 * X^x_0 + m_1 * X^x_1 + ... + m_i * X^x_i)] - fn glwe_pack(&self, cts: &mut HashMap, log_gap_out: usize, keys: &H, scratch: &mut Scratch) - where - R: GLWEToMut + GLWEToRef + GLWEInfos, + fn glwe_pack( + &self, + res: &mut R, + mut a: HashMap, + log_gap_out: usize, + keys: &H, + scratch: &mut Scratch, + ) where + R: GLWEToMut, + A: GLWEToMut + GLWEToRef + GLWEInfos, K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, H: GLWEAutomorphismKeyHelper, { - #[cfg(debug_assertions)] - { - assert!(*cts.keys().max().unwrap() < self.n()) - } + assert!(*a.keys().max().unwrap() < self.n()); let log_n: usize = self.log_n(); @@ -58,18 +70,27 @@ where }; for j in 0..t { - let mut a: Option<&mut R> = cts.remove(&j); - let mut b: Option<&mut R> = cts.remove(&(j + t)); + let mut lo: Option<&mut A> = a.remove(&j); + let mut hi: Option<&mut A> = a.remove(&(j + t)); - pack_internal(self, &mut a, &mut b, i, key, scratch); + pack_internal(self, &mut lo, &mut hi, i, key, scratch); - if let Some(a) = a { - cts.insert(j, a); - } else if let Some(b) = b { - cts.insert(j, b); + if let Some(lo) = lo { + a.insert(j, lo); + } else if let Some(hi) = hi { + a.insert(j, hi); } } } + + self.glwe_trace( + res, + log_n - log_gap_out, + log_n, + *a.get(&0).unwrap(), + keys, + scratch, + ); } } diff --git a/poulpy-core/src/tests/mod.rs b/poulpy-core/src/tests/mod.rs index aab0ec9..e29f625 100644 --- a/poulpy-core/src/tests/mod.rs +++ b/poulpy-core/src/tests/mod.rs @@ -28,7 +28,7 @@ glwe_external_product => crate::tests::test_suite::external_product::test_glwe_e glwe_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace, // GLWE Trace glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, -glwe_packing => crate::tests::test_suite::test_glwe_packing, +glwe_packing => crate::tests::test_suite::test_glwe_packer, // GGLWE Encryption gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk, @@ -86,7 +86,7 @@ glwe_external_product => crate::tests::test_suite::external_product::test_glwe_e glwe_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace, // GLWE Trace glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, -glwe_packing => crate::tests::test_suite::test_glwe_packing, +glwe_packing => crate::tests::test_suite::test_glwe_packer, // GGLWE Encryption gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk, @@ -146,7 +146,7 @@ glwe_external_product => crate::tests::test_suite::external_product::test_glwe_e glwe_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace, // GLWE Trace glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, -glwe_packing => crate::tests::test_suite::test_glwe_packing, +glwe_packing => crate::tests::test_suite::test_glwe_packer, // GGLWE Encryption gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk, diff --git a/poulpy-core/src/tests/test_suite/packing.rs b/poulpy-core/src/tests/test_suite/glwe_packer.rs similarity index 98% rename from poulpy-core/src/tests/test_suite/packing.rs rename to poulpy-core/src/tests/test_suite/glwe_packer.rs index cf8284a..7dd5ea2 100644 --- a/poulpy-core/src/tests/test_suite/packing.rs +++ b/poulpy-core/src/tests/test_suite/glwe_packer.rs @@ -15,7 +15,7 @@ use crate::{ }, }; -pub fn test_glwe_packing(module: &Module) +pub fn test_glwe_packer(module: &Module) where Module: GLWEEncryptSk + GLWEAutomorphismKeyEncryptSk diff --git a/poulpy-core/src/tests/test_suite/mod.rs b/poulpy-core/src/tests/test_suite/mod.rs index 624b9c3..6777d46 100644 --- a/poulpy-core/src/tests/test_suite/mod.rs +++ b/poulpy-core/src/tests/test_suite/mod.rs @@ -4,9 +4,9 @@ pub mod external_product; pub mod keyswitch; mod conversion; -mod packing; +mod glwe_packer; mod trace; pub use conversion::*; -pub use packing::*; +pub use glwe_packer::*; pub use trace::*; diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/bdd_2w_to_1w.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/bdd_2w_to_1w.rs index 63692fe..09564b5 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/bdd_2w_to_1w.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/bdd_2w_to_1w.rs @@ -1,17 +1,16 @@ use std::marker::PhantomData; -use poulpy_core::{GLWECopy, GLWEPacking, ScratchTakeCore, layouts::GGSWPrepared}; +use poulpy_core::{ + GLWECopy, GLWEPacking, ScratchTakeCore, + layouts::{GGLWEInfos, GGLWEPreparedToRef, GGSWPrepared, GLWEAutomorphismKeyHelper, GetGaloisElement}, +}; use poulpy_hal::{ api::ModuleLogN, layouts::{Backend, DataMut, DataRef, Module, Scratch}, }; -use crate::tfhe::{ - bdd_arithmetic::{ - BDDKeyPrepared, BitSize, ExecuteBDDCircuit, FheUint, FheUintPrepared, GetBitCircuitInfo, GetGGSWBit, UnsignedInteger, - circuits, - }, - blind_rotation::BlindRotationAlgo, +use crate::tfhe::bdd_arithmetic::{ + BitSize, ExecuteBDDCircuit, FheUint, FheUintPrepared, GetBitCircuitInfo, GetGGSWBit, UnsignedInteger, circuits, }; impl ExecuteBDDCircuit2WTo1W for Module where @@ -24,21 +23,21 @@ where Self: Sized + ModuleLogN + ExecuteBDDCircuit + GLWEPacking + GLWECopy, { /// Operations Z x Z -> Z - fn execute_bdd_circuit_2w_to_1w( + fn execute_bdd_circuit_2w_to_1w( &self, out: &mut FheUint, circuit: &C, a: &FheUintPrepared, b: &FheUintPrepared, - key: &BDDKeyPrepared, + key: &H, scratch: &mut Scratch, ) where - BRA: BlindRotationAlgo, - DK: DataRef, C: GetBitCircuitInfo, R: DataMut, A: DataRef, B: DataRef, + K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper, Scratch: ScratchTakeCore, { // Collects inputs into a single array @@ -103,19 +102,19 @@ macro_rules! define_bdd_2w_to_1w_trait { ($(#[$meta:meta])* $vis:vis $trait_name:ident, $method_name:ident) => { $(#[$meta])* $vis trait $trait_name { - fn $method_name( + fn $method_name( &mut self, module: &M, a: &FheUintPrepared, b: &FheUintPrepared, - key: &BDDKeyPrepared, + key: &H, scratch: &mut Scratch, ) where M: ExecuteBDDCircuit2WTo1W, A: DataRef, B: DataRef, - K: DataRef, - BRA: BlindRotationAlgo, + K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper, Scratch: ScratchTakeCore; } }; @@ -125,19 +124,19 @@ macro_rules! define_bdd_2w_to_1w_trait { macro_rules! impl_bdd_2w_to_1w_trait { ($trait_name:ident, $method_name:ident, $ty:ty, $n:literal, $circuit_ty:ty, $output_circuits:path) => { impl $trait_name<$ty, BE> for FheUint { - fn $method_name( + fn $method_name( &mut self, module: &M, a: &FheUintPrepared, b: &FheUintPrepared, - key: &BDDKeyPrepared, + key: &H, scratch: &mut Scratch, ) where M: ExecuteBDDCircuit2WTo1W<$ty, BE>, A: DataRef, B: DataRef, - K: DataRef, - BRA: BlindRotationAlgo, + K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper, Scratch: ScratchTakeCore, { module.execute_bdd_circuit_2w_to_1w(self, &$output_circuits, a, b, key, scratch) diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs index aa6ce9f..7fc6eda 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs @@ -12,10 +12,7 @@ use poulpy_hal::{ }; use std::{collections::HashMap, marker::PhantomData}; -use crate::tfhe::{ - bdd_arithmetic::{BDDKeyPrepared, FromBits, ToBits, UnsignedInteger}, - blind_rotation::BlindRotationAlgo, -}; +use crate::tfhe::bdd_arithmetic::{FromBits, ToBits, UnsignedInteger}; /// An FHE ciphertext encrypting the bits of an [UnsignedInteger]. pub struct FheUint { @@ -39,6 +36,18 @@ impl FheUint, T> { } } +impl<'a, T: UnsignedInteger> FheUint<&'a mut [u8], T> { + pub fn from_glwe_to_mut(glwe: &'a mut G) -> Self + where + G: GLWEToMut, + { + FheUint { + bits: glwe.to_mut(), + _phantom: PhantomData, + } + } +} + impl LWEInfos for FheUint { fn base2k(&self) -> poulpy_core::layouts::Base2K { self.bits.base2k() @@ -145,16 +154,12 @@ impl FheUint { impl FheUint { /// Packs Vec into [FheUint]. - pub fn pack( - &mut self, - module: &M, - mut bits: Vec, - key: &BDDKeyPrepared, - scratch: &mut Scratch, - ) where + pub fn pack(&mut self, module: &M, mut bits: Vec, keys: &H, scratch: &mut Scratch) + where G: GLWEToMut + GLWEToRef + GLWEInfos, - D1: DataRef, M: ModuleLogN + GLWEPacking + GLWECopy, + K: GGLWEPreparedToRef + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper, Scratch: ScratchTakeCore, { // Repacks the GLWE ciphertexts bits @@ -164,10 +169,7 @@ impl FheUint { cts.insert(T::bit_index(i) << log_gap, ct); } - module.glwe_pack(&mut cts, log_gap, &key.cbt.atk, scratch); - - // And copies the repacked ciphertext on the receiver. - module.glwe_copy(&mut self.bits, cts.remove(&0).unwrap()); + module.glwe_pack(&mut self.bits, cts, log_gap, keys, scratch); } #[allow(clippy::too_many_arguments)] diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs index cd709d9..4cbe748 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs index 0acd1a5..bf7e720 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs index 3f8effc..42ea9aa 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs @@ -78,7 +78,8 @@ where // println!("k: {k}"); - let mut k_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_k_infos); + let mut k_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_k_infos); k_enc_prep.encrypt_sk( module, k, diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs index 6bb4553..de7b37f 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs @@ -71,7 +71,8 @@ where let k: u32 = source.next_u32(); - let mut k_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut k_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); k_enc_prep.encrypt_sk( module, k, diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs index b7be001..e1ff2f2 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs index b947cf5..987c9fb 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15; diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs index 13d9170..bab9bfe 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs index 908ad4a..8b7bb7f 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs index a1c04a7..5cfb757 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15; diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs index 23a6bb1..adc5e0d 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15; diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs index a7174b7..2ee4cba 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs index c9cd937..0edaae4 100644 --- a/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs +++ b/poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs @@ -51,8 +51,10 @@ where let mut scratch: ScratchOwned = ScratchOwned::alloc(1 << 22); let mut res: FheUint, u32> = FheUint::, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared, u32, BE> = FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared, u32, BE> = + FheUintPrepared::, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32(); diff --git a/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs b/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs index a4691fa..22c841b 100644 --- a/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs +++ b/poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs @@ -378,16 +378,6 @@ fn post_process( cts.insert(i * (1 << log_gap_out), ct); } - module.glwe_pack(&mut cts, log_gap_out, auto_keys, scratch); - - let packed: &mut GLWE> = cts.remove(&0).unwrap(); - res.trace( - module, - log_n - log_gap_out, - log_n, - packed, - auto_keys, - scratch, - ); + module.glwe_pack(res, cts, log_gap_out, auto_keys, scratch); } }