mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 05:06:44 +01:00
add sext for fheuint
This commit is contained in:
@@ -83,14 +83,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
self.glwe_trace(
|
||||
res,
|
||||
log_n - log_gap_out,
|
||||
log_n,
|
||||
*a.get(&0).unwrap(),
|
||||
keys,
|
||||
scratch,
|
||||
);
|
||||
self.glwe_trace(res, log_n - log_gap_out, *a.get(&0).unwrap(), keys, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,38 +31,25 @@ impl GLWE<Vec<u8>> {
|
||||
}
|
||||
|
||||
impl<D: DataMut> GLWE<D> {
|
||||
pub fn trace<A, H, K, M, BE: Backend>(
|
||||
&mut self,
|
||||
module: &M,
|
||||
start: usize,
|
||||
end: usize,
|
||||
a: &A,
|
||||
keys: &H,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
pub fn trace<A, H, K, M, BE: Backend>(&mut self, module: &M, skip: usize, a: &A, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
A: GLWEToRef,
|
||||
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
|
||||
H: GLWEAutomorphismKeyHelper<K, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
M: GLWETrace<BE>,
|
||||
{
|
||||
module.glwe_trace(self, start, end, a, keys, scratch);
|
||||
module.glwe_trace(self, skip, a, keys, scratch);
|
||||
}
|
||||
|
||||
pub fn trace_inplace<H, K, M, BE: Backend>(
|
||||
&mut self,
|
||||
module: &M,
|
||||
start: usize,
|
||||
end: usize,
|
||||
keys: &H,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
pub fn trace_inplace<H, K, M, BE: Backend>(&mut self, module: &M, skip: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
|
||||
H: GLWEAutomorphismKeyHelper<K, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
M: GLWETrace<BE>,
|
||||
{
|
||||
module.glwe_trace_inplace(self, start, end, keys, scratch);
|
||||
module.glwe_trace_inplace(self, skip, keys, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +101,7 @@ where
|
||||
trace
|
||||
}
|
||||
|
||||
fn glwe_trace<R, A, K, H>(&self, res: &mut R, start: usize, end: usize, a: &A, keys: &H, scratch: &mut Scratch<BE>)
|
||||
fn glwe_trace<R, A, K, H>(&self, res: &mut R, skip: usize, a: &A, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
R: GLWEToMut,
|
||||
A: GLWEToRef,
|
||||
@@ -122,10 +109,10 @@ where
|
||||
H: GLWEAutomorphismKeyHelper<K, BE>,
|
||||
{
|
||||
self.glwe_copy(res, a);
|
||||
self.glwe_trace_inplace(res, start, end, keys, scratch);
|
||||
self.glwe_trace_inplace(res, skip, keys, scratch);
|
||||
}
|
||||
|
||||
fn glwe_trace_inplace<R, K, H>(&self, res: &mut R, start: usize, end: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
fn glwe_trace_inplace<R, K, H>(&self, res: &mut R, skip: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
R: GLWEToMut,
|
||||
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
|
||||
@@ -134,11 +121,11 @@ where
|
||||
let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();
|
||||
|
||||
let ksk_infos: &GGLWELayout = &keys.automorphism_key_infos();
|
||||
let log_n: usize = self.log_n();
|
||||
|
||||
assert_eq!(res.n(), self.n() as u32);
|
||||
assert_eq!(ksk_infos.n(), self.n() as u32);
|
||||
assert!(start < end);
|
||||
assert!(end <= self.log_n());
|
||||
assert!(skip <= log_n);
|
||||
assert_eq!(ksk_infos.rank_in(), res.rank());
|
||||
assert_eq!(ksk_infos.rank_out(), res.rank());
|
||||
|
||||
@@ -162,7 +149,7 @@ where
|
||||
);
|
||||
}
|
||||
|
||||
for i in start..end {
|
||||
for i in skip..log_n {
|
||||
self.glwe_rsh(1, &mut self_conv, scratch_1);
|
||||
|
||||
let p: i64 = if i == 0 {
|
||||
@@ -192,7 +179,7 @@ where
|
||||
} else {
|
||||
// println!("res: {}", res);
|
||||
|
||||
for i in start..end {
|
||||
for i in skip..log_n {
|
||||
self.glwe_rsh(1, res, scratch);
|
||||
|
||||
let p: i64 = if i == 0 {
|
||||
@@ -220,14 +207,14 @@ pub trait GLWETrace<BE: Backend> {
|
||||
A: GLWEInfos,
|
||||
K: GGLWEInfos;
|
||||
|
||||
fn glwe_trace<R, A, K, H>(&self, res: &mut R, start: usize, end: usize, a: &A, keys: &H, scratch: &mut Scratch<BE>)
|
||||
fn glwe_trace<R, A, K, H>(&self, res: &mut R, skip: usize, a: &A, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
R: GLWEToMut,
|
||||
A: GLWEToRef,
|
||||
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
|
||||
H: GLWEAutomorphismKeyHelper<K, BE>;
|
||||
|
||||
fn glwe_trace_inplace<R, K, H>(&self, res: &mut R, start: usize, end: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
fn glwe_trace_inplace<R, K, H>(&self, res: &mut R, skip: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
R: GLWEToMut,
|
||||
K: GGLWEPreparedToRef<BE> + GetGaloisElement + GGLWEInfos,
|
||||
|
||||
@@ -114,8 +114,7 @@ where
|
||||
auto_keys.insert(*gal_el, atk_prepared);
|
||||
});
|
||||
|
||||
glwe_out.trace_inplace(module, 0, 5, &auto_keys, scratch.borrow());
|
||||
glwe_out.trace_inplace(module, 5, module.log_n(), &auto_keys, scratch.borrow());
|
||||
glwe_out.trace_inplace(module, 0, &auto_keys, scratch.borrow());
|
||||
|
||||
(0..pt_want.size()).for_each(|i| pt_want.data.at_mut(0, i)[0] = pt_have.data.at(0, i)[0]);
|
||||
|
||||
|
||||
@@ -239,14 +239,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
|
||||
|
||||
// Stores this byte (everything else zeroed) into tmp_trace
|
||||
let (mut tmp_trace, scratch_1) = scratch.take_glwe(a);
|
||||
module.glwe_trace(
|
||||
&mut tmp_trace,
|
||||
trace_start,
|
||||
module.log_n(),
|
||||
self,
|
||||
keys,
|
||||
scratch_1,
|
||||
);
|
||||
module.glwe_trace(&mut tmp_trace, trace_start, self, keys, scratch_1);
|
||||
|
||||
// Subtracts to self to zero it
|
||||
module.glwe_sub_inplace(&mut self.bits, &tmp_trace);
|
||||
@@ -262,13 +255,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
|
||||
);
|
||||
|
||||
// Zeroes all other bytes
|
||||
module.glwe_trace_inplace(
|
||||
&mut tmp_fhe_uint_byte,
|
||||
trace_start,
|
||||
module.log_n(),
|
||||
keys,
|
||||
scratch_1,
|
||||
);
|
||||
module.glwe_trace_inplace(&mut tmp_fhe_uint_byte, trace_start, keys, scratch_1);
|
||||
|
||||
// Add self[0] += a[0]
|
||||
module.glwe_add_inplace(&mut self.bits, &tmp_fhe_uint_byte);
|
||||
@@ -324,3 +311,40 @@ impl<D: DataRef, T: UnsignedInteger> GLWEToRef for FheUint<D, T> {
|
||||
self.bits.to_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DataMut, T: UnsignedInteger> FheUint<D, T> {
|
||||
pub fn sext<M, H, K, BE>(&mut self, module: &M, byte: usize, keys: &H, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
M:,
|
||||
H: GLWEAutomorphismKeyHelper<K, BE>,
|
||||
K: GGLWEPreparedToRef<BE> + GGLWEInfos + GetGaloisElement,
|
||||
BE: Backend,
|
||||
M: ModuleLogN + GLWERotate<BE> + GLWETrace<BE> + GLWEAdd + GLWESub + GLWECopy,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
assert!(byte < (1 << T::LOG_BYTES));
|
||||
|
||||
let log_gap: usize = module.log_n() - T::LOG_BITS as usize;
|
||||
let rot: i64 = (T::bit_index(byte << 3) << log_gap) as i64;
|
||||
|
||||
let (mut sext, scratch_1) = scratch.take_glwe(self);
|
||||
|
||||
// Extract MSB
|
||||
module.glwe_rotate(-rot, &mut sext, &self.bits);
|
||||
module.glwe_trace_inplace(&mut sext, 0, keys, scratch_1);
|
||||
|
||||
// Replicates MSB in byte
|
||||
for i in 0..3 {
|
||||
let (mut tmp, _) = scratch_1.take_glwe(self);
|
||||
module.glwe_rotate(((1 << T::LOG_BYTES) << log_gap) << i, &mut tmp, &sext);
|
||||
module.glwe_add_inplace(&mut sext, &tmp);
|
||||
}
|
||||
|
||||
// Splice sext
|
||||
let (mut tmp, scratch_2) = scratch_1.take_glwe(self);
|
||||
for i in byte..(1 << T::LOG_BYTES) as usize {
|
||||
FheUint::<&mut [u8], T>::from_glwe_to_mut(&mut tmp).splice_u8(module, i, 0, &self.bits, &sext, keys, scratch_2);
|
||||
module.glwe_copy(&mut self.bits, &tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use poulpy_core::LWEFromGLWE;
|
||||
use poulpy_core::layouts::{
|
||||
Base2K, Dnum, Dsize, GGSWInfos, GGSWPreparedFactory, GLWEInfos, LWEInfos, Rank, TorusPrecision, prepared::GGSWPrepared,
|
||||
};
|
||||
use poulpy_core::layouts::{GGSWPreparedToMut, GGSWPreparedToRef};
|
||||
use poulpy_core::layouts::{GGSWPreparedToMut, GGSWPreparedToRef, LWE};
|
||||
|
||||
use poulpy_core::{GGSWEncryptSk, ScratchTakeCore, layouts::GLWESecretPreparedToRef};
|
||||
use poulpy_hal::layouts::{Backend, Data, DataRef, Module};
|
||||
@@ -14,8 +15,10 @@ use poulpy_hal::{
|
||||
source::Source,
|
||||
};
|
||||
|
||||
use crate::tfhe::bdd_arithmetic::ToBits;
|
||||
use crate::tfhe::bdd_arithmetic::UnsignedInteger;
|
||||
use crate::tfhe::bdd_arithmetic::{BDDKey, BDDKeyHelper, BDDKeyInfos, BDDKeyPrepared, BDDKeyPreparedFactory, FheUint, ToBits};
|
||||
use crate::tfhe::blind_rotation::BlindRotationAlgo;
|
||||
use crate::tfhe::circuit_bootstrapping::CirtuitBootstrappingExecute;
|
||||
|
||||
/// A prepared FHE ciphertext encrypting the bits of an [UnsignedInteger].
|
||||
pub struct FheUintPrepared<D: Data, T: UnsignedInteger, B: Backend> {
|
||||
@@ -23,10 +26,7 @@ pub struct FheUintPrepared<D: Data, T: UnsignedInteger, B: Backend> {
|
||||
pub(crate) _phantom: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T: UnsignedInteger, BE: Backend> FheUintPreparedFactory<T, BE> for Module<BE> where
|
||||
Self: Sized + GGSWPreparedFactory<BE>
|
||||
{
|
||||
}
|
||||
impl<T: UnsignedInteger, BE: Backend> FheUintPreparedFactory<T, BE> for Module<BE> where Self: Sized + GGSWPreparedFactory<BE> {}
|
||||
|
||||
pub trait GetGGSWBit<BE: Backend> {
|
||||
fn get_bit(&self, bit: usize) -> GGSWPrepared<&[u8], BE>;
|
||||
@@ -189,3 +189,88 @@ impl<D: DataRef, T: UnsignedInteger, B: Backend> GGSWInfos for FheUintPrepared<D
|
||||
self.bits[0].dnum()
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DataMut, BRA: BlindRotationAlgo, BE: Backend> BDDKeyPrepared<D, BRA, BE> {
|
||||
pub fn prepare<DR, M>(&mut self, module: &M, other: &BDDKey<DR, BRA>, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
DR: DataRef,
|
||||
M: BDDKeyPreparedFactory<BRA, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.prepare_bdd_key(self, other, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FheUintPrepare<BRA: BlindRotationAlgo, T: UnsignedInteger, BE: Backend> {
|
||||
fn fhe_uint_prepare_tmp_bytes<R, A>(&self, block_size: usize, extension_factor: usize, res_infos: &R, infos: &A) -> usize
|
||||
where
|
||||
R: GGSWInfos,
|
||||
A: BDDKeyInfos;
|
||||
fn fhe_uint_prepare<DM, DB, DK, K>(
|
||||
&self,
|
||||
res: &mut FheUintPrepared<DM, T, BE>,
|
||||
bits: &FheUint<DB, T>,
|
||||
key: &K,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
DM: DataMut,
|
||||
DB: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>;
|
||||
}
|
||||
|
||||
impl<BRA: BlindRotationAlgo, BE: Backend, T: UnsignedInteger> FheUintPrepare<BRA, T, BE> for Module<BE>
|
||||
where
|
||||
Self: LWEFromGLWE<BE> + CirtuitBootstrappingExecute<BRA, BE> + GGSWPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn fhe_uint_prepare_tmp_bytes<R, A>(&self, block_size: usize, extension_factor: usize, res_infos: &R, bdd_infos: &A) -> usize
|
||||
where
|
||||
R: GGSWInfos,
|
||||
A: BDDKeyInfos,
|
||||
{
|
||||
self.circuit_bootstrapping_execute_tmp_bytes(
|
||||
block_size,
|
||||
extension_factor,
|
||||
res_infos,
|
||||
&bdd_infos.cbt_infos(),
|
||||
)
|
||||
}
|
||||
|
||||
fn fhe_uint_prepare<DM, DB, DK, K>(
|
||||
&self,
|
||||
res: &mut FheUintPrepared<DM, T, BE>,
|
||||
bits: &FheUint<DB, T>,
|
||||
key: &K,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
DM: DataMut,
|
||||
DB: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>,
|
||||
{
|
||||
let (cbt, ks) = key.get_cbt_key();
|
||||
|
||||
let mut lwe: LWE<Vec<u8>> = LWE::alloc_from_infos(bits); //TODO: add TakeLWE
|
||||
let (mut tmp_ggsw, scratch_1) = scratch.take_ggsw(res);
|
||||
for (bit, dst) in res.bits.iter_mut().enumerate() {
|
||||
bits.get_bit(self, bit, &mut lwe, ks, scratch_1);
|
||||
cbt.execute_to_constant(self, &mut tmp_ggsw, &lwe, 1, 1, scratch_1);
|
||||
dst.prepare(self, &tmp_ggsw, scratch_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DataMut, T: UnsignedInteger, BE: Backend> FheUintPrepared<D, T, BE> {
|
||||
pub fn prepare<BRA, M, O, K, DK>(&mut self, module: &M, other: &FheUint<O, T>, key: &K, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
BRA: BlindRotationAlgo,
|
||||
O: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>,
|
||||
M: FheUintPrepare<BRA, T, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.fhe_uint_prepare(self, other, key, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::tfhe::bdd_arithmetic::{BDDKeyPrepared, FheUint, FheUintBlockDebugPrepare, ToBits};
|
||||
use crate::tfhe::bdd_arithmetic::{BDDKeyPrepared, FheUint, FheUintPrepareDebug, ToBits};
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::UnsignedInteger, blind_rotation::BlindRotationAlgo, circuit_bootstrapping::CirtuitBootstrappingExecute,
|
||||
};
|
||||
@@ -109,7 +109,7 @@ impl<D: DataRef, T: UnsignedInteger + ToBits> FheUintPreparedDebug<D, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<BRA: BlindRotationAlgo, BE: Backend, T: UnsignedInteger> FheUintBlockDebugPrepare<BRA, T, BE> for Module<BE>
|
||||
impl<BRA: BlindRotationAlgo, BE: Backend, T: UnsignedInteger> FheUintPrepareDebug<BRA, T, BE> for Module<BE>
|
||||
where
|
||||
Self: ModuleN + LWEFromGLWE<BE> + CirtuitBootstrappingExecute<BRA, BE> + GGSWPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
@@ -144,7 +144,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUintPreparedDebug<D, T> {
|
||||
BRA: BlindRotationAlgo,
|
||||
O: DataRef,
|
||||
K: DataRef,
|
||||
M: FheUintBlockDebugPrepare<BRA, T, BE>,
|
||||
M: FheUintPrepareDebug<BRA, T, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.fhe_uint_debug_prepare(self, other, key, scratch);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
use crate::tfhe::bdd_arithmetic::FheUintPreparedDebug;
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{FheUint, FheUintPrepared, UnsignedInteger},
|
||||
bdd_arithmetic::{FheUint, UnsignedInteger},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
circuit_bootstrapping::{
|
||||
CircuitBootstrappingKey, CircuitBootstrappingKeyEncryptSk, CircuitBootstrappingKeyLayout,
|
||||
CircuitBootstrappingKeyPrepared, CircuitBootstrappingKeyPreparedFactory, CirtuitBootstrappingExecute,
|
||||
CircuitBootstrappingKeyPrepared, CircuitBootstrappingKeyPreparedFactory,
|
||||
},
|
||||
};
|
||||
|
||||
use poulpy_core::layouts::{GLWEAutomorphismKeyHelper, GLWEAutomorphismKeyPrepared};
|
||||
use poulpy_core::{
|
||||
GLWEToLWESwitchingKeyEncryptSk, GetDistribution, LWEFromGLWE, ScratchTakeCore,
|
||||
GLWEToLWESwitchingKeyEncryptSk, GetDistribution, ScratchTakeCore,
|
||||
layouts::{
|
||||
GGSWInfos, GGSWPreparedFactory, GLWEInfos, GLWESecretToRef, GLWEToLWEKey, GLWEToLWEKeyLayout,
|
||||
GLWEToLWEKeyPreparedFactory, LWE, LWEInfos, LWESecretToRef, prepared::GLWEToLWEKeyPrepared,
|
||||
GLWEInfos, GLWESecretToRef, GLWEToLWEKey, GLWEToLWEKeyLayout, GLWEToLWEKeyPreparedFactory, LWEInfos, LWESecretToRef,
|
||||
prepared::GLWEToLWEKeyPrepared,
|
||||
},
|
||||
};
|
||||
use poulpy_hal::{
|
||||
@@ -194,77 +194,6 @@ impl<BRA: BlindRotationAlgo, BE: Backend> BDDKeyPrepared<Vec<u8>, BRA, BE> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<D: DataMut, BRA: BlindRotationAlgo, BE: Backend> BDDKeyPrepared<D, BRA, BE> {
|
||||
pub fn prepare<DR, M>(&mut self, module: &M, other: &BDDKey<DR, BRA>, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
DR: DataRef,
|
||||
M: BDDKeyPreparedFactory<BRA, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.prepare_bdd_key(self, other, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FheUintPrepare<BRA: BlindRotationAlgo, T: UnsignedInteger, BE: Backend> {
|
||||
fn fhe_uint_prepare_tmp_bytes<R, A>(&self, block_size: usize, extension_factor: usize, res_infos: &R, infos: &A) -> usize
|
||||
where
|
||||
R: GGSWInfos,
|
||||
A: BDDKeyInfos;
|
||||
fn fhe_uint_prepare<DM, DB, DK, K>(
|
||||
&self,
|
||||
res: &mut FheUintPrepared<DM, T, BE>,
|
||||
bits: &FheUint<DB, T>,
|
||||
key: &K,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
DM: DataMut,
|
||||
DB: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>;
|
||||
}
|
||||
|
||||
impl<BRA: BlindRotationAlgo, BE: Backend, T: UnsignedInteger> FheUintPrepare<BRA, T, BE> for Module<BE>
|
||||
where
|
||||
Self: LWEFromGLWE<BE> + CirtuitBootstrappingExecute<BRA, BE> + GGSWPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn fhe_uint_prepare_tmp_bytes<R, A>(&self, block_size: usize, extension_factor: usize, res_infos: &R, bdd_infos: &A) -> usize
|
||||
where
|
||||
R: GGSWInfos,
|
||||
A: BDDKeyInfos,
|
||||
{
|
||||
self.circuit_bootstrapping_execute_tmp_bytes(
|
||||
block_size,
|
||||
extension_factor,
|
||||
res_infos,
|
||||
&bdd_infos.cbt_infos(),
|
||||
)
|
||||
}
|
||||
|
||||
fn fhe_uint_prepare<DM, DB, DK, K>(
|
||||
&self,
|
||||
res: &mut FheUintPrepared<DM, T, BE>,
|
||||
bits: &FheUint<DB, T>,
|
||||
key: &K,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
DM: DataMut,
|
||||
DB: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>,
|
||||
{
|
||||
let (cbt, ks) = key.get_cbt_key();
|
||||
|
||||
let mut lwe: LWE<Vec<u8>> = LWE::alloc_from_infos(bits); //TODO: add TakeLWE
|
||||
let (mut tmp_ggsw, scratch_1) = scratch.take_ggsw(res);
|
||||
for (bit, dst) in res.bits.iter_mut().enumerate() {
|
||||
bits.get_bit(self, bit, &mut lwe, ks, scratch_1);
|
||||
cbt.execute_to_constant(self, &mut tmp_ggsw, &lwe, 1, 1, scratch_1);
|
||||
dst.prepare(self, &tmp_ggsw, scratch_1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BDDKeyHelper<D: DataRef, BRA: BlindRotationAlgo, BE: Backend> {
|
||||
fn get_cbt_key(
|
||||
&self,
|
||||
@@ -274,21 +203,7 @@ pub trait BDDKeyHelper<D: DataRef, BRA: BlindRotationAlgo, BE: Backend> {
|
||||
);
|
||||
}
|
||||
|
||||
impl<D: DataMut, T: UnsignedInteger, BE: Backend> FheUintPrepared<D, T, BE> {
|
||||
pub fn prepare<BRA, M, O, K, DK>(&mut self, module: &M, other: &FheUint<O, T>, key: &K, scratch: &mut Scratch<BE>)
|
||||
where
|
||||
BRA: BlindRotationAlgo,
|
||||
O: DataRef,
|
||||
DK: DataRef,
|
||||
K: BDDKeyHelper<DK, BRA, BE>,
|
||||
M: FheUintPrepare<BRA, T, BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.fhe_uint_prepare(self, other, key, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FheUintBlockDebugPrepare<BRA: BlindRotationAlgo, T: UnsignedInteger, BE: Backend> {
|
||||
pub trait FheUintPrepareDebug<BRA: BlindRotationAlgo, T: UnsignedInteger, BE: Backend> {
|
||||
fn fhe_uint_debug_prepare<DM, DR0, DR1>(
|
||||
&self,
|
||||
res: &mut FheUintPreparedDebug<DM, T>,
|
||||
|
||||
@@ -5,8 +5,9 @@ use poulpy_backend::FFT64Ref;
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::tests::test_suite::{
|
||||
TestContext, test_bdd_add, test_bdd_and, test_bdd_or, test_bdd_prepare, test_bdd_sll, test_bdd_slt, test_bdd_sltu,
|
||||
test_bdd_sra, test_bdd_srl, test_bdd_sub, test_bdd_xor, test_fhe_uint_splice_u8, test_fhe_uint_splice_u16,
|
||||
test_glwe_blind_selection, test_glwe_to_glwe_blind_rotation, test_scalar_to_ggsw_blind_rotation,
|
||||
test_bdd_sra, test_bdd_srl, test_bdd_sub, test_bdd_xor, test_fhe_uint_sext, test_fhe_uint_splice_u8,
|
||||
test_fhe_uint_splice_u16, test_glwe_blind_selection, test_glwe_to_glwe_blind_rotation,
|
||||
test_scalar_to_ggsw_blind_rotation,
|
||||
},
|
||||
blind_rotation::CGGI,
|
||||
};
|
||||
@@ -14,6 +15,11 @@ use crate::tfhe::{
|
||||
static TEST_CONTEXT_CGGI_FFT64_REF: LazyLock<TestContext<CGGI, FFT64Ref>> =
|
||||
LazyLock::new(|| TestContext::<CGGI, FFT64Ref>::new());
|
||||
|
||||
#[test]
|
||||
fn test_fhe_uint_sext_fft64_ref() {
|
||||
test_fhe_uint_sext(&TEST_CONTEXT_CGGI_FFT64_REF);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_glwe_blind_selection_fft64_ref() {
|
||||
test_glwe_blind_selection(&TEST_CONTEXT_CGGI_FFT64_REF)
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
Add, BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared,
|
||||
Add, BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
And, BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared,
|
||||
And, BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -16,6 +16,51 @@ use crate::tfhe::{
|
||||
blind_rotation::BlindRotationAlgo,
|
||||
};
|
||||
|
||||
pub fn test_fhe_uint_sext<BRA: BlindRotationAlgo, BE: Backend>(test_context: &TestContext<BRA, BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptSk<BE> + GLWERotate<BE> + GLWETrace<BE> + GLWESub + GLWEAdd + GLWEDecrypt<BE>,
|
||||
ScratchOwned<BE>: ScratchOwnedAlloc<BE> + ScratchOwnedBorrow<BE>,
|
||||
Scratch<BE>: ScratchTakeBDD<u32, BE>,
|
||||
{
|
||||
let glwe_infos: GLWELayout = TEST_GLWE_INFOS;
|
||||
|
||||
let module: &Module<BE> = &test_context.module;
|
||||
let sk: &GLWESecretPrepared<Vec<u8>, BE> = &test_context.sk_glwe;
|
||||
let keys: &BDDKeyPrepared<Vec<u8>, BRA, BE> = &test_context.bdd_key;
|
||||
|
||||
let mut source_xa: Source = Source::new([2u8; 32]);
|
||||
let mut source_xe: Source = Source::new([3u8; 32]);
|
||||
|
||||
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(1 << 22);
|
||||
|
||||
let mut a_enc: FheUint<Vec<u8>, u32> = FheUint::<Vec<u8>, u32>::alloc_from_infos(&glwe_infos);
|
||||
|
||||
for j in 0..3 {
|
||||
for i in 0..32 {
|
||||
let a: u32 = 0xFFFFFFFF >> i;
|
||||
|
||||
a_enc.encrypt_sk(
|
||||
module,
|
||||
a,
|
||||
sk,
|
||||
&mut source_xa,
|
||||
&mut source_xe,
|
||||
scratch.borrow(),
|
||||
);
|
||||
|
||||
a_enc.sext(module, j, keys, scratch.borrow());
|
||||
|
||||
// println!("{:08x} -> {:08x} {:08x}", a, sext(a, j), a_enc.decrypt(module, sk, scratch.borrow()));
|
||||
|
||||
assert_eq!(sext(a, j), a_enc.decrypt(module, sk, scratch.borrow()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sext(x: u32, byte: usize) -> u32 {
|
||||
x | ((x >> (byte << 3)) & 1) * (0xFFFF_FFFF & (0xFFFF_FFFF << (byte << 3)))
|
||||
}
|
||||
|
||||
pub fn test_fhe_uint_splice_u8<BRA: BlindRotationAlgo, BE: Backend>(test_context: &TestContext<BRA, BE>)
|
||||
where
|
||||
Module<BE>: GLWEEncryptSk<BE> + GLWERotate<BE> + GLWETrace<BE> + GLWESub + GLWEAdd + GLWEDecrypt<BE>,
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Or,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Or,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPreparedDebug,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPreparedDebug, FheUintPreparedEncryptSk, FheUintPreparedFactory,
|
||||
tests::test_suite::{TEST_BASE2K, TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Sll,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Sll,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Slt,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Slt,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Sltu,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Sltu,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Sra,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Sra,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Srl,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Srl,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Sub,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Sub,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -11,8 +11,8 @@ use rand::RngCore;
|
||||
|
||||
use crate::tfhe::{
|
||||
bdd_arithmetic::{
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintBlockDebugPrepare,
|
||||
FheUintPrepare, FheUintPreparedEncryptSk, FheUintPreparedFactory, FheUintPrepared, Xor,
|
||||
BDDKeyEncryptSk, BDDKeyPrepared, BDDKeyPreparedFactory, ExecuteBDDCircuit2WTo1W, FheUint, FheUintPrepare,
|
||||
FheUintPrepareDebug, FheUintPrepared, FheUintPreparedEncryptSk, FheUintPreparedFactory, Xor,
|
||||
tests::test_suite::{TEST_GGSW_INFOS, TEST_GLWE_INFOS, TestContext},
|
||||
},
|
||||
blind_rotation::{BlindRotationAlgo, BlindRotationKey, BlindRotationKeyFactory},
|
||||
@@ -26,7 +26,7 @@ where
|
||||
+ GLWENoise<BE>
|
||||
+ FheUintPreparedFactory<u32, BE>
|
||||
+ FheUintPreparedEncryptSk<u32, BE>
|
||||
+ FheUintBlockDebugPrepare<BRA, u32, BE>
|
||||
+ FheUintPrepareDebug<BRA, u32, BE>
|
||||
+ BDDKeyEncryptSk<BRA, BE>
|
||||
+ BDDKeyPreparedFactory<BRA, BE>
|
||||
+ GGSWNoise<BE>
|
||||
|
||||
@@ -305,7 +305,7 @@ pub fn circuit_bootstrap_core<R, L, D, M, BRA: BlindRotationAlgo, BE: Backend>(
|
||||
scratch_2,
|
||||
);
|
||||
} else {
|
||||
tmp_glwe.trace(module, 0, module.log_n(), &res_glwe, &key.atk, scratch_2);
|
||||
tmp_glwe.trace(module, 0, &res_glwe, &key.atk, scratch_2);
|
||||
}
|
||||
|
||||
// let sk_glwe: &poulpy_core::layouts::GLWESecret<&[u8]> = &sk_glwe.to_ref();
|
||||
@@ -344,8 +344,6 @@ fn post_process<R, A, M, H, K, BE: Backend>(
|
||||
let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();
|
||||
let a: &GLWE<&[u8]> = &a.to_ref();
|
||||
|
||||
let log_n: usize = module.log_n();
|
||||
|
||||
let mut cts: HashMap<usize, &mut GLWE<Vec<u8>>> = HashMap::new();
|
||||
|
||||
// First partial trace, vanishes all coefficients which are not multiples of gap_in
|
||||
@@ -353,7 +351,6 @@ fn post_process<R, A, M, H, K, BE: Backend>(
|
||||
res.trace(
|
||||
module,
|
||||
module.log_n() - log_gap_in + 1,
|
||||
log_n,
|
||||
a,
|
||||
auto_keys,
|
||||
scratch,
|
||||
|
||||
Reference in New Issue
Block a user