mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
wip
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use poulpy_core::layouts::{Base2K, GLWECiphertext, GLWEInfos, GLWEPlaintextLayout, LWEInfos, Rank, TorusPrecision};
|
||||
use poulpy_core::layouts::{Base2K, GLWE, GLWEInfos, GLWEPlaintextLayout, LWEInfos, Rank, TorusPrecision};
|
||||
|
||||
use poulpy_core::{TakeGLWEPt, layouts::prepared::GLWESecretPrepared};
|
||||
use poulpy_hal::api::VecZnxBigAllocBytes;
|
||||
@@ -24,7 +24,7 @@ use crate::tfhe::bdd_arithmetic::{FromBits, ToBits, UnsignedInteger};
|
||||
|
||||
/// An FHE ciphertext encrypting the bits of an [UnsignedInteger].
|
||||
pub struct FheUintBlocks<D: Data, T: UnsignedInteger> {
|
||||
pub(crate) blocks: Vec<GLWECiphertext<D>>,
|
||||
pub(crate) blocks: Vec<GLWE<D>>,
|
||||
pub(crate) _base: u8,
|
||||
pub(crate) _phantom: PhantomData<T>,
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl<T: UnsignedInteger> FheUintBlocks<Vec<u8>, T> {
|
||||
pub(crate) fn alloc_with<BE: Backend>(module: &Module<BE>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> Self {
|
||||
Self {
|
||||
blocks: (0..T::WORD_SIZE)
|
||||
.map(|_| GLWECiphertext::alloc_with(module.n().into(), base2k, k, rank))
|
||||
.map(|_| GLWE::alloc(module.n().into(), base2k, k, rank))
|
||||
.collect(),
|
||||
_base: 1,
|
||||
_phantom: PhantomData,
|
||||
|
||||
@@ -60,7 +60,7 @@ impl<T: UnsignedInteger> FheUintBlocksPrepDebug<Vec<u8>, T> {
|
||||
) -> Self {
|
||||
Self {
|
||||
blocks: (0..T::WORD_SIZE)
|
||||
.map(|_| GGSW::alloc_with(module.n().into(), base2k, k, rank, dnum, dsize))
|
||||
.map(|_| GGSW::alloc(module.n().into(), base2k, k, rank, dnum, dsize))
|
||||
.collect(),
|
||||
_base: 1,
|
||||
_phantom: PhantomData,
|
||||
|
||||
@@ -2,7 +2,7 @@ use itertools::Itertools;
|
||||
use poulpy_core::{
|
||||
GLWEOperations, TakeGLWECtSlice, TakeGLWEPt, glwe_packing,
|
||||
layouts::{
|
||||
GLWECiphertext, GLWEInfos, GLWEPlaintextLayout, LWEInfos, TorusPrecision,
|
||||
GLWE, GLWEInfos, GLWEPlaintextLayout, LWEInfos, TorusPrecision,
|
||||
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared},
|
||||
},
|
||||
};
|
||||
@@ -24,14 +24,14 @@ use std::{collections::HashMap, marker::PhantomData};
|
||||
use crate::tfhe::bdd_arithmetic::{FromBits, ToBits, UnsignedInteger};
|
||||
|
||||
/// A FHE ciphertext encrypting a [UnsignedInteger].
|
||||
pub struct FheUintWord<D: Data, T: UnsignedInteger>(pub(crate) GLWECiphertext<D>, pub(crate) PhantomData<T>);
|
||||
pub struct FheUintWord<D: Data, T: UnsignedInteger>(pub(crate) GLWE<D>, pub(crate) PhantomData<T>);
|
||||
|
||||
impl<D: DataMut, T: UnsignedInteger> FheUintWord<D, T> {
|
||||
#[allow(dead_code)]
|
||||
fn post_process<ATK, BE: Backend>(
|
||||
&mut self,
|
||||
module: &Module<BE>,
|
||||
mut tmp_res: Vec<GLWECiphertext<&mut [u8]>>,
|
||||
mut tmp_res: Vec<GLWE<&mut [u8]>>,
|
||||
auto_keys: &HashMap<i64, AutomorphismKeyPrepared<ATK, BE>>,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
@@ -67,7 +67,7 @@ impl<D: DataMut, T: UnsignedInteger> FheUintWord<D, T> {
|
||||
// Repacks the GLWE ciphertexts bits
|
||||
let gap: usize = module.n() / T::WORD_SIZE;
|
||||
let log_gap: usize = (usize::BITS - (gap - 1).leading_zeros()) as usize;
|
||||
let mut cts: HashMap<usize, &mut GLWECiphertext<&mut [u8]>> = HashMap::new();
|
||||
let mut cts: HashMap<usize, &mut GLWE<&mut [u8]>> = HashMap::new();
|
||||
for (i, ct) in tmp_res.iter_mut().enumerate().take(T::WORD_SIZE) {
|
||||
cts.insert(i * gap, ct);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user