mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
partial fheuint preparation
This commit is contained in:
@@ -217,6 +217,18 @@ pub trait FheUintPrepare<BRA: BlindRotationAlgo, T: UnsignedInteger, BE: Backend
|
|||||||
DB: DataRef,
|
DB: DataRef,
|
||||||
DK: DataRef,
|
DK: DataRef,
|
||||||
K: BDDKeyHelper<DK, BRA, BE>;
|
K: BDDKeyHelper<DK, BRA, BE>;
|
||||||
|
fn fhe_uint_prepare_partial<DM, DB, DK, K>(
|
||||||
|
&self,
|
||||||
|
res: &mut FheUintPrepared<DM, T, BE>,
|
||||||
|
bits: &FheUint<DB, T>,
|
||||||
|
count: usize,
|
||||||
|
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>
|
impl<BRA: BlindRotationAlgo, BE: Backend, T: UnsignedInteger> FheUintPrepare<BRA, T, BE> for Module<BE>
|
||||||
@@ -259,6 +271,30 @@ where
|
|||||||
dst.prepare(self, &tmp_ggsw, scratch_1);
|
dst.prepare(self, &tmp_ggsw, scratch_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fhe_uint_prepare_partial<DM, DB, DK, K>(
|
||||||
|
&self,
|
||||||
|
res: &mut FheUintPrepared<DM, T, BE>,
|
||||||
|
bits: &FheUint<DB, T>,
|
||||||
|
count: usize,
|
||||||
|
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[0..count].iter_mut().enumerate() { // TODO: set the rest of the bits to a prepared zero GGSW
|
||||||
|
bits.get_bit_lwe(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> {
|
impl<D: DataMut, T: UnsignedInteger, BE: Backend> FheUintPrepared<D, T, BE> {
|
||||||
@@ -273,4 +309,15 @@ impl<D: DataMut, T: UnsignedInteger, BE: Backend> FheUintPrepared<D, T, BE> {
|
|||||||
{
|
{
|
||||||
module.fhe_uint_prepare(self, other, key, scratch);
|
module.fhe_uint_prepare(self, other, key, scratch);
|
||||||
}
|
}
|
||||||
|
pub fn prepare_partial<BRA, M, O, K, DK>(&mut self, module: &M, other: &FheUint<O, T>, count: usize, 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_partial(self, other, count, key, scratch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user