mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
Updated packing to clean values correctly
This commit is contained in:
@@ -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<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 @@ where
|
||||
+ 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 @@ 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
Module<BE>: GLWEEncryptSk<BE>
|
||||
+ GLWEAutomorphismKeyEncryptSk<BE>
|
||||
@@ -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::*;
|
||||
|
||||
@@ -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_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<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)
|
||||
|
||||
@@ -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<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> {
|
||||
fn base2k(&self) -> poulpy_core::layouts::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> {
|
||||
/// 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 @@ impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
|
||||
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)]
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -78,7 +78,8 @@ where
|
||||
|
||||
// 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,
|
||||
|
||||
@@ -71,7 +71,8 @@ where
|
||||
|
||||
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,
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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;
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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;
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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;
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -51,8 +51,10 @@ where
|
||||
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();
|
||||
|
||||
@@ -378,16 +378,6 @@ fn post_process<R, A, M, H, K, BE: Backend>(
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user