arnaucube
arnaucube/poulpyPublic Self-hosted repository
Updated packing to clean values correctly
Pro7ech jeanphilippe.bossuat@gmail.com
Thu, 30 Oct 2025 15:58:30 +0100
commit

3cd79e5a90c1ea4ab0ddee5208cafda83f5a21c2

parent

a6970669dd677500cb3eb622ed9adf7711fe9e85

M poulpy-core/src/glwe_packing.rs → poulpy-core/src/glwe_packing.rs

@@ -6,15 +6,22 @@ layouts::{Backend, GaloisElement, Module, Scratch},

}; 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<BE: Backend> { /// 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<R, K, H>(&self, cts: &mut HashMap<usize, &mut R>, log_gap_out: usize, keys: &H, scratch: &mut Scratch<BE>) - where - R: GLWEToMut + GLWEToRef + GLWEInfos, + fn glwe_pack<R, A, K, H>( + &self, + res: &mut R, + a: HashMap<usize, &mut A>, + log_gap_out: usize, + keys: &H, + scratch: &mut Scratch<BE>, + ) where + R: GLWEToMut, + A: GLWEToMut + GLWEToRef + GLWEInfos, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, H: GLWEAutomorphismKeyHelper<K, BE>; }

@@ -29,21 +36,26 @@ + GLWESub

+ GLWEShift<BE> + GLWEAdd + GLWENormalize<BE> - + GLWECopy, + + GLWECopy + + GLWETrace<BE>, Scratch<BE>: ScratchTakeCore<BE>, { /// 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<R, K, H>(&self, cts: &mut HashMap<usize, &mut R>, log_gap_out: usize, keys: &H, scratch: &mut Scratch<BE>) - where - R: GLWEToMut + GLWEToRef + GLWEInfos, + fn glwe_pack<R, A, K, H>( + &self, + res: &mut R, + mut a: HashMap<usize, &mut A>, + log_gap_out: usize, + keys: &H, + scratch: &mut Scratch<BE>, + ) where + R: GLWEToMut, + A: GLWEToMut + GLWEToRef + GLWEInfos, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, H: GLWEAutomorphismKeyHelper<K, BE>, { - #[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 @@ .unwrap()

}; 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, + ); } }
M poulpy-core/src/tests/mod.rs → poulpy-core/src/tests/mod.rs

@@ -28,7 +28,7 @@ glwe_external_product => crate::tests::test_suite::external_product::test_glwe_external_product,

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_external_product,

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_external_product,

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,
M poulpy-core/src/tests/test_suite/mod.rs → 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::*;
M poulpy-core/src/tests/test_suite/packing.rs → poulpy-core/src/tests/test_suite/glwe_packer.rs

@@ -15,7 +15,7 @@ prepared::{GLWEAutomorphismKeyPrepared, GLWESecretPrepared},

}, }; -pub fn test_glwe_packing<BE: Backend>(module: &Module<BE>) +pub fn test_glwe_packer<BE: Backend>(module: &Module<BE>) where Module<BE>: GLWEEncryptSk<BE> + GLWEAutomorphismKeyEncryptSk<BE>
M poulpy-schemes/src/tfhe/bdd_arithmetic/bdd_2w_to_1w.rs → 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<T: UnsignedInteger, BE: Backend> ExecuteBDDCircuit2WTo1W<T, BE> for Module<BE> where

@@ -24,21 +23,21 @@ where

Self: Sized + ModuleLogN + ExecuteBDDCircuit<T, BE> + GLWEPacking<BE> + GLWECopy, { /// Operations Z x Z -> Z - fn execute_bdd_circuit_2w_to_1w<R, C, A, B, DK, BRA>( + fn execute_bdd_circuit_2w_to_1w<R, C, A, B, K, H>( &self, out: &mut FheUint<R, T>, circuit: &C, a: &FheUintPrepared<A, T, BE>, b: &FheUintPrepared<B, T, BE>, - key: &BDDKeyPrepared<DK, BRA, BE>, + key: &H, scratch: &mut Scratch<BE>, ) where - BRA: BlindRotationAlgo, - DK: DataRef, C: GetBitCircuitInfo<T>, R: DataMut, A: DataRef, B: DataRef, + K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper<K, BE>, Scratch<BE>: ScratchTakeCore<BE>, { // 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<T: UnsignedInteger, BE: Backend> { - fn $method_name<A, M, K, BRA, B>( + fn $method_name<A, M, K, H, B>( &mut self, module: &M, a: &FheUintPrepared<A, T, BE>, b: &FheUintPrepared<B, T, BE>, - key: &BDDKeyPrepared<K, BRA, BE>, + key: &H, scratch: &mut Scratch<BE>, ) where M: ExecuteBDDCircuit2WTo1W<T, BE>, A: DataRef, B: DataRef, - K: DataRef, - BRA: BlindRotationAlgo, + K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper<K, BE>, Scratch<BE>: ScratchTakeCore<BE>; } };

@@ -125,19 +124,19 @@ #[macro_export]

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<D: DataMut, BE: Backend> $trait_name<$ty, BE> for FheUint<D, $ty> { - fn $method_name<A, M, K, BRA, B>( + fn $method_name<A, M, K, H, B>( &mut self, module: &M, a: &FheUintPrepared<A, $ty, BE>, b: &FheUintPrepared<B, $ty, BE>, - key: &BDDKeyPrepared<K, BRA, BE>, + key: &H, scratch: &mut Scratch<BE>, ) where M: ExecuteBDDCircuit2WTo1W<$ty, BE>, A: DataRef, B: DataRef, - K: DataRef, - BRA: BlindRotationAlgo, + K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper<K, BE>, Scratch<BE>: ScratchTakeCore<BE>, { module.execute_bdd_circuit_2w_to_1w(self, &$output_circuits, a, b, key, scratch)
M poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/fhe_uint.rs

@@ -12,10 +12,7 @@ source::Source,

}; 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<D: Data, T: UnsignedInteger> {

@@ -34,6 +31,18 @@

pub fn alloc(n: Degree, base2k: Base2K, k: TorusPrecision, rank: Rank) -> Self { Self { bits: GLWE::alloc(n, base2k, k, rank), + _phantom: PhantomData, + } + } +} + +impl<'a, T: UnsignedInteger> FheUint<&'a mut [u8], T> { + pub fn from_glwe_to_mut<G>(glwe: &'a mut G) -> Self + where + G: GLWEToMut, + { + FheUint { + bits: glwe.to_mut(), _phantom: PhantomData, } }

@@ -145,16 +154,12 @@ }

impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> { /// Packs Vec<GLWE(bit[i])> into [FheUint]. - pub fn pack<G, D1, M, BRA: BlindRotationAlgo, BE: Backend>( - &mut self, - module: &M, - mut bits: Vec<G>, - key: &BDDKeyPrepared<D1, BRA, BE>, - scratch: &mut Scratch<BE>, - ) where + pub fn pack<G, M, K, H, BE: Backend>(&mut self, module: &M, mut bits: Vec<G>, keys: &H, scratch: &mut Scratch<BE>) + where G: GLWEToMut + GLWEToRef + GLWEInfos, - D1: DataRef, M: ModuleLogN + GLWEPacking<BE> + GLWECopy, + K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos, + H: GLWEAutomorphismKeyHelper<K, BE>, Scratch<BE>: ScratchTakeCore<BE>, { // Repacks the GLWE ciphertexts bits

@@ -164,10 +169,7 @@ for (i, ct) in bits.iter_mut().enumerate().take(T::BITS as usize) {

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)]
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/add.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/and.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/ggsw_blind_rotations.rs

@@ -78,7 +78,8 @@ let k: u32 = source.next_u32();

// println!("k: {k}"); - let mut k_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_k_infos); + let mut k_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_k_infos); k_enc_prep.encrypt_sk( module, k,
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/glwe_blind_rotation.rs

@@ -71,7 +71,8 @@ test_glwe.encode_vec_i64(&data, base2k.as_usize().into());

let k: u32 = source.next_u32(); - let mut k_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut k_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); k_enc_prep.encrypt_sk( module, k,
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/or.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sll.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15;
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/slt.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sltu.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sra.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15;
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/srl.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32() & 15;
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/sub.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/tests/test_suite/xor.rs

@@ -51,8 +51,10 @@

let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); let mut res: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos); - let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); - let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); + let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = + FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); let a: u32 = source.next_u32(); let b: u32 = source.next_u32();
M poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs → poulpy-schemes/src/tfhe/circuit_bootstrapping/circuit.rs

@@ -378,16 +378,6 @@ for (i, ct) in cts_vec.iter_mut().enumerate().take(steps) {

cts.insert(i * (1 << log_gap_out), ct); } - module.glwe_pack(&mut cts, log_gap_out, auto_keys, scratch); - - let packed: &mut GLWE<Vec<u8>> = 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); } }