Updated packing to clean values correctly

This commit is contained in:
Pro7ech
2025-10-30 15:58:30 +01:00
parent a6970669dd
commit 3cd79e5a90
19 changed files with 127 additions and 93 deletions

View File

@@ -6,15 +6,22 @@ use poulpy_hal::{
}; };
use crate::{ 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}, layouts::{GGLWEInfos, GGLWEPreparedToRef, GLWEAutomorphismKeyHelper, GLWEInfos, GLWEToMut, GLWEToRef, GetGaloisElement},
}; };
pub trait GLWEPacking<BE: Backend> { pub trait GLWEPacking<BE: Backend> {
/// Packs [x_0: GLWE(m_0), x_1: GLWE(m_1), ..., x_i: GLWE(m_i)] /// 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)] /// 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>) fn glwe_pack<R, A, K, H>(
where &self,
R: GLWEToMut + GLWEToRef + GLWEInfos, 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, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
H: GLWEAutomorphismKeyHelper<K, BE>; H: GLWEAutomorphismKeyHelper<K, BE>;
} }
@@ -29,21 +36,26 @@ where
+ GLWEShift<BE> + GLWEShift<BE>
+ GLWEAdd + GLWEAdd
+ GLWENormalize<BE> + GLWENormalize<BE>
+ GLWECopy, + GLWECopy
+ GLWETrace<BE>,
Scratch<BE>: ScratchTakeCore<BE>, Scratch<BE>: ScratchTakeCore<BE>,
{ {
/// Packs [x_0: GLWE(m_0), x_1: GLWE(m_1), ..., x_i: GLWE(m_i)] /// 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)] /// 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>) fn glwe_pack<R, A, K, H>(
where &self,
R: GLWEToMut + GLWEToRef + GLWEInfos, 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, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
H: GLWEAutomorphismKeyHelper<K, BE>, H: GLWEAutomorphismKeyHelper<K, BE>,
{ {
#[cfg(debug_assertions)] assert!(*a.keys().max().unwrap() < self.n());
{
assert!(*cts.keys().max().unwrap() < self.n())
}
let log_n: usize = self.log_n(); let log_n: usize = self.log_n();
@@ -58,18 +70,27 @@ where
}; };
for j in 0..t { for j in 0..t {
let mut a: Option<&mut R> = cts.remove(&j); let mut lo: Option<&mut A> = a.remove(&j);
let mut b: Option<&mut R> = cts.remove(&(j + t)); 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 { if let Some(lo) = lo {
cts.insert(j, a); a.insert(j, lo);
} else if let Some(b) = b { } else if let Some(hi) = hi {
cts.insert(j, b); a.insert(j, hi);
} }
} }
} }
self.glwe_trace(
res,
log_n - log_gap_out,
log_n,
*a.get(&0).unwrap(),
keys,
scratch,
);
} }
} }

View File

@@ -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_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace,
// GLWE Trace // GLWE Trace
glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, 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 Encryption
gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, 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, 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_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace,
// GLWE Trace // GLWE Trace
glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, 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 Encryption
gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, 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, 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_external_product_inplace => crate::tests::test_suite::external_product::test_glwe_external_product_inplace,
// GLWE Trace // GLWE Trace
glwe_trace_inplace => crate::tests::test_suite::test_glwe_trace_inplace, 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 Encryption
gglwe_switching_key_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_encrypt_sk, 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, gglwe_switching_key_compressed_encrypt_sk => crate::tests::test_suite::encryption::test_gglwe_switching_key_compressed_encrypt_sk,

View File

@@ -15,7 +15,7 @@ use crate::{
}, },
}; };
pub fn test_glwe_packing<BE: Backend>(module: &Module<BE>) pub fn test_glwe_packer<BE: Backend>(module: &Module<BE>)
where where
Module<BE>: GLWEEncryptSk<BE> Module<BE>: GLWEEncryptSk<BE>
+ GLWEAutomorphismKeyEncryptSk<BE> + GLWEAutomorphismKeyEncryptSk<BE>

View File

@@ -4,9 +4,9 @@ pub mod external_product;
pub mod keyswitch; pub mod keyswitch;
mod conversion; mod conversion;
mod packing; mod glwe_packer;
mod trace; mod trace;
pub use conversion::*; pub use conversion::*;
pub use packing::*; pub use glwe_packer::*;
pub use trace::*; pub use trace::*;

View File

@@ -1,17 +1,16 @@
use std::marker::PhantomData; 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::{ use poulpy_hal::{
api::ModuleLogN, api::ModuleLogN,
layouts::{Backend, DataMut, DataRef, Module, Scratch}, layouts::{Backend, DataMut, DataRef, Module, Scratch},
}; };
use crate::tfhe::{ use crate::tfhe::bdd_arithmetic::{
bdd_arithmetic::{ BitSize, ExecuteBDDCircuit, FheUint, FheUintPrepared, GetBitCircuitInfo, GetGGSWBit, UnsignedInteger, circuits,
BDDKeyPrepared, BitSize, ExecuteBDDCircuit, FheUint, FheUintPrepared, GetBitCircuitInfo, GetGGSWBit, UnsignedInteger,
circuits,
},
blind_rotation::BlindRotationAlgo,
}; };
impl<T: UnsignedInteger, BE: Backend> ExecuteBDDCircuit2WTo1W<T, BE> for Module<BE> where 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, Self: Sized + ModuleLogN + ExecuteBDDCircuit<T, BE> + GLWEPacking<BE> + GLWECopy,
{ {
/// Operations Z x Z -> Z /// 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, &self,
out: &mut FheUint<R, T>, out: &mut FheUint<R, T>,
circuit: &C, circuit: &C,
a: &FheUintPrepared<A, T, BE>, a: &FheUintPrepared<A, T, BE>,
b: &FheUintPrepared<B, T, BE>, b: &FheUintPrepared<B, T, BE>,
key: &BDDKeyPrepared<DK, BRA, BE>, key: &H,
scratch: &mut Scratch<BE>, scratch: &mut Scratch<BE>,
) where ) where
BRA: BlindRotationAlgo,
DK: DataRef,
C: GetBitCircuitInfo<T>, C: GetBitCircuitInfo<T>,
R: DataMut, R: DataMut,
A: DataRef, A: DataRef,
B: DataRef, B: DataRef,
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
H: GLWEAutomorphismKeyHelper<K, BE>,
Scratch<BE>: ScratchTakeCore<BE>, Scratch<BE>: ScratchTakeCore<BE>,
{ {
// Collects inputs into a single array // 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:meta])* $vis:vis $trait_name:ident, $method_name:ident) => {
$(#[$meta])* $(#[$meta])*
$vis trait $trait_name<T: UnsignedInteger, BE: Backend> { $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, &mut self,
module: &M, module: &M,
a: &FheUintPrepared<A, T, BE>, a: &FheUintPrepared<A, T, BE>,
b: &FheUintPrepared<B, T, BE>, b: &FheUintPrepared<B, T, BE>,
key: &BDDKeyPrepared<K, BRA, BE>, key: &H,
scratch: &mut Scratch<BE>, scratch: &mut Scratch<BE>,
) where ) where
M: ExecuteBDDCircuit2WTo1W<T, BE>, M: ExecuteBDDCircuit2WTo1W<T, BE>,
A: DataRef, A: DataRef,
B: DataRef, B: DataRef,
K: DataRef, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
BRA: BlindRotationAlgo, H: GLWEAutomorphismKeyHelper<K, BE>,
Scratch<BE>: ScratchTakeCore<BE>; Scratch<BE>: ScratchTakeCore<BE>;
} }
}; };
@@ -125,19 +124,19 @@ macro_rules! define_bdd_2w_to_1w_trait {
macro_rules! impl_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) => { ($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> { 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, &mut self,
module: &M, module: &M,
a: &FheUintPrepared<A, $ty, BE>, a: &FheUintPrepared<A, $ty, BE>,
b: &FheUintPrepared<B, $ty, BE>, b: &FheUintPrepared<B, $ty, BE>,
key: &BDDKeyPrepared<K, BRA, BE>, key: &H,
scratch: &mut Scratch<BE>, scratch: &mut Scratch<BE>,
) where ) where
M: ExecuteBDDCircuit2WTo1W<$ty, BE>, M: ExecuteBDDCircuit2WTo1W<$ty, BE>,
A: DataRef, A: DataRef,
B: DataRef, B: DataRef,
K: DataRef, K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
BRA: BlindRotationAlgo, H: GLWEAutomorphismKeyHelper<K, BE>,
Scratch<BE>: ScratchTakeCore<BE>, Scratch<BE>: ScratchTakeCore<BE>,
{ {
module.execute_bdd_circuit_2w_to_1w(self, &$output_circuits, a, b, key, scratch) module.execute_bdd_circuit_2w_to_1w(self, &$output_circuits, a, b, key, scratch)

View File

@@ -12,10 +12,7 @@ use poulpy_hal::{
}; };
use std::{collections::HashMap, marker::PhantomData}; use std::{collections::HashMap, marker::PhantomData};
use crate::tfhe::{ use crate::tfhe::bdd_arithmetic::{FromBits, ToBits, UnsignedInteger};
bdd_arithmetic::{BDDKeyPrepared, FromBits, ToBits, UnsignedInteger},
blind_rotation::BlindRotationAlgo,
};
/// An FHE ciphertext encrypting the bits of an [UnsignedInteger]. /// An FHE ciphertext encrypting the bits of an [UnsignedInteger].
pub struct FheUint<D: Data, T: UnsignedInteger> { pub struct FheUint<D: Data, T: UnsignedInteger> {
@@ -39,6 +36,18 @@ impl<T: UnsignedInteger> FheUint<Vec<u8>, T> {
} }
} }
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,
}
}
}
impl<D: DataRef, T: UnsignedInteger> LWEInfos for FheUint<D, T> { impl<D: DataRef, T: UnsignedInteger> LWEInfos for FheUint<D, T> {
fn base2k(&self) -> poulpy_core::layouts::Base2K { fn base2k(&self) -> poulpy_core::layouts::Base2K {
self.bits.base2k() self.bits.base2k()
@@ -145,16 +154,12 @@ impl<D: DataRef, T: UnsignedInteger + FromBits> FheUint<D, T> {
impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> { impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
/// Packs Vec<GLWE(bit[i])> into [FheUint]. /// Packs Vec<GLWE(bit[i])> into [FheUint].
pub fn pack<G, D1, M, BRA: BlindRotationAlgo, BE: Backend>( pub fn pack<G, M, K, H, BE: Backend>(&mut self, module: &M, mut bits: Vec<G>, keys: &H, scratch: &mut Scratch<BE>)
&mut self, where
module: &M,
mut bits: Vec<G>,
key: &BDDKeyPrepared<D1, BRA, BE>,
scratch: &mut Scratch<BE>,
) where
G: GLWEToMut + GLWEToRef + GLWEInfos, G: GLWEToMut + GLWEToRef + GLWEInfos,
D1: DataRef,
M: ModuleLogN + GLWEPacking<BE> + GLWECopy, M: ModuleLogN + GLWEPacking<BE> + GLWECopy,
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
H: GLWEAutomorphismKeyHelper<K, BE>,
Scratch<BE>: ScratchTakeCore<BE>, Scratch<BE>: ScratchTakeCore<BE>,
{ {
// Repacks the GLWE ciphertexts bits // Repacks the GLWE ciphertexts bits
@@ -164,10 +169,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
cts.insert(T::bit_index(i) << log_gap, ct); cts.insert(T::bit_index(i) << log_gap, ct);
} }
module.glwe_pack(&mut cts, log_gap, &key.cbt.atk, scratch); module.glwe_pack(&mut self.bits, cts, log_gap, keys, scratch);
// And copies the repacked ciphertext on the receiver.
module.glwe_copy(&mut self.bits, cts.remove(&0).unwrap());
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -78,7 +78,8 @@ where
// println!("k: {k}"); // 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( k_enc_prep.encrypt_sk(
module, module,
k, k,

View File

@@ -71,7 +71,8 @@ where
let k: u32 = source.next_u32(); 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( k_enc_prep.encrypt_sk(
module, module,
k, k,

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32() & 15; let b: u32 = source.next_u32() & 15;

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32() & 15; let b: u32 = source.next_u32() & 15;

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32() & 15; let b: u32 = source.next_u32() & 15;

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -51,8 +51,10 @@ where
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22); 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 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 a_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> =
let mut b_enc_prep: FheUintPrepared<Vec<u8>, u32, BE> = FheUintPrepared::<Vec<u8>, u32, BE>::alloc_from_infos(module, &ggsw_infos); 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 a: u32 = source.next_u32();
let b: u32 = source.next_u32(); let b: u32 = source.next_u32();

View File

@@ -378,16 +378,6 @@ fn post_process<R, A, M, H, K, BE: Backend>(
cts.insert(i * (1 << log_gap_out), ct); cts.insert(i * (1 << log_gap_out), ct);
} }
module.glwe_pack(&mut cts, log_gap_out, auto_keys, scratch); module.glwe_pack(res, 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,
);
} }
} }