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

@@ -1,5 +1,5 @@
use poulpy_core::layouts::{ use poulpy_core::layouts::{
Base2K, Degree, Dnum, Dsize, GGSW, GGSWLayout, GLWE, GLWELayout, GLWESecret, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGSW, GGSWLayout, GLWE, GLWELayout, GLWESecret, Rank, RingDegree, TorusPrecision,
prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc}, prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc},
}; };
use std::hint::black_box; use std::hint::black_box;
@@ -28,7 +28,7 @@ fn bench_external_product_glwe_fft64(c: &mut Criterion) {
fn runner(p: Params) -> impl FnMut() { fn runner(p: Params) -> impl FnMut() {
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n); let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
let n: Degree = Degree(module.n() as u32); let n: RingDegree = RingDegree(module.n() as u32);
let base2k: Base2K = p.base2k; let base2k: Base2K = p.base2k;
let k_ct_in: TorusPrecision = p.k_ct_in; let k_ct_in: TorusPrecision = p.k_ct_in;
let k_ct_out: TorusPrecision = p.k_ct_out; let k_ct_out: TorusPrecision = p.k_ct_out;
@@ -137,7 +137,7 @@ fn bench_external_product_glwe_inplace_fft64(c: &mut Criterion) {
fn runner(p: Params) -> impl FnMut() { fn runner(p: Params) -> impl FnMut() {
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n); let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
let n: Degree = Degree(module.n() as u32); let n: RingDegree = RingDegree(module.n() as u32);
let base2k: Base2K = p.base2k; let base2k: Base2K = p.base2k;
let k_glwe: TorusPrecision = p.k_ct; let k_glwe: TorusPrecision = p.k_ct;
let k_ggsw: TorusPrecision = p.k_ggsw; let k_ggsw: TorusPrecision = p.k_ggsw;

View File

@@ -1,6 +1,6 @@
use poulpy_core::layouts::{ use poulpy_core::layouts::{
AutomorphismKey, AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GLWE, GLWELayout, GLWESecret, GLWESwitchingKey, AutomorphismKey, AutomorphismKeyLayout, Base2K, Dnum, Dsize, GLWE, GLWELayout, GLWESecret, GLWESwitchingKey,
GLWESwitchingKeyLayout, Rank, TorusPrecision, GLWESwitchingKeyLayout, Rank, RingDegree, TorusPrecision,
prepared::{AutomorphismKeyPrepared, GLWESecretPrepared, GLWESwitchingKeyPrepared, PrepareAlloc}, prepared::{AutomorphismKeyPrepared, GLWESecretPrepared, GLWESwitchingKeyPrepared, PrepareAlloc},
}; };
use std::{hint::black_box, time::Duration}; use std::{hint::black_box, time::Duration};
@@ -29,7 +29,7 @@ fn bench_keyswitch_glwe_fft64(c: &mut Criterion) {
fn runner(p: Params) -> impl FnMut() { fn runner(p: Params) -> impl FnMut() {
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n); let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
let n: Degree = Degree(module.n() as u32); let n: RingDegree = RingDegree(module.n() as u32);
let base2k: Base2K = p.base2k; let base2k: Base2K = p.base2k;
let k_glwe_in: TorusPrecision = p.k_ct_in; let k_glwe_in: TorusPrecision = p.k_ct_in;
let k_glwe_out: TorusPrecision = p.k_ct_out; let k_glwe_out: TorusPrecision = p.k_ct_out;
@@ -148,7 +148,7 @@ fn bench_keyswitch_glwe_inplace_fft64(c: &mut Criterion) {
fn runner(p: Params) -> impl FnMut() { fn runner(p: Params) -> impl FnMut() {
let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n); let module: Module<FFT64Spqlios> = Module::<FFT64Spqlios>::new(1 << p.log_n);
let n: Degree = Degree(module.n() as u32); let n: RingDegree = RingDegree(module.n() as u32);
let base2k: Base2K = p.base2k; let base2k: Base2K = p.base2k;
let k_ct: TorusPrecision = p.k_ct; let k_ct: TorusPrecision = p.k_ct;
let k_ksk: TorusPrecision = p.k_ksk; let k_ksk: TorusPrecision = p.k_ksk;

View File

@@ -2,7 +2,7 @@ use poulpy_backend::cpu_spqlios::FFT64Spqlios;
use poulpy_core::{ use poulpy_core::{
GLWEOperations, SIGMA, GLWEOperations, SIGMA,
layouts::{ layouts::{
Base2K, Degree, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, TorusPrecision, Base2K, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, RingDegree, TorusPrecision,
prepared::{GLWESecretPrepared, PrepareAlloc}, prepared::{GLWESecretPrepared, PrepareAlloc},
}, },
}; };
@@ -16,7 +16,7 @@ fn main() {
// Ring degree // Ring degree
let log_n: usize = 10; let log_n: usize = 10;
let n: Degree = Degree(1 << log_n); let n: RingDegree = RingDegree(1 << log_n);
// Base-2-k (implicit digit decomposition) // Base-2-k (implicit digit decomposition)
let base2k: Base2K = Base2K(14); let base2k: Base2K = Base2K(14);

View File

@@ -7,7 +7,7 @@ use poulpy_hal::{
use crate::{ use crate::{
encryption::compressed::gglwe_ct::GGLWECompressedEncryptSk, encryption::compressed::gglwe_ct::GGLWECompressedEncryptSk,
layouts::{ layouts::{
Degree, GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, RingDegree,
compressed::{GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedToMut}, compressed::{GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedToMut},
prepared::GLWESecretPrepared, prepared::GLWESecretPrepared,
}, },
@@ -110,7 +110,7 @@ where
); );
}); });
let (mut sk_out_tmp, scratch_2) = scratch_1.take_glwe_secret_prepared(Degree(n as u32), sk_out.rank()); let (mut sk_out_tmp, scratch_2) = scratch_1.take_glwe_secret_prepared(RingDegree(n as u32), sk_out.rank());
{ {
let (mut tmp, _) = scratch_2.take_scalar_znx(n, 1); let (mut tmp, _) = scratch_2.take_scalar_znx(n, 1);
(0..sk_out.rank().into()).for_each(|i| { (0..sk_out.rank().into()).for_each(|i| {

View File

@@ -9,7 +9,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Degree, GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, prepared::GLWESecretPrepared, GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, RingDegree, prepared::GLWESecretPrepared,
}; };
impl GLWESwitchingKey<Vec<u8>> { impl GLWESwitchingKey<Vec<u8>> {
@@ -85,7 +85,7 @@ impl<DataSelf: DataMut> GLWESwitchingKey<DataSelf> {
); );
}); });
let (mut sk_out_tmp, scratch_2) = scratch_1.take_glwe_secret_prepared(Degree(n as u32), sk_out.rank()); let (mut sk_out_tmp, scratch_2) = scratch_1.take_glwe_secret_prepared(RingDegree(n as u32), sk_out.rank());
{ {
let (mut tmp, _) = scratch_2.take_scalar_znx(n, 1); let (mut tmp, _) = scratch_2.take_scalar_znx(n, 1);
(0..sk_out.rank().into()).for_each(|i| { (0..sk_out.rank().into()).for_each(|i| {

View File

@@ -10,7 +10,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Degree, GGLWEInfos, GLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, Rank, TensorKey, prepared::GLWESecretPrepared, GGLWEInfos, GLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, Rank, RingDegree, TensorKey, prepared::GLWESecretPrepared,
}; };
impl TensorKey<Vec<u8>> { impl TensorKey<Vec<u8>> {
@@ -23,7 +23,7 @@ impl TensorKey<Vec<u8>> {
+ module.bytes_of_vec_znx_dft(infos.rank_out().into(), 1) + module.bytes_of_vec_znx_dft(infos.rank_out().into(), 1)
+ module.bytes_of_vec_znx_big(1, 1) + module.bytes_of_vec_znx_big(1, 1)
+ module.bytes_of_vec_znx_dft(1, 1) + module.bytes_of_vec_znx_dft(1, 1)
+ GLWESecret::bytes_of(Degree(module.n() as u32), Rank(1)) + GLWESecret::bytes_of(RingDegree(module.n() as u32), Rank(1))
+ GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos) + GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos)
} }
} }
@@ -64,7 +64,7 @@ impl<DataSelf: DataMut> TensorKey<DataSelf> {
assert_eq!(self.n(), sk.n()); assert_eq!(self.n(), sk.n());
} }
let n: Degree = sk.n(); let n: RingDegree = sk.n();
let rank: Rank = self.rank_out(); let rank: Rank = self.rank_out();
let (mut sk_dft_prep, scratch_1) = scratch.take_glwe_secret_prepared(n, rank); let (mut sk_dft_prep, scratch_1) = scratch.take_glwe_secret_prepared(n, rank);

View File

@@ -10,7 +10,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Degree, GGLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, LWESecret, LWESwitchingKey, Rank, prepared::GLWESecretPrepared, GGLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, LWESecret, LWESwitchingKey, Rank, RingDegree,
prepared::GLWESecretPrepared,
}; };
impl LWESwitchingKey<Vec<u8>> { impl LWESwitchingKey<Vec<u8>> {
@@ -34,7 +35,7 @@ impl LWESwitchingKey<Vec<u8>> {
1, 1,
"rank_out > 1 is not supported for LWESwitchingKey" "rank_out > 1 is not supported for LWESwitchingKey"
); );
GLWESecret::bytes_of(Degree(module.n() as u32), Rank(1)) GLWESecret::bytes_of(RingDegree(module.n() as u32), Rank(1))
+ GLWESecretPrepared::bytes_of(module, Rank(1)) + GLWESecretPrepared::bytes_of(module, Rank(1))
+ GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos) + GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos)
} }

View File

@@ -9,7 +9,7 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Degree, GGLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, LWESecret, LWEToGLWESwitchingKey, Rank}; use crate::layouts::{GGLWEInfos, GLWESecret, GLWESwitchingKey, LWEInfos, LWESecret, LWEToGLWESwitchingKey, Rank, RingDegree};
impl LWEToGLWESwitchingKey<Vec<u8>> { impl LWEToGLWESwitchingKey<Vec<u8>> {
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
@@ -22,7 +22,8 @@ impl LWEToGLWESwitchingKey<Vec<u8>> {
Rank(1), Rank(1),
"rank_in != 1 is not supported for LWEToGLWESwitchingKey" "rank_in != 1 is not supported for LWEToGLWESwitchingKey"
); );
GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos) + GLWESecret::bytes_of(Degree(module.n() as u32), infos.rank_in()) GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos)
+ GLWESecret::bytes_of(RingDegree(module.n() as u32), infos.rank_in())
} }
} }

View File

@@ -1,22 +1,48 @@
use poulpy_hal::{ use poulpy_hal::{
api::{ api::ScratchAvailable,
ScratchAvailable, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxCopy, VecZnxDftApply, layouts::{Backend, DataMut, Module, Scratch, ZnxView, ZnxViewMut, ZnxZero},
VecZnxDftBytesOf, VecZnxIdftApplyConsume, VecZnxNormalize, VecZnxNormalizeTmpBytes, VmpApplyDftToDft,
VmpApplyDftToDftAdd, VmpApplyDftToDftTmpBytes,
},
layouts::{Backend, DataMut, DataRef, Module, Scratch, ZnxView, ZnxViewMut, ZnxZero},
}; };
use crate::{ use crate::{
ScratchTakeCore,
keyswitching::glwe_ct::GLWEKeySwitch, keyswitching::glwe_ct::GLWEKeySwitch,
layouts::{prepared::LWESwitchingKeyPrepared, GGLWEInfos, GLWEAlloc, GLWELayout, GetDegree, LWEToRef, LWEInfos, Rank, TorusPrecision, GLWE, LWE}, layouts::{
GGLWEInfos, GLWE, GLWEAlloc, GLWELayout, LWE, LWEInfos, LWEToMut, LWEToRef, Rank, TorusPrecision,
prepared::{LWESwitchingKeyPrepared, LWESwitchingKeyPreparedToRef},
},
}; };
impl LWE<Vec<u8>> {
pub fn keyswitch_tmp_bytes<M, R, A, K, BE: Backend>(module: &M, res_infos: &R, a_infos: &A, key_infos: &K) -> usize
where
R: LWEInfos,
A: LWEInfos,
K: GGLWEInfos,
M: LWEKeySwitch<BE>,
{
module.lwe_keyswitch_tmp_bytes(res_infos, a_infos, key_infos)
}
}
impl<D: DataMut> LWE<D> {
pub fn keyswitch<M, A, K, BE: Backend>(&mut self, module: &M, a: &A, ksk: &K, scratch: &mut Scratch<BE>)
where
A: LWEToRef,
K: LWESwitchingKeyPreparedToRef<BE>,
Scratch<BE>: ScratchTakeCore<BE>,
M: LWEKeySwitch<BE>,
{
module.lwe_keyswitch(self, a, ksk, scratch);
}
}
impl<BE: Backend> LWEKeySwitch<BE> for Module<BE> where Self: LWEKeySwitch<BE> {}
pub trait LWEKeySwitch<BE: Backend> pub trait LWEKeySwitch<BE: Backend>
where where
Self: GLWEKeySwitch<BE> + GLWEAlloc, Self: GLWEKeySwitch<BE> + GLWEAlloc,
{ {
fn keyswitch_tmp_bytes<B: Backend, R, A, K>(&self, res_infos: &R, a_infos: &A, key_infos: &K) -> usize fn lwe_keyswitch_tmp_bytes<R, A, K>(&self, res_infos: &R, a_infos: &A, key_infos: &K) -> usize
where where
R: LWEInfos, R: LWEInfos,
A: LWEInfos, A: LWEInfos,
@@ -25,14 +51,14 @@ where
let max_k: TorusPrecision = a_infos.k().max(res_infos.k()); let max_k: TorusPrecision = a_infos.k().max(res_infos.k());
let glwe_a_infos: GLWELayout = GLWELayout { let glwe_a_infos: GLWELayout = GLWELayout {
n: GetDegree::n(self), n: self.ring_degree(),
base2k: a_infos.base2k(), base2k: a_infos.base2k(),
k: max_k, k: max_k,
rank: Rank(1), rank: Rank(1),
}; };
let glwe_res_infos: GLWELayout = GLWELayout { let glwe_res_infos: GLWELayout = GLWELayout {
n: GetDegree::n(self), n: self.ring_degree(),
base2k: res_infos.base2k(), base2k: res_infos.base2k(),
k: max_k, k: max_k,
rank: Rank(1), rank: Rank(1),
@@ -45,39 +71,46 @@ where
glwe_in + glwe_out + ks glwe_in + glwe_out + ks
} }
fn keyswitch<A, DKs, B: Backend>( fn lwe_keyswitch<R, A, K>(&self, res: &mut R, a: &A, ksk: &K, scratch: &mut Scratch<BE>)
&mut self, where
module: &Module<B>, R: LWEToMut,
a: &A,
ksk: &K,
scratch: &mut Scratch<B>,
) where
A: LWEToRef, A: LWEToRef,
DKs: DataRef, K: LWESwitchingKeyPreparedToRef<BE>,
Scratch<B>: ScratchAvailable, Scratch<BE>: ScratchTakeCore<BE>,
{ {
assert!(self.n() <= module.n() as u32); let res: &mut LWE<&mut [u8]> = &mut res.to_mut();
assert!(a.n() <= module.n() as u32); let a: &LWE<&[u8]> = &a.to_ref();
assert!(scratch.available() >= LWE::keyswitch_tmp_bytes(module, self, a, ksk)); let ksk: &LWESwitchingKeyPrepared<&[u8], BE> = &ksk.to_ref();
let max_k: TorusPrecision = self.k().max(a.k()); assert!(res.n().as_usize() <= self.n());
assert!(a.n().as_usize() <= self.n());
assert_eq!(ksk.n(), self.n() as u32);
assert!(scratch.available() >= self.lwe_keyswitch_tmp_bytes(res, a, ksk));
let max_k: TorusPrecision = res.k().max(a.k());
let a_size: usize = a.k().div_ceil(ksk.base2k()) as usize; let a_size: usize = a.k().div_ceil(ksk.base2k()) as usize;
let (mut glwe_in, scratch_1) = scratch.take_glwe_ct(&GLWELayout { let (mut glwe_in, scratch_1) = scratch.take_glwe_ct(
self,
&GLWELayout {
n: ksk.n(), n: ksk.n(),
base2k: a.base2k(), base2k: a.base2k(),
k: max_k, k: max_k,
rank: Rank(1), rank: Rank(1),
}); },
);
glwe_in.data.zero(); glwe_in.data.zero();
let (mut glwe_out, scratch_1) = scratch_1.take_glwe_ct(&GLWELayout { let (mut glwe_out, scratch_1) = scratch_1.take_glwe_ct(
self,
&GLWELayout {
n: ksk.n(), n: ksk.n(),
base2k: self.base2k(), base2k: res.base2k(),
k: max_k, k: max_k,
rank: Rank(1), rank: Rank(1),
}); },
);
let n_lwe: usize = a.n().into(); let n_lwe: usize = a.n().into();
@@ -87,13 +120,7 @@ where
glwe_in.data.at_mut(1, i)[..n_lwe].copy_from_slice(&data_lwe[1..]); glwe_in.data.at_mut(1, i)[..n_lwe].copy_from_slice(&data_lwe[1..]);
} }
glwe_out.keyswitch(module, &glwe_in, &ksk.0, scratch_1); self.glwe_keyswitch(&mut glwe_out, &glwe_in, &ksk.0, scratch_1);
self.sample_extract(&glwe_out); res.sample_extract(&glwe_out);
} }
} }
impl LWE<Vec<u8>> {}
impl<DLwe: DataMut> LWE<DLwe> {
}

View File

@@ -4,7 +4,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
AutomorphismKey, AutomorphismKeyToMut, Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision, AutomorphismKey, AutomorphismKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, RingDegree,
TorusPrecision,
compressed::{ compressed::{
GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,
GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,
@@ -21,7 +22,7 @@ pub struct AutomorphismKeyCompressed<D: Data> {
} }
impl<D: Data> LWEInfos for AutomorphismKeyCompressed<D> { impl<D: Data> LWEInfos for AutomorphismKeyCompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }

View File

@@ -7,7 +7,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWE, GGLWEInfos, GGLWEToMut, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWE, GGLWEInfos, GGLWEToMut, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
compressed::{GLWECompressed, GLWEDecompress}, compressed::{GLWECompressed, GLWEDecompress},
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -24,8 +24,8 @@ pub struct GGLWECompressed<D: Data> {
} }
impl<D: Data> LWEInfos for GGLWECompressed<D> { impl<D: Data> LWEInfos for GGLWECompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn base2k(&self) -> Base2K { fn base2k(&self) -> Base2K {
@@ -88,7 +88,7 @@ impl<D: DataRef> fmt::Display for GGLWECompressed<D> {
pub trait GGLWECompressedAlloc pub trait GGLWECompressedAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_gglwe_compressed( fn alloc_gglwe_compressed(
&self, &self,
@@ -115,7 +115,7 @@ where
GGLWECompressed { GGLWECompressed {
data: MatZnx::alloc( data: MatZnx::alloc(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
rank_in.into(), rank_in.into(),
1, 1,
@@ -133,7 +133,7 @@ where
where where
A: GGLWEInfos, A: GGLWEInfos,
{ {
assert_eq!(infos.n(), self.n()); assert_eq!(infos.n(), self.ring_degree());
self.alloc_gglwe_compressed( self.alloc_gglwe_compressed(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -160,7 +160,7 @@ where
); );
MatZnx::bytes_of( MatZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
rank_in.into(), rank_in.into(),
1, 1,
@@ -172,7 +172,7 @@ where
where where
A: GGLWEInfos, A: GGLWEInfos,
{ {
assert_eq!(infos.n(), self.n()); assert_eq!(infos.n(), self.ring_degree());
self.bytes_of_gglwe_compressed( self.bytes_of_gglwe_compressed(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -183,7 +183,7 @@ where
} }
} }
impl<B: Backend> GGLWECompressedAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GGLWECompressedAlloc for Module<B> where Self: GetRingDegree {}
impl GGLWECompressed<Vec<u8>> { impl GGLWECompressed<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -4,8 +4,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToMut, LWEInfos,
LWEInfos, Rank, TorusPrecision, Rank, RingDegree, TorusPrecision,
compressed::{GGLWECompressed, GGLWECompressedAlloc, GGLWECompressedToMut, GGLWECompressedToRef, GGLWEDecompress}, compressed::{GGLWECompressed, GGLWECompressedAlloc, GGLWECompressedToMut, GGLWECompressedToRef, GGLWEDecompress},
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -19,7 +19,7 @@ pub struct GLWESwitchingKeyCompressed<D: Data> {
} }
impl<D: Data> LWEInfos for GLWESwitchingKeyCompressed<D> { impl<D: Data> LWEInfos for GLWESwitchingKeyCompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }

View File

@@ -4,7 +4,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, TensorKey, TensorKeyToMut, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, RingDegree, TensorKey, TensorKeyToMut, TorusPrecision,
compressed::{ compressed::{
GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,
GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,
@@ -19,7 +19,7 @@ pub struct TensorKeyCompressed<D: Data> {
} }
impl<D: Data> LWEInfos for TensorKeyCompressed<D> { impl<D: Data> LWEInfos for TensorKeyCompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.keys[0].n() self.keys[0].n()
} }

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGSW, GGSWInfos, GGSWToMut, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGSW, GGSWInfos, GGSWToMut, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
compressed::{GLWECompressed, GLWEDecompress}, compressed::{GLWECompressed, GLWEDecompress},
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -23,8 +23,8 @@ pub struct GGSWCompressed<D: Data> {
} }
impl<D: Data> LWEInfos for GGSWCompressed<D> { impl<D: Data> LWEInfos for GGSWCompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn base2k(&self) -> Base2K { fn base2k(&self) -> Base2K {
@@ -78,7 +78,7 @@ impl<D: DataMut> FillUniform for GGSWCompressed<D> {
pub trait GGSWCompressedAlloc pub trait GGSWCompressedAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_ggsw_compressed( fn alloc_ggsw_compressed(
&self, &self,
@@ -104,7 +104,7 @@ where
GGSWCompressed { GGSWCompressed {
data: MatZnx::alloc( data: MatZnx::alloc(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
(rank + 1).into(), (rank + 1).into(),
1, 1,
@@ -147,7 +147,7 @@ where
); );
MatZnx::bytes_of( MatZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
(rank + 1).into(), (rank + 1).into(),
1, 1,

View File

@@ -6,7 +6,9 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Base2K, Degree, GLWE, GLWEInfos, GLWEToMut, GetDegree, LWEInfos, Rank, SetGLWEInfos, TorusPrecision}; use crate::layouts::{
Base2K, GLWE, GLWEInfos, GLWEToMut, GetRingDegree, LWEInfos, Rank, RingDegree, SetGLWEInfos, TorusPrecision,
};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::fmt; use std::fmt;
@@ -32,8 +34,8 @@ impl<D: Data> LWEInfos for GLWECompressed<D> {
self.data.size() self.data.size()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
} }
impl<D: Data> GLWEInfos for GLWECompressed<D> { impl<D: Data> GLWEInfos for GLWECompressed<D> {
@@ -70,11 +72,15 @@ impl<D: DataMut> FillUniform for GLWECompressed<D> {
pub trait GLWECompressedAlloc pub trait GLWECompressedAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_glwe_compressed(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWECompressed<Vec<u8>> { fn alloc_glwe_compressed(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWECompressed<Vec<u8>> {
GLWECompressed { GLWECompressed {
data: VecZnx::alloc(self.n().into(), 1, k.0.div_ceil(base2k.0) as usize), data: VecZnx::alloc(
self.ring_degree().into(),
1,
k.0.div_ceil(base2k.0) as usize,
),
base2k, base2k,
k, k,
rank, rank,
@@ -86,24 +92,28 @@ where
where where
A: GLWEInfos, A: GLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.alloc_glwe_compressed(infos.base2k(), infos.k(), infos.rank()) self.alloc_glwe_compressed(infos.base2k(), infos.k(), infos.rank())
} }
fn bytes_of_glwe_compressed(&self, base2k: Base2K, k: TorusPrecision) -> usize { fn bytes_of_glwe_compressed(&self, base2k: Base2K, k: TorusPrecision) -> usize {
VecZnx::bytes_of(self.n().into(), 1, k.0.div_ceil(base2k.0) as usize) VecZnx::bytes_of(
self.ring_degree().into(),
1,
k.0.div_ceil(base2k.0) as usize,
)
} }
fn bytes_of_glwe_compressed_from_infos<A>(&self, infos: &A) -> usize fn bytes_of_glwe_compressed_from_infos<A>(&self, infos: &A) -> usize
where where
A: GLWEInfos, A: GLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.bytes_of_glwe_compressed(infos.base2k(), infos.k()) self.bytes_of_glwe_compressed(infos.base2k(), infos.k())
} }
} }
impl<B: Backend> GLWECompressedAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GLWECompressedAlloc for Module<B> where Self: GetRingDegree {}
impl GLWECompressed<Vec<u8>> { impl GLWECompressed<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
@@ -159,7 +169,7 @@ impl<D: DataRef> WriterTo for GLWECompressed<D> {
pub trait GLWEDecompress pub trait GLWEDecompress
where where
Self: GetDegree + VecZnxFillUniform + VecZnxCopy, Self: GetRingDegree + VecZnxFillUniform + VecZnxCopy,
{ {
fn decompress_glwe<R, O>(&self, res: &mut R, other: &O) fn decompress_glwe<R, O>(&self, res: &mut R, other: &O)
where where
@@ -171,10 +181,10 @@ where
let other: &GLWECompressed<&[u8]> = &other.to_ref(); let other: &GLWECompressed<&[u8]> = &other.to_ref();
assert_eq!( assert_eq!(
res.n(), res.n(),
self.n(), self.ring_degree(),
"invalid receiver: res.n()={} != other.n()={}", "invalid receiver: res.n()={} != other.n()={}",
res.n(), res.n(),
self.n() self.ring_degree()
); );
assert_eq!(res.lwe_layout(), other.lwe_layout()); assert_eq!(res.lwe_layout(), other.lwe_layout());
@@ -193,7 +203,7 @@ where
} }
} }
impl<B: Backend> GLWEDecompress for Module<B> where Self: GetDegree + VecZnxFillUniform + VecZnxCopy {} impl<B: Backend> GLWEDecompress for Module<B> where Self: GetRingDegree + VecZnxFillUniform + VecZnxCopy {}
impl<D: DataMut> GLWE<D> { impl<D: DataMut> GLWE<D> {
pub fn decompress<O, M>(&mut self, module: &M, other: &O) pub fn decompress<O, M>(&mut self, module: &M, other: &O)

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyToMut, LWEInfos, Rank, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyToMut, LWEInfos, Rank, RingDegree,
TorusPrecision, TorusPrecision,
compressed::{ compressed::{
GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,
@@ -26,7 +26,7 @@ impl<D: Data> LWEInfos for GLWEToLWESwitchingKeyCompressed<D> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }
fn size(&self) -> usize { fn size(&self) -> usize {

View File

@@ -9,7 +9,7 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Base2K, Degree, LWE, LWEInfos, LWEToMut, TorusPrecision}; use crate::layouts::{Base2K, LWE, LWEInfos, LWEToMut, RingDegree, TorusPrecision};
#[derive(PartialEq, Eq, Clone)] #[derive(PartialEq, Eq, Clone)]
pub struct LWECompressed<D: Data> { pub struct LWECompressed<D: Data> {
@@ -28,8 +28,8 @@ impl<D: Data> LWEInfos for LWECompressed<D> {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {

View File

@@ -4,7 +4,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKey, LWESwitchingKeyToMut, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKey, LWESwitchingKeyToMut, Rank, RingDegree,
TorusPrecision,
compressed::{ compressed::{
GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,
GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,
@@ -24,7 +25,7 @@ impl<D: Data> LWEInfos for LWESwitchingKeyCompressed<D> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }
fn size(&self) -> usize { fn size(&self) -> usize {

View File

@@ -4,7 +4,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyToMut, Rank, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyToMut, Rank, RingDegree,
TorusPrecision, TorusPrecision,
compressed::{ compressed::{
GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,
@@ -17,7 +17,7 @@ use std::fmt;
pub struct LWEToGLWESwitchingKeyCompressed<D: Data>(pub(crate) GLWESwitchingKeyCompressed<D>); pub struct LWEToGLWESwitchingKeyCompressed<D: Data>(pub(crate) GLWESwitchingKeyCompressed<D>);
impl<D: Data> LWEInfos for LWEToGLWESwitchingKeyCompressed<D> { impl<D: Data> LWEInfos for LWEToGLWESwitchingKeyCompressed<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -4,8 +4,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWE, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWE, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut,
GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -13,7 +13,7 @@ use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct AutomorphismKeyLayout { pub struct AutomorphismKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank: Rank, pub rank: Rank,
@@ -34,7 +34,7 @@ impl<D: Data> AutomorphismKey<D> {
} }
impl<D: Data> LWEInfos for AutomorphismKey<D> { impl<D: Data> LWEInfos for AutomorphismKey<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }
@@ -84,7 +84,7 @@ impl LWEInfos for AutomorphismKeyLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }

View File

@@ -5,7 +5,7 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Base2K, Degree, Dnum, Dsize, GLWE, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}; use crate::layouts::{Base2K, Dnum, Dsize, GLWE, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::fmt; use std::fmt;
@@ -37,7 +37,7 @@ pub trait SetGGLWEInfos {
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GGLWELayout { pub struct GGLWELayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank_in: Rank, pub rank_in: Rank,
@@ -55,7 +55,7 @@ impl LWEInfos for GGLWELayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }
@@ -101,8 +101,8 @@ impl<D: Data> LWEInfos for GGLWE<D> {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -162,7 +162,7 @@ impl<D: DataRef> fmt::Display for GGLWE<D> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!( write!(
f, f,
"(GGLWECiphertext: k={} base2k={} dsize={}) {}", "(GGLWE: k={} base2k={} dsize={}) {}",
self.k().0, self.k().0,
self.base2k().0, self.base2k().0,
self.dsize().0, self.dsize().0,
@@ -193,7 +193,7 @@ impl<D: DataMut> GGLWE<D> {
pub trait GGLWEAlloc pub trait GGLWEAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_gglwe( fn alloc_gglwe(
&self, &self,
@@ -220,7 +220,7 @@ where
GGLWE { GGLWE {
data: MatZnx::alloc( data: MatZnx::alloc(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
rank_in.into(), rank_in.into(),
(rank_out + 1).into(), (rank_out + 1).into(),
@@ -270,7 +270,7 @@ where
); );
MatZnx::bytes_of( MatZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
rank_in.into(), rank_in.into(),
(rank_out + 1).into(), (rank_out + 1).into(),
@@ -293,7 +293,7 @@ where
} }
} }
impl<B: Backend> GGLWEAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GGLWEAlloc for Module<B> where Self: GetRingDegree {}
impl GGLWE<Vec<u8>> { impl GGLWE<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -4,7 +4,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWE, GGLWEAlloc, GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWE, GLWEInfos, LWEInfos, Rank, Base2K, Dnum, Dsize, GGLWE, GGLWEAlloc, GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWE, GLWEInfos, LWEInfos, Rank, RingDegree,
TorusPrecision, TorusPrecision,
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -13,7 +13,7 @@ use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWESwitchingKeyLayout { pub struct GLWESwitchingKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank_in: Rank, pub rank_in: Rank,
@@ -23,7 +23,7 @@ pub struct GLWESwitchingKeyLayout {
} }
impl LWEInfos for GLWESwitchingKeyLayout { impl LWEInfos for GLWESwitchingKeyLayout {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -98,7 +98,7 @@ impl<D: DataRef> GLWESwtichingKeyGetMetaData for GLWESwitchingKey<D> {
} }
impl<D: Data> LWEInfos for GLWESwitchingKey<D> { impl<D: Data> LWEInfos for GLWESwitchingKey<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }

View File

@@ -4,8 +4,8 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut,
GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -13,7 +13,7 @@ use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct TensorKeyLayout { pub struct TensorKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank: Rank, pub rank: Rank,
@@ -27,7 +27,7 @@ pub struct TensorKey<D: Data> {
} }
impl<D: Data> LWEInfos for TensorKey<D> { impl<D: Data> LWEInfos for TensorKey<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.keys[0].n() self.keys[0].n()
} }
@@ -69,7 +69,7 @@ impl<D: Data> GGLWEInfos for TensorKey<D> {
} }
impl LWEInfos for TensorKeyLayout { impl LWEInfos for TensorKeyLayout {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
}; };
use std::fmt; use std::fmt;
use crate::layouts::{Base2K, Degree, Dnum, Dsize, GLWE, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}; use crate::layouts::{Base2K, Dnum, Dsize, GLWE, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision};
pub trait GGSWInfos pub trait GGSWInfos
where where
@@ -28,7 +28,7 @@ where
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GGSWLayout { pub struct GGSWLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank: Rank, pub rank: Rank,
@@ -45,7 +45,7 @@ impl LWEInfos for GGSWLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }
@@ -74,8 +74,8 @@ pub struct GGSW<D: Data> {
} }
impl<D: Data> LWEInfos for GGSW<D> { impl<D: Data> LWEInfos for GGSW<D> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn base2k(&self) -> Base2K { fn base2k(&self) -> Base2K {
@@ -152,11 +152,11 @@ impl<D: DataMut> GGSW<D> {
} }
} }
impl<B: Backend> GGSWAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GGSWAlloc for Module<B> where Self: GetRingDegree {}
pub trait GGSWAlloc pub trait GGSWAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_ggsw(&self, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> GGSW<Vec<u8>> { fn alloc_ggsw(&self, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> GGSW<Vec<u8>> {
let size: usize = k.0.div_ceil(base2k.0) as usize; let size: usize = k.0.div_ceil(base2k.0) as usize;
@@ -175,7 +175,7 @@ where
GGSW { GGSW {
data: MatZnx::alloc( data: MatZnx::alloc(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
(rank + 1).into(), (rank + 1).into(),
(rank + 1).into(), (rank + 1).into(),
@@ -216,7 +216,7 @@ where
); );
MatZnx::bytes_of( MatZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
dnum.into(), dnum.into(),
(rank + 1).into(), (rank + 1).into(),
(rank + 1).into(), (rank + 1).into(),

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Base2K, Degree, GetDegree, LWEInfos, Rank, TorusPrecision}; use crate::layouts::{Base2K, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::fmt; use std::fmt;
@@ -32,14 +32,14 @@ pub trait SetGLWEInfos {
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWELayout { pub struct GLWELayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank: Rank, pub rank: Rank,
} }
impl LWEInfos for GLWELayout { impl LWEInfos for GLWELayout {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -96,8 +96,8 @@ impl<D: Data> LWEInfos for GLWE<D> {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -148,12 +148,12 @@ impl<D: DataMut> FillUniform for GLWE<D> {
pub trait GLWEAlloc pub trait GLWEAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWE<Vec<u8>> { fn alloc_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWE<Vec<u8>> {
GLWE { GLWE {
data: VecZnx::alloc( data: VecZnx::alloc(
self.n().into(), self.ring_degree().into(),
(rank + 1).into(), (rank + 1).into(),
k.0.div_ceil(base2k.0) as usize, k.0.div_ceil(base2k.0) as usize,
), ),
@@ -171,7 +171,7 @@ where
fn bytes_of_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize { fn bytes_of_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
VecZnx::bytes_of( VecZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
(rank + 1).into(), (rank + 1).into(),
k.0.div_ceil(base2k.0) as usize, k.0.div_ceil(base2k.0) as usize,
) )
@@ -185,7 +185,7 @@ where
} }
} }
impl<B: Backend> GLWEAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GLWEAlloc for Module<B> where Self: GetRingDegree {}
impl GLWE<Vec<u8>> { impl GLWE<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -4,7 +4,7 @@ use poulpy_hal::layouts::{
use crate::{ use crate::{
dist::Distribution, dist::Distribution,
layouts::{Base2K, Degree, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}, layouts::{Base2K, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision},
}; };
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
@@ -18,7 +18,7 @@ pub struct GLWEPublicKey<D: Data> {
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWEPublicKeyLayout { pub struct GLWEPublicKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank: Rank, pub rank: Rank,
@@ -43,8 +43,8 @@ impl<D: Data> LWEInfos for GLWEPublicKey<D> {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -67,7 +67,7 @@ impl LWEInfos for GLWEPublicKeyLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -84,12 +84,12 @@ impl GLWEInfos for GLWEPublicKeyLayout {
pub trait GLWEPublicKeyAlloc pub trait GLWEPublicKeyAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWEPublicKey<Vec<u8>> { fn alloc_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWEPublicKey<Vec<u8>> {
GLWEPublicKey { GLWEPublicKey {
data: VecZnx::alloc( data: VecZnx::alloc(
self.n().into(), self.ring_degree().into(),
(rank + 1).into(), (rank + 1).into(),
k.0.div_ceil(base2k.0) as usize, k.0.div_ceil(base2k.0) as usize,
), ),
@@ -108,7 +108,7 @@ where
fn bytes_of_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize { fn bytes_of_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
VecZnx::bytes_of( VecZnx::bytes_of(
self.n().into(), self.ring_degree().into(),
(rank + 1).into(), (rank + 1).into(),
k.0.div_ceil(base2k.0) as usize, k.0.div_ceil(base2k.0) as usize,
) )
@@ -122,7 +122,7 @@ where
} }
} }
impl<B: Backend> GLWEPublicKeyAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GLWEPublicKeyAlloc for Module<B> where Self: GetRingDegree {}
impl GLWEPublicKey<Vec<u8>> { impl GLWEPublicKey<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -3,12 +3,12 @@ use std::fmt;
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, VecZnx, VecZnxToMut, VecZnxToRef, ZnxInfos}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, VecZnx, VecZnxToMut, VecZnxToRef, ZnxInfos};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, GLWE, GLWEInfos, GLWEToMut, GLWEToRef, GetDegree, LWEInfos, Rank, SetGLWEInfos, TorusPrecision, Base2K, GLWE, GLWEInfos, GLWEToMut, GLWEToRef, GetRingDegree, LWEInfos, Rank, RingDegree, SetGLWEInfos, TorusPrecision,
}; };
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWEPlaintextLayout { pub struct GLWEPlaintextLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
} }
@@ -22,7 +22,7 @@ impl LWEInfos for GLWEPlaintextLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }
@@ -62,8 +62,8 @@ impl<D: Data> LWEInfos for GLWEPlaintext<D> {
self.data.size() self.data.size()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
} }
@@ -87,11 +87,15 @@ impl<D: DataRef> fmt::Display for GLWEPlaintext<D> {
pub trait GLWEPlaintextAlloc pub trait GLWEPlaintextAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_glwe_plaintext(&self, base2k: Base2K, k: TorusPrecision) -> GLWEPlaintext<Vec<u8>> { fn alloc_glwe_plaintext(&self, base2k: Base2K, k: TorusPrecision) -> GLWEPlaintext<Vec<u8>> {
GLWEPlaintext { GLWEPlaintext {
data: VecZnx::alloc(self.n().into(), 1, k.0.div_ceil(base2k.0) as usize), data: VecZnx::alloc(
self.ring_degree().into(),
1,
k.0.div_ceil(base2k.0) as usize,
),
base2k, base2k,
k, k,
} }
@@ -105,7 +109,11 @@ where
} }
fn bytes_of_glwe_plaintext(&self, base2k: Base2K, k: TorusPrecision) -> usize { fn bytes_of_glwe_plaintext(&self, base2k: Base2K, k: TorusPrecision) -> usize {
VecZnx::bytes_of(self.n().into(), 1, k.0.div_ceil(base2k.0) as usize) VecZnx::bytes_of(
self.ring_degree().into(),
1,
k.0.div_ceil(base2k.0) as usize,
)
} }
fn bytes_of_glwe_plaintext_from_infos<A>(&self, infos: &A) -> usize fn bytes_of_glwe_plaintext_from_infos<A>(&self, infos: &A) -> usize
@@ -116,7 +124,7 @@ where
} }
} }
impl<B: Backend> GLWEPlaintextAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GLWEPlaintextAlloc for Module<B> where Self: GetRingDegree {}
impl GLWEPlaintext<Vec<u8>> { impl GLWEPlaintext<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -8,12 +8,12 @@ use poulpy_hal::{
use crate::{ use crate::{
dist::Distribution, dist::Distribution,
layouts::{Base2K, Degree, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}, layouts::{Base2K, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision},
}; };
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWESecretLayout { pub struct GLWESecretLayout {
pub n: Degree, pub n: RingDegree,
pub rank: Rank, pub rank: Rank,
} }
@@ -26,7 +26,7 @@ impl LWEInfos for GLWESecretLayout {
TorusPrecision(0) TorusPrecision(0)
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -55,8 +55,8 @@ impl<D: Data> LWEInfos for GLWESecret<D> {
TorusPrecision(0) TorusPrecision(0)
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -72,11 +72,11 @@ impl<D: Data> GLWEInfos for GLWESecret<D> {
pub trait GLWESecretAlloc pub trait GLWESecretAlloc
where where
Self: GetDegree, Self: GetRingDegree,
{ {
fn alloc_glwe_secret(&self, rank: Rank) -> GLWESecret<Vec<u8>> { fn alloc_glwe_secret(&self, rank: Rank) -> GLWESecret<Vec<u8>> {
GLWESecret { GLWESecret {
data: ScalarZnx::alloc(self.n().into(), rank.into()), data: ScalarZnx::alloc(self.ring_degree().into(), rank.into()),
dist: Distribution::NONE, dist: Distribution::NONE,
} }
} }
@@ -89,7 +89,7 @@ where
} }
fn bytes_of_glwe_secret(&self, rank: Rank) -> usize { fn bytes_of_glwe_secret(&self, rank: Rank) -> usize {
ScalarZnx::bytes_of(self.n().into(), rank.into()) ScalarZnx::bytes_of(self.ring_degree().into(), rank.into())
} }
fn bytes_of_glwe_secret_from_infos<A>(&self, infos: &A) -> usize fn bytes_of_glwe_secret_from_infos<A>(&self, infos: &A) -> usize
@@ -100,7 +100,7 @@ where
} }
} }
impl<B: Backend> GLWESecretAlloc for Module<B> where Self: GetDegree {} impl<B: Backend> GLWESecretAlloc for Module<B> where Self: GetRingDegree {}
impl GLWESecret<Vec<u8>> { impl GLWESecret<Vec<u8>> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

View File

@@ -4,15 +4,15 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut,
GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
use std::fmt; use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct GLWEToLWEKeyLayout { pub struct GLWEToLWEKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank_in: Rank, pub rank_in: Rank,
@@ -20,7 +20,7 @@ pub struct GLWEToLWEKeyLayout {
} }
impl LWEInfos for GLWEToLWEKeyLayout { impl LWEInfos for GLWEToLWEKeyLayout {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -70,7 +70,7 @@ impl<D: Data> LWEInfos for GLWEToLWESwitchingKey<D> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -5,11 +5,11 @@ use poulpy_hal::{
source::Source, source::Source,
}; };
use crate::layouts::{Base2K, Degree, TorusPrecision}; use crate::layouts::{Base2K, RingDegree, TorusPrecision};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
pub trait LWEInfos { pub trait LWEInfos {
fn n(&self) -> Degree; fn n(&self) -> RingDegree;
fn k(&self) -> TorusPrecision; fn k(&self) -> TorusPrecision;
fn max_k(&self) -> TorusPrecision { fn max_k(&self) -> TorusPrecision {
TorusPrecision(self.k().0 * self.size() as u32) TorusPrecision(self.k().0 * self.size() as u32)
@@ -34,7 +34,7 @@ pub trait SetLWEInfos {
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct LWELayout { pub struct LWELayout {
pub n: Degree, pub n: RingDegree,
pub k: TorusPrecision, pub k: TorusPrecision,
pub base2k: Base2K, pub base2k: Base2K,
} }
@@ -48,7 +48,7 @@ impl LWEInfos for LWELayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }
@@ -67,8 +67,8 @@ impl<D: Data> LWEInfos for LWE<D> {
fn k(&self) -> TorusPrecision { fn k(&self) -> TorusPrecision {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32 - 1) RingDegree(self.data.n() as u32 - 1)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -126,7 +126,7 @@ where
} }
pub trait LWEAlloc { pub trait LWEAlloc {
fn alloc_lwe(&self, n: Degree, base2k: Base2K, k: TorusPrecision) -> LWE<Vec<u8>> { fn alloc_lwe(&self, n: RingDegree, base2k: Base2K, k: TorusPrecision) -> LWE<Vec<u8>> {
LWE { LWE {
data: Zn::alloc((n + 1).into(), 1, k.0.div_ceil(base2k.0) as usize), data: Zn::alloc((n + 1).into(), 1, k.0.div_ceil(base2k.0) as usize),
k, k,
@@ -141,7 +141,7 @@ pub trait LWEAlloc {
self.alloc_lwe(infos.n(), infos.base2k(), infos.k()) self.alloc_lwe(infos.n(), infos.base2k(), infos.k())
} }
fn bytes_of_lwe(&self, n: Degree, base2k: Base2K, k: TorusPrecision) -> usize { fn bytes_of_lwe(&self, n: RingDegree, base2k: Base2K, k: TorusPrecision) -> usize {
Zn::bytes_of((n + 1).into(), 1, k.0.div_ceil(base2k.0) as usize) Zn::bytes_of((n + 1).into(), 1, k.0.div_ceil(base2k.0) as usize)
} }
@@ -164,7 +164,7 @@ impl LWE<Vec<u8>> {
module.alloc_lwe_from_infos(infos) module.alloc_lwe_from_infos(infos)
} }
pub fn alloc<M>(module: &M, n: Degree, base2k: Base2K, k: TorusPrecision) -> Self pub fn alloc<M>(module: &M, n: RingDegree, base2k: Base2K, k: TorusPrecision) -> Self
where where
M: LWEAlloc, M: LWEAlloc,
{ {
@@ -179,7 +179,7 @@ impl LWE<Vec<u8>> {
module.bytes_of_lwe_from_infos(infos) module.bytes_of_lwe_from_infos(infos)
} }
pub fn bytes_of<M>(module: &M, n: Degree, base2k: Base2K, k: TorusPrecision) -> usize pub fn bytes_of<M>(module: &M, n: RingDegree, base2k: Base2K, k: TorusPrecision) -> usize
where where
M: LWEAlloc, M: LWEAlloc,
{ {

View File

@@ -6,20 +6,20 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut,
GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct LWESwitchingKeyLayout { pub struct LWESwitchingKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub dnum: Dnum, pub dnum: Dnum,
} }
impl LWEInfos for LWESwitchingKeyLayout { impl LWEInfos for LWESwitchingKeyLayout {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
@@ -68,7 +68,7 @@ impl<D: Data> LWEInfos for LWESwitchingKey<D> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -2,7 +2,7 @@ use std::fmt;
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Zn, ZnToMut, ZnToRef, ZnxInfos}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Zn, ZnToMut, ZnToRef, ZnxInfos};
use crate::layouts::{Base2K, Degree, LWEInfos, TorusPrecision}; use crate::layouts::{Base2K, LWEInfos, RingDegree, TorusPrecision};
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct LWEPlaintextLayout { pub struct LWEPlaintextLayout {
@@ -19,8 +19,8 @@ impl LWEInfos for LWEPlaintextLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(0) RingDegree(0)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -43,8 +43,8 @@ impl<D: Data> LWEInfos for LWEPlaintext<D> {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32 - 1) RingDegree(self.data.n() as u32 - 1)
} }
fn size(&self) -> usize { fn size(&self) -> usize {

View File

@@ -5,7 +5,7 @@ use poulpy_hal::{
use crate::{ use crate::{
dist::Distribution, dist::Distribution,
layouts::{Base2K, Degree, LWEInfos, TorusPrecision}, layouts::{Base2K, LWEInfos, RingDegree, TorusPrecision},
}; };
pub struct LWESecret<D: Data> { pub struct LWESecret<D: Data> {
@@ -14,7 +14,7 @@ pub struct LWESecret<D: Data> {
} }
pub trait LWESecretAlloc { pub trait LWESecretAlloc {
fn alloc_lwe_secret(&self, n: Degree) -> LWESecret<Vec<u8>> { fn alloc_lwe_secret(&self, n: RingDegree) -> LWESecret<Vec<u8>> {
LWESecret { LWESecret {
data: ScalarZnx::alloc(n.into(), 1), data: ScalarZnx::alloc(n.into(), 1),
dist: Distribution::NONE, dist: Distribution::NONE,
@@ -25,7 +25,7 @@ pub trait LWESecretAlloc {
impl<B: Backend> LWESecretAlloc for Module<B> {} impl<B: Backend> LWESecretAlloc for Module<B> {}
impl LWESecret<Vec<u8>> { impl LWESecret<Vec<u8>> {
pub fn alloc<M>(module: &M, n: Degree) -> Self pub fn alloc<M>(module: &M, n: RingDegree) -> Self
where where
M: LWESecretAlloc, M: LWESecretAlloc,
{ {
@@ -55,8 +55,8 @@ impl<D: Data> LWEInfos for LWESecret<D> {
TorusPrecision(0) TorusPrecision(0)
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {

View File

@@ -6,13 +6,13 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut,
GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
#[derive(PartialEq, Eq, Copy, Clone, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub struct LWEToGLWESwitchingKeyLayout { pub struct LWEToGLWESwitchingKeyLayout {
pub n: Degree, pub n: RingDegree,
pub base2k: Base2K, pub base2k: Base2K,
pub k: TorusPrecision, pub k: TorusPrecision,
pub rank_out: Rank, pub rank_out: Rank,
@@ -28,7 +28,7 @@ impl LWEInfos for LWEToGLWESwitchingKeyLayout {
self.k self.k
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.n self.n
} }
} }
@@ -69,7 +69,7 @@ impl<D: Data> LWEInfos for LWEToGLWESwitchingKey<D> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -35,12 +35,12 @@ pub use lwe_to_glwe_ksk::*;
use poulpy_hal::layouts::{Backend, Module}; use poulpy_hal::layouts::{Backend, Module};
pub trait GetDegree { pub trait GetRingDegree {
fn n(&self) -> Degree; fn ring_degree(&self) -> RingDegree;
} }
impl<B: Backend> GetDegree for Module<B> { impl<B: Backend> GetRingDegree for Module<B> {
fn n(&self) -> Degree { fn ring_degree(&self) -> RingDegree {
Self::n(&self).into() Self::n(&self).into()
} }
} }
@@ -202,14 +202,14 @@ macro_rules! newtype_u32 {
}; };
} }
newtype_u32!(Degree); newtype_u32!(RingDegree);
newtype_u32!(TorusPrecision); newtype_u32!(TorusPrecision);
newtype_u32!(Base2K); newtype_u32!(Base2K);
newtype_u32!(Dnum); newtype_u32!(Dnum);
newtype_u32!(Rank); newtype_u32!(Rank);
newtype_u32!(Dsize); newtype_u32!(Dsize);
impl Degree { impl RingDegree {
pub fn log2(&self) -> usize { pub fn log2(&self) -> usize {
let n: usize = self.0 as usize; let n: usize = self.0 as usize;
(usize::BITS - (n - 1).leading_zeros()) as _ (usize::BITS - (n - 1).leading_zeros()) as _

View File

@@ -1,7 +1,7 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
AutomorphismKeyToRef, Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision, AutomorphismKeyToRef, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, RingDegree, TorusPrecision,
prepared::{ prepared::{
GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut,
GLWESwitchingKeyPreparedToRef, GLWESwitchingKeyPreparedToRef,
@@ -15,7 +15,7 @@ pub struct AutomorphismKeyPrepared<D: Data, B: Backend> {
} }
impl<D: Data, B: Backend> LWEInfos for AutomorphismKeyPrepared<D, B> { impl<D: Data, B: Backend> LWEInfos for AutomorphismKeyPrepared<D, B> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }

View File

@@ -4,7 +4,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWE, GGLWEInfos, GGLWEToRef, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWE, GGLWEInfos, GGLWEToRef, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
@@ -16,8 +16,8 @@ pub struct GGLWEPrepared<D: Data, B: Backend> {
} }
impl<D: Data, B: Backend> LWEInfos for GGLWEPrepared<D, B> { impl<D: Data, B: Backend> LWEInfos for GGLWEPrepared<D, B> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn base2k(&self) -> Base2K { fn base2k(&self) -> Base2K {
@@ -59,7 +59,7 @@ impl<D: Data, B: Backend> GGLWEInfos for GGLWEPrepared<D, B> {
pub trait GGLWEPreparedAlloc<B: Backend> pub trait GGLWEPreparedAlloc<B: Backend>
where where
Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, Self: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf,
{ {
fn alloc_gglwe_prepared( fn alloc_gglwe_prepared(
&self, &self,
@@ -96,7 +96,7 @@ where
where where
A: GGLWEInfos, A: GGLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.alloc_gglwe_prepared( self.alloc_gglwe_prepared(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -137,7 +137,7 @@ where
where where
A: GGLWEInfos, A: GGLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.bytes_of_gglwe_prepared( self.bytes_of_gglwe_prepared(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -149,7 +149,7 @@ where
} }
} }
impl<B: Backend> GGLWEPreparedAlloc<B> for Module<B> where Module<B>: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {} impl<B: Backend> GGLWEPreparedAlloc<B> for Module<B> where Module<B>: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {}
impl<B: Backend> GGLWEPrepared<Vec<u8>, B> { impl<B: Backend> GGLWEPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
@@ -201,7 +201,7 @@ impl<B: Backend> GGLWEPrepared<Vec<u8>, B> {
pub trait GGLWEPrepare<B: Backend> pub trait GGLWEPrepare<B: Backend>
where where
Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B>, Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B>,
{ {
fn prepare_gglwe_tmp_bytes<A>(&self, infos: &A) -> usize fn prepare_gglwe_tmp_bytes<A>(&self, infos: &A) -> usize
where where
@@ -223,8 +223,8 @@ where
let mut res: GGLWEPrepared<&mut [u8], B> = res.to_mut(); let mut res: GGLWEPrepared<&mut [u8], B> = res.to_mut();
let other: GGLWE<&[u8]> = other.to_ref(); let other: GGLWE<&[u8]> = other.to_ref();
assert_eq!(res.n(), self.n()); assert_eq!(res.n(), self.ring_degree());
assert_eq!(other.n(), self.n()); assert_eq!(other.n(), self.ring_degree());
assert_eq!(res.base2k, other.base2k); assert_eq!(res.base2k, other.base2k);
assert_eq!(res.k, other.k); assert_eq!(res.k, other.k);
assert_eq!(res.dsize, other.dsize); assert_eq!(res.dsize, other.dsize);
@@ -233,7 +233,7 @@ where
} }
} }
impl<B: Backend> GGLWEPrepare<B> for Module<B> where Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B> {} impl<B: Backend> GGLWEPrepare<B> for Module<B> where Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B> {}
impl<D: DataMut, B: Backend> GGLWEPrepared<D, B> { impl<D: DataMut, B: Backend> GGLWEPrepared<D, B> {
pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>) pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)

View File

@@ -1,8 +1,8 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToRef, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToRef, GLWESwtichingKeyGetMetaData,
GLWESwtichingKeyGetMetaData, LWEInfos, Rank, TorusPrecision, LWEInfos, Rank, RingDegree, TorusPrecision,
prepared::{GGLWEPrepare, GGLWEPrepared, GGLWEPreparedAlloc, GGLWEPreparedToMut, GGLWEPreparedToRef}, prepared::{GGLWEPrepare, GGLWEPrepared, GGLWEPreparedAlloc, GGLWEPreparedToMut, GGLWEPreparedToRef},
}; };
@@ -34,7 +34,7 @@ impl<D: DataRef, B: Backend> GLWESwtichingKeyGetMetaData for GLWESwitchingKeyPre
} }
impl<D: Data, B: Backend> LWEInfos for GLWESwitchingKeyPrepared<D, B> { impl<D: Data, B: Backend> LWEInfos for GLWESwitchingKeyPrepared<D, B> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.key.n() self.key.n()
} }

View File

@@ -1,7 +1,7 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, TensorKey, TensorKeyToRef, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, RingDegree, TensorKey, TensorKeyToRef, TorusPrecision,
prepared::{ prepared::{
GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut,
GLWESwitchingKeyPreparedToRef, GLWESwitchingKeyPreparedToRef,
@@ -14,7 +14,7 @@ pub struct TensorKeyPrepared<D: Data, B: Backend> {
} }
impl<D: Data, B: Backend> LWEInfos for TensorKeyPrepared<D, B> { impl<D: Data, B: Backend> LWEInfos for TensorKeyPrepared<D, B> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.keys[0].n() self.keys[0].n()
} }

View File

@@ -4,7 +4,7 @@ use poulpy_hal::{
}; };
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGSW, GGSWInfos, GGSWToRef, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGSW, GGSWInfos, GGSWToRef, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
}; };
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
@@ -16,8 +16,8 @@ pub struct GGSWPrepared<D: Data, B: Backend> {
} }
impl<D: Data, B: Backend> LWEInfos for GGSWPrepared<D, B> { impl<D: Data, B: Backend> LWEInfos for GGSWPrepared<D, B> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn base2k(&self) -> Base2K { fn base2k(&self) -> Base2K {
@@ -51,7 +51,7 @@ impl<D: Data, B: Backend> GGSWInfos for GGSWPrepared<D, B> {
pub trait GGSWPreparedAlloc<B: Backend> pub trait GGSWPreparedAlloc<B: Backend>
where where
Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, Self: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf,
{ {
fn alloc_ggsw_prepared( fn alloc_ggsw_prepared(
&self, &self,
@@ -92,7 +92,7 @@ where
where where
A: GGSWInfos, A: GGSWInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.alloc_ggsw_prepared( self.alloc_ggsw_prepared(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -124,7 +124,7 @@ where
where where
A: GGSWInfos, A: GGSWInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.bytes_of_ggsw_prepared( self.bytes_of_ggsw_prepared(
infos.base2k(), infos.base2k(),
infos.k(), infos.k(),
@@ -135,7 +135,7 @@ where
} }
} }
impl<B: Backend> GGSWPreparedAlloc<B> for Module<B> where Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {} impl<B: Backend> GGSWPreparedAlloc<B> for Module<B> where Self: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {}
impl<B: Backend> GGSWPrepared<Vec<u8>, B> { impl<B: Backend> GGSWPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
@@ -177,13 +177,13 @@ impl<D: DataRef, B: Backend> GGSWPrepared<D, B> {
pub trait GGSWPrepare<B: Backend> pub trait GGSWPrepare<B: Backend>
where where
Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B>, Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B>,
{ {
fn ggsw_prepare_tmp_bytes<A>(&self, infos: &A) -> usize fn ggsw_prepare_tmp_bytes<A>(&self, infos: &A) -> usize
where where
A: GGSWInfos, A: GGSWInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.vmp_prepare_tmp_bytes( self.vmp_prepare_tmp_bytes(
infos.dnum().into(), infos.dnum().into(),
(infos.rank() + 1).into(), (infos.rank() + 1).into(),
@@ -198,8 +198,8 @@ where
{ {
let mut res: GGSWPrepared<&mut [u8], B> = res.to_mut(); let mut res: GGSWPrepared<&mut [u8], B> = res.to_mut();
let other: GGSW<&[u8]> = other.to_ref(); let other: GGSW<&[u8]> = other.to_ref();
assert_eq!(res.n(), self.n()); assert_eq!(res.n(), self.ring_degree());
assert_eq!(other.n(), self.n()); assert_eq!(other.n(), self.ring_degree());
assert_eq!(res.k, other.k); assert_eq!(res.k, other.k);
assert_eq!(res.base2k, other.base2k); assert_eq!(res.base2k, other.base2k);
assert_eq!(res.dsize, other.dsize); assert_eq!(res.dsize, other.dsize);
@@ -207,7 +207,7 @@ where
} }
} }
impl<B: Backend> GGSWPrepare<B> for Module<B> where Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B> {} impl<B: Backend> GGSWPrepare<B> for Module<B> where Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B> {}
impl<B: Backend> GGSWPrepared<Vec<u8>, B> { impl<B: Backend> GGSWPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A) -> usize pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A) -> usize

View File

@@ -5,7 +5,9 @@ use poulpy_hal::{
use crate::{ use crate::{
dist::Distribution, dist::Distribution,
layouts::{Base2K, Degree, GLWEInfos, GLWEPublicKey, GLWEPublicKeyToRef, GetDegree, GetDist, LWEInfos, Rank, TorusPrecision}, layouts::{
Base2K, GLWEInfos, GLWEPublicKey, GLWEPublicKeyToRef, GetDist, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
},
}; };
#[derive(PartialEq, Eq)] #[derive(PartialEq, Eq)]
@@ -39,8 +41,8 @@ impl<D: Data, B: Backend> LWEInfos for GLWEPublicKeyPrepared<D, B> {
self.data.size() self.data.size()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
} }
@@ -52,7 +54,7 @@ impl<D: Data, B: Backend> GLWEInfos for GLWEPublicKeyPrepared<D, B> {
pub trait GLWEPublicKeyPreparedAlloc<B: Backend> pub trait GLWEPublicKeyPreparedAlloc<B: Backend>
where where
Self: GetDegree + VecZnxDftAlloc<B> + VecZnxDftBytesOf, Self: GetRingDegree + VecZnxDftAlloc<B> + VecZnxDftBytesOf,
{ {
fn alloc_glwe_public_key_prepared(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWEPublicKeyPrepared<Vec<u8>, B> { fn alloc_glwe_public_key_prepared(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWEPublicKeyPrepared<Vec<u8>, B> {
GLWEPublicKeyPrepared { GLWEPublicKeyPrepared {
@@ -118,7 +120,7 @@ impl<B: Backend> GLWEPublicKeyPrepared<Vec<u8>, B> {
pub trait GLWEPublicKeyPrepare<B: Backend> pub trait GLWEPublicKeyPrepare<B: Backend>
where where
Self: GetDegree + VecZnxDftApply<B>, Self: GetRingDegree + VecZnxDftApply<B>,
{ {
fn prepare_glwe_public_key<R, O>(&self, res: &mut R, other: &O) fn prepare_glwe_public_key<R, O>(&self, res: &mut R, other: &O)
where where
@@ -129,8 +131,8 @@ where
let mut res: GLWEPublicKeyPrepared<&mut [u8], B> = res.to_mut(); let mut res: GLWEPublicKeyPrepared<&mut [u8], B> = res.to_mut();
let other: GLWEPublicKey<&[u8]> = other.to_ref(); let other: GLWEPublicKey<&[u8]> = other.to_ref();
assert_eq!(res.n(), self.n()); assert_eq!(res.n(), self.ring_degree());
assert_eq!(other.n(), self.n()); assert_eq!(other.n(), self.ring_degree());
assert_eq!(res.size(), other.size()); assert_eq!(res.size(), other.size());
assert_eq!(res.k(), other.k()); assert_eq!(res.k(), other.k());
assert_eq!(res.base2k(), other.base2k()); assert_eq!(res.base2k(), other.base2k());
@@ -144,7 +146,7 @@ where
} }
} }
impl<B: Backend> GLWEPublicKeyPrepare<B> for Module<B> where Self: GetDegree + VecZnxDftApply<B> {} impl<B: Backend> GLWEPublicKeyPrepare<B> for Module<B> where Self: GetRingDegree + VecZnxDftApply<B> {}
impl<D: DataMut, B: Backend> GLWEPublicKeyPrepared<D, B> { impl<D: DataMut, B: Backend> GLWEPublicKeyPrepared<D, B> {
pub fn prepare<O, M>(&mut self, module: &M, other: &O) pub fn prepare<O, M>(&mut self, module: &M, other: &O)

View File

@@ -6,7 +6,7 @@ use poulpy_hal::{
use crate::{ use crate::{
dist::Distribution, dist::Distribution,
layouts::{ layouts::{
Base2K, Degree, GLWEInfos, GLWESecret, GLWESecretToRef, GetDegree, GetDist, LWEInfos, Rank, TorusPrecision, Base2K, GLWEInfos, GLWESecret, GLWESecretToRef, GetDist, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision,
prepared::SetDist, prepared::SetDist,
}, },
}; };
@@ -31,8 +31,8 @@ impl<D: Data, B: Backend> LWEInfos for GLWESecretPrepared<D, B> {
TorusPrecision(0) TorusPrecision(0)
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
fn size(&self) -> usize { fn size(&self) -> usize {
@@ -47,7 +47,7 @@ impl<D: Data, B: Backend> GLWEInfos for GLWESecretPrepared<D, B> {
pub trait GLWESecretPreparedAlloc<B: Backend> pub trait GLWESecretPreparedAlloc<B: Backend>
where where
Self: GetDegree + SvpPPolBytesOf + SvpPPolAlloc<B>, Self: GetRingDegree + SvpPPolBytesOf + SvpPPolAlloc<B>,
{ {
fn alloc_glwe_secret_prepared(&self, rank: Rank) -> GLWESecretPrepared<Vec<u8>, B> { fn alloc_glwe_secret_prepared(&self, rank: Rank) -> GLWESecretPrepared<Vec<u8>, B> {
GLWESecretPrepared { GLWESecretPrepared {
@@ -59,7 +59,7 @@ where
where where
A: GLWEInfos, A: GLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.alloc_glwe_secret_prepared(infos.rank()) self.alloc_glwe_secret_prepared(infos.rank())
} }
@@ -70,12 +70,12 @@ where
where where
A: GLWEInfos, A: GLWEInfos,
{ {
assert_eq!(self.n(), infos.n()); assert_eq!(self.ring_degree(), infos.n());
self.bytes_of_glwe_secret(infos.rank()) self.bytes_of_glwe_secret(infos.rank())
} }
} }
impl<B: Backend> GLWESecretPreparedAlloc<B> for Module<B> where Self: GetDegree + SvpPPolBytesOf + SvpPPolAlloc<B> {} impl<B: Backend> GLWESecretPreparedAlloc<B> for Module<B> where Self: GetRingDegree + SvpPPolBytesOf + SvpPPolAlloc<B> {}
impl<B: Backend> GLWESecretPrepared<Vec<u8>, B> { impl<B: Backend> GLWESecretPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
@@ -110,8 +110,8 @@ impl<B: Backend> GLWESecretPrepared<Vec<u8>, B> {
} }
impl<D: Data, B: Backend> GLWESecretPrepared<D, B> { impl<D: Data, B: Backend> GLWESecretPrepared<D, B> {
pub fn n(&self) -> Degree { pub fn n(&self) -> RingDegree {
Degree(self.data.n() as u32) RingDegree(self.data.n() as u32)
} }
pub fn rank(&self) -> Rank { pub fn rank(&self) -> Rank {

View File

@@ -1,7 +1,7 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision,
prepared::{ prepared::{
GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut,
GLWESwitchingKeyPreparedToRef, GLWESwitchingKeyPreparedToRef,
@@ -20,7 +20,7 @@ impl<D: Data, B: Backend> LWEInfos for GLWEToLWESwitchingKeyPrepared<D, B> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -1,7 +1,7 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKeyToRef, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKeyToRef, Rank, RingDegree, TorusPrecision,
prepared::{ prepared::{
GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut,
GLWESwitchingKeyPreparedToRef, GLWESwitchingKeyPreparedToRef,
@@ -20,7 +20,7 @@ impl<D: Data, B: Backend> LWEInfos for LWESwitchingKeyPrepared<D, B> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

@@ -1,7 +1,7 @@
use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch};
use crate::layouts::{ use crate::layouts::{
Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKeyToRef, Rank, TorusPrecision, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKeyToRef, Rank, RingDegree, TorusPrecision,
prepared::{ prepared::{
GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut,
GLWESwitchingKeyPreparedToRef, GLWESwitchingKeyPreparedToRef,
@@ -21,7 +21,7 @@ impl<D: Data, B: Backend> LWEInfos for LWEToGLWESwitchingKeyPrepared<D, B> {
self.0.k() self.0.k()
} }
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.0.n() self.0.n()
} }

View File

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

View File

@@ -1,8 +1,8 @@
use poulpy_core::{ use poulpy_core::{
GLWEOperations, GLWEOperations,
layouts::{ layouts::{
AutomorphismKeyLayout, GGSW, GGSWLayout, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWELayout, AutomorphismKeyLayout, GGSW, GGSWLayout, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWEInfos, LWELayout,
LWEInfos, LWEPlaintext, LWESecret, TensorKeyLayout, LWEPlaintext, LWESecret, TensorKeyLayout,
prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc}, prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc},
}, },
}; };

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -8,7 +8,7 @@ use std::{fmt, marker::PhantomData};
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use poulpy_core::{ use poulpy_core::{
Distribution, 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}; 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> { impl<D: DataRef, BRA: BlindRotationAlgo> BlindRotationKeyInfos for BlindRotationKeyCompressed<D, BRA> {
fn n_glwe(&self) -> Degree { fn n_glwe(&self) -> RingDegree {
self.n() self.n()
} }
fn n_lwe(&self) -> Degree { fn n_lwe(&self) -> RingDegree {
Degree(self.keys.len() as u32) RingDegree(self.keys.len() as u32)
} }
} }
impl<D: DataRef, BRA: BlindRotationAlgo> LWEInfos for BlindRotationKeyCompressed<D, BRA> { impl<D: DataRef, BRA: BlindRotationAlgo> LWEInfos for BlindRotationKeyCompressed<D, BRA> {
fn n(&self) -> Degree { fn n(&self) -> RingDegree {
self.keys[0].n() self.keys[0].n()
} }

View File

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

View File

@@ -23,7 +23,7 @@ use crate::tfhe::blind_rotation::{
}; };
use poulpy_core::layouts::{ 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}, prepared::{GLWESecretPrepared, PrepareAlloc},
}; };

View File

@@ -31,9 +31,7 @@ use crate::tfhe::{
}, },
}; };
use poulpy_core::layouts::{ use poulpy_core::layouts::{AutomorphismKeyLayout, Dsize, GGSWLayout, LWELayout, TensorKeyLayout, prepared::PrepareAlloc};
AutomorphismKeyLayout, Dsize, GGSWLayout, LWELayout, TensorKeyLayout, prepared::PrepareAlloc,
};
use poulpy_core::layouts::{ use poulpy_core::layouts::{
GGSW, GLWE, GLWEPlaintext, GLWESecret, LWE, LWEPlaintext, LWESecret, GGSW, GLWE, GLWEPlaintext, GLWESecret, LWE, LWEPlaintext, LWESecret,