This commit is contained in:
Pro7ech
2025-10-15 18:26:32 +02:00
parent 10817a8529
commit 2ea59310fb
57 changed files with 363 additions and 314 deletions

View File

@@ -13,7 +13,7 @@ use poulpy_hal::{
use poulpy_core::{
Distribution, GLWEOperations, TakeGLWE,
layouts::{GGSWInfos, GLWE, GLWEInfos, GLWEToMut, LWE, LWEToRef, LWEInfos},
layouts::{GGSWInfos, GLWE, GLWEInfos, GLWEToMut, LWE, LWEInfos, LWEToRef},
};
use crate::tfhe::blind_rotation::{

View File

@@ -8,7 +8,7 @@ use std::{fmt, marker::PhantomData};
use poulpy_core::{
Distribution,
layouts::{
Base2K, Degree, Dnum, Dsize, GGSW, GGSWInfos, GLWEInfos, LWEInfos, LWESecret, Rank, TorusPrecision,
Base2K, Dnum, Dsize, GGSW, GGSWInfos, GLWEInfos, LWEInfos, LWESecret, Rank, RingDegree, 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: Degree,
pub n_lwe: Degree,
pub n_glwe: RingDegree,
pub n_lwe: RingDegree,
pub base2k: Base2K,
pub k: TorusPrecision,
pub dnum: Dnum,
@@ -28,11 +28,11 @@ pub struct BlindRotationKeyLayout {
}
impl BlindRotationKeyInfos for BlindRotationKeyLayout {
fn n_glwe(&self) -> Degree {
fn n_glwe(&self) -> RingDegree {
self.n_glwe
}
fn n_lwe(&self) -> Degree {
fn n_lwe(&self) -> RingDegree {
self.n_lwe
}
}
@@ -62,7 +62,7 @@ impl LWEInfos for BlindRotationKeyLayout {
self.k
}
fn n(&self) -> Degree {
fn n(&self) -> RingDegree {
self.n_glwe
}
}
@@ -71,8 +71,8 @@ pub trait BlindRotationKeyInfos
where
Self: GGSWInfos,
{
fn n_glwe(&self) -> Degree;
fn n_lwe(&self) -> Degree;
fn n_glwe(&self) -> RingDegree;
fn n_lwe(&self) -> RingDegree;
}
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) -> Degree {
fn n_glwe(&self) -> RingDegree {
self.n()
}
fn n_lwe(&self) -> Degree {
Degree(self.keys.len() as u32)
fn n_lwe(&self) -> RingDegree {
RingDegree(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) -> Degree {
fn n(&self) -> RingDegree {
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, Degree, Dsize, GGSWInfos, GLWEInfos, LWEInfos, TorusPrecision, compressed::GGSWCompressed},
layouts::{Base2K, Dsize, GGSWInfos, GLWEInfos, LWEInfos, RingDegree, 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) -> Degree {
fn n_glwe(&self) -> RingDegree {
self.n()
}
fn n_lwe(&self) -> Degree {
Degree(self.keys.len() as u32)
fn n_lwe(&self) -> RingDegree {
RingDegree(self.keys.len() as u32)
}
}
impl<D: DataRef, BRA: BlindRotationAlgo> LWEInfos for BlindRotationKeyCompressed<D, BRA> {
fn n(&self) -> Degree {
fn n(&self) -> RingDegree {
self.keys[0].n()
}

View File

@@ -8,7 +8,7 @@ use std::marker::PhantomData;
use poulpy_core::{
Distribution,
layouts::{
Base2K, Degree, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision,
Base2K, Dnum, Dsize, GGSWInfos, GLWEInfos, LWEInfos, Rank, RingDegree, 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) -> Degree {
fn n_glwe(&self) -> RingDegree {
self.n()
}
fn n_lwe(&self) -> Degree {
Degree(self.data.len() as u32)
fn n_lwe(&self) -> RingDegree {
RingDegree(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) -> Degree {
fn n(&self) -> RingDegree {
self.data[0].n()
}

View File

@@ -23,7 +23,7 @@ use crate::tfhe::blind_rotation::{
};
use poulpy_core::layouts::{
GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWELayout, LWEToRef, LWEInfos, LWEPlaintext, LWESecret,
GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWEInfos, LWELayout, LWEPlaintext, LWESecret, LWEToRef,
prepared::{GLWESecretPrepared, PrepareAlloc},
};