fixed missing implementations

This commit is contained in:
Jean-Philippe Bossuat
2025-10-18 12:56:30 +02:00
parent 0b8dcb1f16
commit a84ad06086
50 changed files with 444 additions and 419 deletions

View File

@@ -188,8 +188,8 @@ where
// Scratch space (4MB)
let mut scratch: ScratchOwned<B> = ScratchOwned::alloc(1 << 22);
let n_glwe: poulpy_core::layouts::RingDegree = params.cbt_infos.layout_brk.n_glwe();
let n_lwe: poulpy_core::layouts::RingDegree = params.cbt_infos.layout_brk.n_lwe();
let n_glwe: poulpy_core::layouts::Degree = params.cbt_infos.layout_brk.n_glwe();
let n_lwe: poulpy_core::layouts::Degree = params.cbt_infos.layout_brk.n_lwe();
let rank: poulpy_core::layouts::Rank = params.cbt_infos.layout_brk.rank;
let module: Module<B> = Module::<B>::new(n_glwe.as_u32() as u64);

View File

@@ -38,7 +38,7 @@ impl<D: DataRef, T: UnsignedInteger> LWEInfos for FheUintBlocks<D, T> {
self.blocks[0].k()
}
fn n(&self) -> poulpy_core::layouts::RingDegree {
fn n(&self) -> poulpy_core::layouts::Degree {
self.blocks[0].n()
}
}

View File

@@ -225,7 +225,7 @@ impl<D: DataRef, T: UnsignedInteger, B: Backend> LWEInfos for FheUintBlocksPrep<
self.blocks[0].k()
}
fn n(&self) -> poulpy_core::layouts::RingDegree {
fn n(&self) -> poulpy_core::layouts::Degree {
self.blocks[0].n()
}
}
@@ -256,7 +256,7 @@ impl<D: DataRef, T: UnsignedInteger> LWEInfos for FheUintBlocksPrepDebug<D, T> {
self.blocks[0].k()
}
fn n(&self) -> poulpy_core::layouts::RingDegree {
fn n(&self) -> poulpy_core::layouts::Degree {
self.blocks[0].n()
}
}

View File

@@ -87,7 +87,7 @@ impl<D: DataRef, T: UnsignedInteger> LWEInfos for FheUintWord<D, T> {
self.0.k()
}
fn n(&self) -> poulpy_core::layouts::RingDegree {
fn n(&self) -> poulpy_core::layouts::Degree {
self.0.n()
}
}

View File

@@ -1,6 +1,6 @@
#[cfg(test)]
use poulpy_core::layouts::{
AutomorphismKeyLayout, Base2K, Dnum, Dsize, GGSWLayout, GLWELayout, GLWEToLWEKeyLayout, Rank, RingDegree, TensorKeyLayout,
AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GGSWLayout, GLWELayout, GLWEToLWEKeyLayout, Rank, TensorKeyLayout,
TorusPrecision,
};
@@ -26,7 +26,7 @@ pub(crate) const TEST_RANK: u32 = 2;
#[cfg(test)]
pub(crate) static TEST_GLWE_INFOS: GLWELayout = GLWELayout {
n: RingDegree(TEST_N_GLWE),
n: Degree(TEST_N_GLWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(TEST_K_GLWE),
rank: Rank(TEST_RANK),
@@ -34,7 +34,7 @@ pub(crate) static TEST_GLWE_INFOS: GLWELayout = GLWELayout {
#[cfg(test)]
pub(crate) static TEST_GGSW_INFOS: GGSWLayout = GGSWLayout {
n: RingDegree(TEST_N_GLWE),
n: Degree(TEST_N_GLWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(TEST_K_GGSW),
rank: Rank(TEST_RANK),
@@ -46,15 +46,15 @@ pub(crate) static TEST_GGSW_INFOS: GGSWLayout = GGSWLayout {
pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout {
cbt: CircuitBootstrappingKeyLayout {
layout_brk: BlindRotationKeyLayout {
n_glwe: RingDegree(TEST_N_GLWE),
n_lwe: RingDegree(TEST_N_LWE),
n_glwe: Degree(TEST_N_GLWE),
n_lwe: Degree(TEST_N_LWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(52),
dnum: Dnum(3),
rank: Rank(TEST_RANK),
},
layout_atk: AutomorphismKeyLayout {
n: RingDegree(TEST_N_GLWE),
n: Degree(TEST_N_GLWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(52),
rank: Rank(TEST_RANK),
@@ -62,7 +62,7 @@ pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout {
dsize: Dsize(1),
},
layout_tsk: TensorKeyLayout {
n: RingDegree(TEST_N_GLWE),
n: Degree(TEST_N_GLWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(52),
rank: Rank(TEST_RANK),
@@ -71,7 +71,7 @@ pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout {
},
},
ks: GLWEToLWEKeyLayout {
n: RingDegree(TEST_N_GLWE),
n: Degree(TEST_N_GLWE),
base2k: Base2K(TEST_BASE2K),
k: TorusPrecision(39),
rank_in: Rank(TEST_RANK),

View File

@@ -8,7 +8,7 @@ use std::{fmt, marker::PhantomData};
use poulpy_core::{
Distribution,
layouts::{
Base2K, Dnum, Dsize, GGSW, GGSWInfos, GLWEInfos, LWEInfos, LWESecret, Rank, RingDegree, TorusPrecision,
Base2K, Degree, Dnum, Dsize, GGSW, GGSWInfos, GLWEInfos, LWEInfos, LWESecret, Rank, TorusPrecision,
prepared::GLWESecretPrepared,
},
};
@@ -19,8 +19,8 @@ use crate::tfhe::blind_rotation::BlindRotationAlgo;
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct BlindRotationKeyLayout {
pub n_glwe: RingDegree,
pub n_lwe: RingDegree,
pub n_glwe: Degree,
pub n_lwe: Degree,
pub base2k: Base2K,
pub k: TorusPrecision,
pub dnum: Dnum,
@@ -28,11 +28,11 @@ pub struct BlindRotationKeyLayout {
}
impl BlindRotationKeyInfos for BlindRotationKeyLayout {
fn n_glwe(&self) -> RingDegree {
fn n_glwe(&self) -> Degree {
self.n_glwe
}
fn n_lwe(&self) -> RingDegree {
fn n_lwe(&self) -> Degree {
self.n_lwe
}
}
@@ -62,7 +62,7 @@ impl LWEInfos for BlindRotationKeyLayout {
self.k
}
fn n(&self) -> RingDegree {
fn n(&self) -> Degree {
self.n_glwe
}
}
@@ -71,8 +71,8 @@ pub trait BlindRotationKeyInfos
where
Self: GGSWInfos,
{
fn n_glwe(&self) -> RingDegree;
fn n_lwe(&self) -> RingDegree;
fn n_glwe(&self) -> Degree;
fn n_lwe(&self) -> Degree;
}
pub trait BlindRotationKeyAlloc {
@@ -178,12 +178,12 @@ impl<D: DataRef, BRT: BlindRotationAlgo> WriterTo for BlindRotationKey<D, BRT> {
}
impl<D: DataRef, BRT: BlindRotationAlgo> BlindRotationKeyInfos for BlindRotationKey<D, BRT> {
fn n_glwe(&self) -> RingDegree {
fn n_glwe(&self) -> Degree {
self.n()
}
fn n_lwe(&self) -> RingDegree {
RingDegree(self.keys.len() as u32)
fn n_lwe(&self) -> Degree {
Degree(self.keys.len() as u32)
}
}
@@ -206,7 +206,7 @@ impl<D: DataRef, BRT: BlindRotationAlgo> LWEInfos for BlindRotationKey<D, BRT> {
self.keys[0].k()
}
fn n(&self) -> RingDegree {
fn n(&self) -> Degree {
self.keys[0].n()
}

View File

@@ -8,7 +8,7 @@ use std::{fmt, marker::PhantomData};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use poulpy_core::{
Distribution,
layouts::{Base2K, Dsize, GGSWInfos, GLWEInfos, LWEInfos, RingDegree, TorusPrecision, compressed::GGSWCompressed},
layouts::{Base2K, Degree, Dsize, GGSWInfos, GLWEInfos, LWEInfos, TorusPrecision, compressed::GGSWCompressed},
};
use crate::tfhe::blind_rotation::{BlindRotationAlgo, BlindRotationKeyInfos};
@@ -94,17 +94,17 @@ impl<D: DataRef, BRT: BlindRotationAlgo> WriterTo for BlindRotationKeyCompressed
}
impl<D: DataRef, BRA: BlindRotationAlgo> BlindRotationKeyInfos for BlindRotationKeyCompressed<D, BRA> {
fn n_glwe(&self) -> RingDegree {
fn n_glwe(&self) -> Degree {
self.n()
}
fn n_lwe(&self) -> RingDegree {
RingDegree(self.keys.len() as u32)
fn n_lwe(&self) -> Degree {
Degree(self.keys.len() as u32)
}
}
impl<D: DataRef, BRA: BlindRotationAlgo> LWEInfos for BlindRotationKeyCompressed<D, BRA> {
fn n(&self) -> RingDegree {
fn n(&self) -> Degree {
self.keys[0].n()
}

View File

@@ -8,7 +8,7 @@ use std::marker::PhantomData;
use poulpy_core::{
Distribution,
layouts::{
Base2K, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, RingDegree, TorusPrecision,
Base2K, Degree, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision,
prepared::{GGSWPrepared, Prepare, PrepareAlloc},
},
};
@@ -30,12 +30,12 @@ pub struct BlindRotationKeyPrepared<D: Data, BRT: BlindRotationAlgo, B: Backend>
}
impl<D: Data, BRT: BlindRotationAlgo, B: Backend> BlindRotationKeyInfos for BlindRotationKeyPrepared<D, BRT, B> {
fn n_glwe(&self) -> RingDegree {
fn n_glwe(&self) -> Degree {
self.n()
}
fn n_lwe(&self) -> RingDegree {
RingDegree(self.data.len() as u32)
fn n_lwe(&self) -> Degree {
Degree(self.data.len() as u32)
}
}
@@ -48,7 +48,7 @@ impl<D: Data, BRT: BlindRotationAlgo, B: Backend> LWEInfos for BlindRotationKeyP
self.data[0].k()
}
fn n(&self) -> RingDegree {
fn n(&self) -> Degree {
self.data[0].n()
}