mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
wip
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use poulpy_core::layouts::{
|
||||
Base2K, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision, prepared::GGSWCiphertextPrepared,
|
||||
};
|
||||
use poulpy_core::layouts::{Base2K, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision, prepared::GGSWPrepared};
|
||||
#[cfg(test)]
|
||||
use poulpy_core::{
|
||||
TakeGGSW,
|
||||
layouts::{GGSWCiphertext, prepared::GLWESecretPrepared},
|
||||
layouts::{GGSW, prepared::GLWESecretPrepared},
|
||||
};
|
||||
use poulpy_hal::{
|
||||
api::VmpPMatAlloc,
|
||||
@@ -29,7 +27,7 @@ use crate::tfhe::bdd_arithmetic::{FheUintBlocks, FheUintPrepare, ToBits, Unsigne
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) struct FheUintBlocksPrepDebug<D: Data, T: UnsignedInteger> {
|
||||
pub(crate) blocks: Vec<GGSWCiphertext<D>>,
|
||||
pub(crate) blocks: Vec<GGSW<D>>,
|
||||
pub(crate) _base: u8,
|
||||
pub(crate) _phantom: PhantomData<T>,
|
||||
}
|
||||
@@ -62,7 +60,7 @@ impl<T: UnsignedInteger> FheUintBlocksPrepDebug<Vec<u8>, T> {
|
||||
) -> Self {
|
||||
Self {
|
||||
blocks: (0..T::WORD_SIZE)
|
||||
.map(|_| GGSWCiphertext::alloc_with(module.n().into(), base2k, k, rank, dnum, dsize))
|
||||
.map(|_| GGSW::alloc_with(module.n().into(), base2k, k, rank, dnum, dsize))
|
||||
.collect(),
|
||||
_base: 1,
|
||||
_phantom: PhantomData,
|
||||
@@ -72,7 +70,7 @@ impl<T: UnsignedInteger> FheUintBlocksPrepDebug<Vec<u8>, T> {
|
||||
|
||||
/// A prepared FHE ciphertext encrypting the bits of an [UnsignedInteger].
|
||||
pub struct FheUintBlocksPrep<D: Data, B: Backend, T: UnsignedInteger> {
|
||||
pub(crate) blocks: Vec<GGSWCiphertextPrepared<D, B>>,
|
||||
pub(crate) blocks: Vec<GGSWPrepared<D, B>>,
|
||||
pub(crate) _base: u8,
|
||||
pub(crate) _phantom: PhantomData<T>,
|
||||
}
|
||||
@@ -103,7 +101,7 @@ where
|
||||
{
|
||||
Self {
|
||||
blocks: (0..T::WORD_SIZE)
|
||||
.map(|_| GGSWCiphertextPrepared::alloc_with(module, base2k, k, dnum, dsize, rank))
|
||||
.map(|_| GGSWPrepared::alloc_with(module, base2k, k, dnum, dsize, rank))
|
||||
.collect(),
|
||||
_base: 1,
|
||||
_phantom: PhantomData,
|
||||
|
||||
@@ -3,7 +3,7 @@ use poulpy_core::{
|
||||
GLWEOperations, TakeGLWECtSlice, TakeGLWEPt, glwe_packing,
|
||||
layouts::{
|
||||
GLWECiphertext, GLWEInfos, GLWEPlaintextLayout, LWEInfos, TorusPrecision,
|
||||
prepared::{GGLWEAutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
};
|
||||
use poulpy_hal::{
|
||||
@@ -32,7 +32,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUintWord<D, T> {
|
||||
&mut self,
|
||||
module: &Module<BE>,
|
||||
mut tmp_res: Vec<GLWECiphertext<&mut [u8]>>,
|
||||
auto_keys: &HashMap<i64, GGLWEAutomorphismKeyPrepared<ATK, BE>>,
|
||||
auto_keys: &HashMap<i64, AutomorphismKeyPrepared<ATK, BE>>,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
ATK: DataRef,
|
||||
|
||||
@@ -3,7 +3,7 @@ use poulpy_core::{
|
||||
GLWEExternalProductInplace, GLWEOperations, TakeGLWECtSlice,
|
||||
layouts::{
|
||||
GLWECiphertext, GLWECiphertextToMut, LWEInfos,
|
||||
prepared::{GGSWCiphertextPrepared, GGSWCiphertextPreparedToRef},
|
||||
prepared::{GGSWCiphertextPreparedToRef, GGSWPrepared},
|
||||
},
|
||||
};
|
||||
use poulpy_hal::{
|
||||
@@ -164,7 +164,7 @@ pub trait Cmux<BE: Backend> {
|
||||
out: &mut GLWECiphertext<O>,
|
||||
t: &GLWECiphertext<T>,
|
||||
f: &GLWECiphertext<F>,
|
||||
s: &GGSWCiphertextPrepared<S, BE>,
|
||||
s: &GGSWPrepared<S, BE>,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
O: DataMut,
|
||||
@@ -182,7 +182,7 @@ where
|
||||
out: &mut GLWECiphertext<O>,
|
||||
t: &GLWECiphertext<T>,
|
||||
f: &GLWECiphertext<F>,
|
||||
s: &GGSWCiphertextPrepared<S, BE>,
|
||||
s: &GGSWPrepared<S, BE>,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
O: DataMut,
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::tfhe::{
|
||||
use poulpy_core::{
|
||||
TakeGGSW, TakeGLWECt,
|
||||
layouts::{
|
||||
GLWESecret, GLWEToLWEKey, GLWEToLWEKeyLayout, LWECiphertext, LWESecret,
|
||||
GLWESecret, GLWEToLWEKeyLayout, GLWEToLWESwitchingKey, LWECiphertext, LWESecret,
|
||||
prepared::{GLWEToLWESwitchingKeyPrepared, Prepare, PrepareAlloc},
|
||||
},
|
||||
};
|
||||
@@ -56,7 +56,7 @@ where
|
||||
BRA: BlindRotationAlgo,
|
||||
{
|
||||
cbt: CircuitBootstrappingKey<CBT, BRA>,
|
||||
ks: GLWEToLWEKey<LWE>,
|
||||
ks: GLWEToLWESwitchingKey<LWE>,
|
||||
}
|
||||
|
||||
impl<BRA: BlindRotationAlgo> BDDKey<Vec<u8>, Vec<u8>, BRA> {
|
||||
@@ -98,7 +98,7 @@ impl<BRA: BlindRotationAlgo> BDDKey<Vec<u8>, Vec<u8>, BRA> {
|
||||
+ VecZnxAutomorphismInplace<BE>,
|
||||
Scratch<BE>: TakeVecZnxDft<BE> + ScratchAvailable + TakeVecZnx + TakeScalarZnx + TakeSvpPPol<BE> + TakeVecZnxBig<BE>,
|
||||
{
|
||||
let mut ks: GLWEToLWEKey<Vec<u8>> = GLWEToLWEKey::alloc(&infos.ks_infos());
|
||||
let mut ks: GLWEToLWESwitchingKey<Vec<u8>> = GLWEToLWESwitchingKey::alloc(&infos.ks_infos());
|
||||
ks.encrypt_sk(module, sk_lwe, sk_glwe, source_xa, source_xe, scratch);
|
||||
|
||||
Self {
|
||||
@@ -131,7 +131,7 @@ impl<CBT: DataMut, LWE: DataMut, BRA: BlindRotationAlgo, BE: Backend> PrepareAll
|
||||
for BDDKey<CBT, LWE, BRA>
|
||||
where
|
||||
CircuitBootstrappingKey<CBT, BRA>: PrepareAlloc<BE, CircuitBootstrappingKeyPrepared<CBT, BRA, BE>>,
|
||||
GLWEToLWEKey<LWE>: PrepareAlloc<BE, GLWEToLWESwitchingKeyPrepared<LWE, BE>>,
|
||||
GLWEToLWESwitchingKey<LWE>: PrepareAlloc<BE, GLWEToLWESwitchingKeyPrepared<LWE, BE>>,
|
||||
{
|
||||
fn prepare_alloc(&self, module: &Module<BE>, scratch: &mut Scratch<BE>) -> BDDKeyPrepared<CBT, LWE, BRA, BE> {
|
||||
BDDKeyPrepared {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(test)]
|
||||
use poulpy_core::layouts::{
|
||||
Base2K, Degree, Dnum, Dsize, GGLWEAutomorphismKeyLayout, GGLWETensorKeyLayout, GGSWCiphertextLayout, GLWECiphertextLayout,
|
||||
GLWEToLWEKeyLayout, Rank, TorusPrecision,
|
||||
AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GGSWCiphertextLayout, GLWECiphertextLayout, GLWEToLWEKeyLayout, Rank,
|
||||
TensorKeyLayout, TorusPrecision,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -53,7 +53,7 @@ pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout {
|
||||
dnum: Dnum(3),
|
||||
rank: Rank(TEST_RANK),
|
||||
},
|
||||
layout_atk: GGLWEAutomorphismKeyLayout {
|
||||
layout_atk: AutomorphismKeyLayout {
|
||||
n: Degree(TEST_N_GLWE),
|
||||
base2k: Base2K(TEST_BASE2K),
|
||||
k: TorusPrecision(52),
|
||||
@@ -61,7 +61,7 @@ pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout {
|
||||
dnum: Dnum(3),
|
||||
dsize: Dsize(1),
|
||||
},
|
||||
layout_tsk: GGLWETensorKeyLayout {
|
||||
layout_tsk: TensorKeyLayout {
|
||||
n: Degree(TEST_N_GLWE),
|
||||
base2k: Base2K(TEST_BASE2K),
|
||||
k: TorusPrecision(52),
|
||||
|
||||
Reference in New Issue
Block a user