arnaucube
arnaucube/poulpyPublic Self-hosted repository
wip
Pro7ech jeanphilippe.bossuat@gmail.com
Wed, 15 Oct 2025 18:26:32 +0200
commit

2ea59310fbefca5cc899bd7e449ba2aebdb78397

parent

10817a85297a26a42f2a8d1e651dd4682e740906

57 files changed, 363 insertions(+), 314 deletions(-)

jump to
M poulpy-core/benches/external_product_glwe_fft64.rs → poulpy-core/benches/external_product_glwe_fft64.rs

@@ -1,5 +1,5 @@

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}, }; use std::hint::black_box;

@@ -28,7 +28,7 @@

fn runner(p: Params) -> impl FnMut() { 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 k_ct_in: TorusPrecision = p.k_ct_in; let k_ct_out: TorusPrecision = p.k_ct_out;

@@ -137,7 +137,7 @@

fn runner(p: Params) -> impl FnMut() { 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 k_glwe: TorusPrecision = p.k_ct; let k_ggsw: TorusPrecision = p.k_ggsw;
M poulpy-core/benches/keyswitch_glwe_fft64.rs → poulpy-core/benches/keyswitch_glwe_fft64.rs

@@ -1,6 +1,6 @@

use poulpy_core::layouts::{ - AutomorphismKey, AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GLWE, GLWELayout, GLWESecret, GLWESwitchingKey, - GLWESwitchingKeyLayout, Rank, TorusPrecision, + AutomorphismKey, AutomorphismKeyLayout, Base2K, Dnum, Dsize, GLWE, GLWELayout, GLWESecret, GLWESwitchingKey, + GLWESwitchingKeyLayout, Rank, RingDegree, TorusPrecision, prepared::{AutomorphismKeyPrepared, GLWESecretPrepared, GLWESwitchingKeyPrepared, PrepareAlloc}, }; use std::{hint::black_box, time::Duration};

@@ -29,7 +29,7 @@

fn runner(p: Params) -> impl FnMut() { 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 k_glwe_in: TorusPrecision = p.k_ct_in; let k_glwe_out: TorusPrecision = p.k_ct_out;

@@ -148,7 +148,7 @@

fn runner(p: Params) -> impl FnMut() { 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 k_ct: TorusPrecision = p.k_ct; let k_ksk: TorusPrecision = p.k_ksk;
M poulpy-core/examples/encryption.rs → poulpy-core/examples/encryption.rs

@@ -2,7 +2,7 @@ use poulpy_backend::cpu_spqlios::FFT64Spqlios;

use poulpy_core::{ GLWEOperations, SIGMA, layouts::{ - Base2K, Degree, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, TorusPrecision, + Base2K, GLWE, GLWELayout, GLWEPlaintext, GLWEPlaintextLayout, GLWESecret, LWEInfos, Rank, RingDegree, TorusPrecision, prepared::{GLWESecretPrepared, PrepareAlloc}, }, };

@@ -16,7 +16,7 @@ fn main() {

// Ring degree 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) let base2k: Base2K = Base2K(14);
M poulpy-core/src/encryption/compressed/gglwe_ksk.rs → poulpy-core/src/encryption/compressed/gglwe_ksk.rs

@@ -7,7 +7,7 @@

use crate::{ encryption::compressed::gglwe_ct::GGLWECompressedEncryptSk, layouts::{ - Degree, GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, + GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, RingDegree, compressed::{GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedToMut}, prepared::GLWESecretPrepared, },

@@ -110,7 +110,7 @@ i,

); }); - 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); (0..sk_out.rank().into()).for_each(|i| {
M poulpy-core/src/encryption/gglwe_ksk.rs → poulpy-core/src/encryption/gglwe_ksk.rs

@@ -9,7 +9,7 @@ source::Source,

}; 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>> {

@@ -85,7 +85,7 @@ i,

); }); - 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); (0..sk_out.rank().into()).for_each(|i| {
M poulpy-core/src/encryption/gglwe_tsk.rs → poulpy-core/src/encryption/gglwe_tsk.rs

@@ -10,7 +10,7 @@ source::Source,

}; 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>> {

@@ -23,7 +23,7 @@ GLWESecretPrepared::bytes_of(module, infos.rank_out())

+ module.bytes_of_vec_znx_dft(infos.rank_out().into(), 1) + module.bytes_of_vec_znx_big(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) } }

@@ -64,7 +64,7 @@ assert_eq!(self.rank_out(), sk.rank());

assert_eq!(self.n(), sk.n()); } - let n: Degree = sk.n(); + let n: RingDegree = sk.n(); let rank: Rank = self.rank_out(); let (mut sk_dft_prep, scratch_1) = scratch.take_glwe_secret_prepared(n, rank);
M poulpy-core/src/encryption/lwe_ksk.rs → poulpy-core/src/encryption/lwe_ksk.rs

@@ -10,7 +10,8 @@ source::Source,

}; 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>> {

@@ -34,7 +35,7 @@ infos.rank_out().0,

1, "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)) + GLWESwitchingKey::encrypt_sk_tmp_bytes(module, infos) }
M poulpy-core/src/encryption/lwe_to_glwe_ksk.rs → poulpy-core/src/encryption/lwe_to_glwe_ksk.rs

@@ -9,7 +9,7 @@ layouts::{Backend, DataMut, DataRef, Module, Scratch, ZnxView, ZnxViewMut},

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>> { pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize

@@ -22,7 +22,8 @@ infos.rank_in(),

Rank(1), "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()) } }
M poulpy-core/src/keyswitching/lwe_ct.rs → poulpy-core/src/keyswitching/lwe_ct.rs

@@ -1,22 +1,48 @@

use poulpy_hal::{ - api::{ - ScratchAvailable, VecZnxBigAddSmallInplace, VecZnxBigNormalize, VecZnxBigNormalizeTmpBytes, VecZnxCopy, VecZnxDftApply, - VecZnxDftBytesOf, VecZnxIdftApplyConsume, VecZnxNormalize, VecZnxNormalizeTmpBytes, VmpApplyDftToDft, - VmpApplyDftToDftAdd, VmpApplyDftToDftTmpBytes, - }, - layouts::{Backend, DataMut, DataRef, Module, Scratch, ZnxView, ZnxViewMut, ZnxZero}, + api::ScratchAvailable, + layouts::{Backend, DataMut, Module, Scratch, ZnxView, ZnxViewMut, ZnxZero}, }; use crate::{ + ScratchTakeCore, 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> where 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 R: LWEInfos, A: LWEInfos,

@@ -25,14 +51,14 @@ {

let max_k: TorusPrecision = a_infos.k().max(res_infos.k()); let glwe_a_infos: GLWELayout = GLWELayout { - n: GetDegree::n(self), + n: self.ring_degree(), base2k: a_infos.base2k(), k: max_k, rank: Rank(1), }; let glwe_res_infos: GLWELayout = GLWELayout { - n: GetDegree::n(self), + n: self.ring_degree(), base2k: res_infos.base2k(), k: max_k, rank: Rank(1),

@@ -45,39 +71,46 @@

glwe_in + glwe_out + ks } - fn keyswitch<A, DKs, B: Backend>( - &mut self, - module: &Module<B>, - a: &A, - ksk: &K, - scratch: &mut Scratch<B>, - ) where + fn lwe_keyswitch<R, A, K>(&self, res: &mut R, a: &A, ksk: &K, scratch: &mut Scratch<BE>) + where + R: LWEToMut, A: LWEToRef, - DKs: DataRef, - Scratch<B>: ScratchAvailable, + K: LWESwitchingKeyPreparedToRef<BE>, + Scratch<BE>: ScratchTakeCore<BE>, { - assert!(self.n() <= module.n() as u32); - assert!(a.n() <= module.n() as u32); - assert!(scratch.available() >= LWE::keyswitch_tmp_bytes(module, self, a, ksk)); + let res: &mut LWE<&mut [u8]> = &mut res.to_mut(); + let a: &LWE<&[u8]> = &a.to_ref(); + 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 (mut glwe_in, scratch_1) = scratch.take_glwe_ct(&GLWELayout { - n: ksk.n(), - base2k: a.base2k(), - k: max_k, - rank: Rank(1), - }); + let (mut glwe_in, scratch_1) = scratch.take_glwe_ct( + self, + &GLWELayout { + n: ksk.n(), + base2k: a.base2k(), + k: max_k, + rank: Rank(1), + }, + ); glwe_in.data.zero(); - let (mut glwe_out, scratch_1) = scratch_1.take_glwe_ct(&GLWELayout { - n: ksk.n(), - base2k: self.base2k(), - k: max_k, - rank: Rank(1), - }); + let (mut glwe_out, scratch_1) = scratch_1.take_glwe_ct( + self, + &GLWELayout { + n: ksk.n(), + base2k: res.base2k(), + k: max_k, + rank: Rank(1), + }, + ); let n_lwe: usize = a.n().into();

@@ -87,13 +120,7 @@ glwe_in.data.at_mut(0, i)[0] = data_lwe[0];

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.sample_extract(&glwe_out); + self.glwe_keyswitch(&mut glwe_out, &glwe_in, &ksk.0, scratch_1); + res.sample_extract(&glwe_out); } } - -impl LWE<Vec<u8>> {} - -impl<DLwe: DataMut> LWE<DLwe> { - -}
M poulpy-core/src/layouts/compressed/gglwe_atk.rs → poulpy-core/src/layouts/compressed/gglwe_atk.rs

@@ -4,7 +4,8 @@ source::Source,

}; 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::{ GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,

@@ -21,7 +22,7 @@ pub(crate) p: i64,

} impl<D: Data> LWEInfos for AutomorphismKeyCompressed<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }
M poulpy-core/src/layouts/compressed/gglwe_ct.rs → poulpy-core/src/layouts/compressed/gglwe_ct.rs

@@ -7,7 +7,7 @@ source::Source,

}; 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}, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -24,8 +24,8 @@ pub(crate) seed: Vec<[u8; 32]>,

} impl<D: Data> LWEInfos for GGLWECompressed<D> { - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn base2k(&self) -> Base2K {

@@ -88,7 +88,7 @@ }

pub trait GGLWECompressedAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_gglwe_compressed( &self,

@@ -115,7 +115,7 @@ );

GGLWECompressed { data: MatZnx::alloc( - self.n().into(), + self.ring_degree().into(), dnum.into(), rank_in.into(), 1,

@@ -133,7 +133,7 @@ fn alloc_gglwe_compressed_from_infos<A>(&self, infos: &A) -> GGLWECompressed<Vec<u8>>

where A: GGLWEInfos, { - assert_eq!(infos.n(), self.n()); + assert_eq!(infos.n(), self.ring_degree()); self.alloc_gglwe_compressed( infos.base2k(), infos.k(),

@@ -160,7 +160,7 @@ dsize.0,

); MatZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), dnum.into(), rank_in.into(), 1,

@@ -172,7 +172,7 @@ fn bytes_of_gglwe_compressed_from_infos<A>(&self, infos: &A) -> usize

where A: GGLWEInfos, { - assert_eq!(infos.n(), self.n()); + assert_eq!(infos.n(), self.ring_degree()); self.bytes_of_gglwe_compressed( infos.base2k(), infos.k(),

@@ -183,7 +183,7 @@ )

} } -impl<B: Backend> GGLWECompressedAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GGLWECompressedAlloc for Module<B> where Self: GetRingDegree {} impl GGLWECompressed<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/compressed/gglwe_ksk.rs → poulpy-core/src/layouts/compressed/gglwe_ksk.rs

@@ -4,8 +4,8 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToMut, - LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToMut, LWEInfos, + Rank, RingDegree, TorusPrecision, compressed::{GGLWECompressed, GGLWECompressedAlloc, GGLWECompressedToMut, GGLWECompressedToRef, GGLWEDecompress}, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -19,7 +19,7 @@ pub(crate) sk_out_n: usize, // Degree of sk_out

} impl<D: Data> LWEInfos for GLWESwitchingKeyCompressed<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }
M poulpy-core/src/layouts/compressed/gglwe_tsk.rs → poulpy-core/src/layouts/compressed/gglwe_tsk.rs

@@ -4,7 +4,7 @@ source::Source,

}; 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::{ GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,

@@ -19,7 +19,7 @@ pub(crate) keys: Vec<GLWESwitchingKeyCompressed<D>>,

} impl<D: Data> LWEInfos for TensorKeyCompressed<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.keys[0].n() }
M poulpy-core/src/layouts/compressed/ggsw_ct.rs → poulpy-core/src/layouts/compressed/ggsw_ct.rs

@@ -6,7 +6,7 @@ source::Source,

}; 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}, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -23,8 +23,8 @@ pub(crate) seed: Vec<[u8; 32]>,

} impl<D: Data> LWEInfos for GGSWCompressed<D> { - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn base2k(&self) -> Base2K {

@@ -78,7 +78,7 @@ }

pub trait GGSWCompressedAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_ggsw_compressed( &self,

@@ -104,7 +104,7 @@ );

GGSWCompressed { data: MatZnx::alloc( - self.n().into(), + self.ring_degree().into(), dnum.into(), (rank + 1).into(), 1,

@@ -147,7 +147,7 @@ dsize.0,

); MatZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), dnum.into(), (rank + 1).into(), 1,
M poulpy-core/src/layouts/compressed/glwe_ct.rs → poulpy-core/src/layouts/compressed/glwe_ct.rs

@@ -6,7 +6,9 @@ },

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 std::fmt;

@@ -32,8 +34,8 @@ fn size(&self) -> usize {

self.data.size() } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } } impl<D: Data> GLWEInfos for GLWECompressed<D> {

@@ -70,11 +72,15 @@ }

pub trait GLWECompressedAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_glwe_compressed(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWECompressed<Vec<u8>> { 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, k, rank,

@@ -86,24 +92,28 @@ fn alloc_glwe_compressed_from_infos<A>(&self, infos: &A) -> GLWECompressed<Vec<u8>>

where 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()) } 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 where A: GLWEInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); 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>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

@@ -159,7 +169,7 @@ }

pub trait GLWEDecompress where - Self: GetDegree + VecZnxFillUniform + VecZnxCopy, + Self: GetRingDegree + VecZnxFillUniform + VecZnxCopy, { fn decompress_glwe<R, O>(&self, res: &mut R, other: &O) where

@@ -171,10 +181,10 @@ let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();

let other: &GLWECompressed<&[u8]> = &other.to_ref(); assert_eq!( res.n(), - self.n(), + self.ring_degree(), "invalid receiver: res.n()={} != other.n()={}", res.n(), - self.n() + self.ring_degree() ); assert_eq!(res.lwe_layout(), other.lwe_layout());

@@ -193,7 +203,7 @@ res.set_k(other.k());

} } -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> { pub fn decompress<O, M>(&mut self, module: &M, other: &O)
M poulpy-core/src/layouts/compressed/glwe_to_lwe_ksk.rs → poulpy-core/src/layouts/compressed/glwe_to_lwe_ksk.rs

@@ -6,7 +6,7 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyToMut, LWEInfos, Rank, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKey, GLWEToLWESwitchingKeyToMut, LWEInfos, Rank, RingDegree, TorusPrecision, compressed::{ GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,

@@ -26,7 +26,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() } fn size(&self) -> usize {
M poulpy-core/src/layouts/compressed/lwe_ct.rs → poulpy-core/src/layouts/compressed/lwe_ct.rs

@@ -9,7 +9,7 @@ },

source::Source, }; -use crate::layouts::{Base2K, Degree, LWE, LWEInfos, LWEToMut, TorusPrecision}; +use crate::layouts::{Base2K, LWE, LWEInfos, LWEToMut, RingDegree, TorusPrecision}; #[derive(PartialEq, Eq, Clone)] pub struct LWECompressed<D: Data> {

@@ -28,8 +28,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {
M poulpy-core/src/layouts/compressed/lwe_ksk.rs → poulpy-core/src/layouts/compressed/lwe_ksk.rs

@@ -4,7 +4,8 @@ source::Source,

}; 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::{ GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut, GLWESwitchingKeyCompressedToRef, GLWESwitchingKeyDecompress,

@@ -24,7 +25,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() } fn size(&self) -> usize {
M poulpy-core/src/layouts/compressed/lwe_to_glwe_ksk.rs → poulpy-core/src/layouts/compressed/lwe_to_glwe_ksk.rs

@@ -4,7 +4,7 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyToMut, Rank, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKey, LWEToGLWESwitchingKeyToMut, Rank, RingDegree, TorusPrecision, compressed::{ GLWESwitchingKeyCompressed, GLWESwitchingKeyCompressedAlloc, GLWESwitchingKeyCompressedToMut,

@@ -17,7 +17,7 @@ #[derive(PartialEq, Eq, Clone)]

pub struct LWEToGLWESwitchingKeyCompressed<D: Data>(pub(crate) GLWESwitchingKeyCompressed<D>); impl<D: Data> LWEInfos for LWEToGLWESwitchingKeyCompressed<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/gglwe_atk.rs → poulpy-core/src/layouts/gglwe_atk.rs

@@ -4,8 +4,8 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWE, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, - GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWE, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, + GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -13,7 +13,7 @@ use std::fmt;

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct AutomorphismKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank: Rank,

@@ -34,7 +34,7 @@ }

} impl<D: Data> LWEInfos for AutomorphismKey<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }

@@ -84,7 +84,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }
M poulpy-core/src/layouts/gglwe_ct.rs → poulpy-core/src/layouts/gglwe_ct.rs

@@ -5,7 +5,7 @@ },

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 std::fmt;

@@ -37,7 +37,7 @@ }

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GGLWELayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank_in: Rank,

@@ -55,7 +55,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }

@@ -101,8 +101,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } 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 { write!( f, - "(GGLWECiphertext: k={} base2k={} dsize={}) {}", + "(GGLWE: k={} base2k={} dsize={}) {}", self.k().0, self.base2k().0, self.dsize().0,

@@ -193,7 +193,7 @@ }

pub trait GGLWEAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_gglwe( &self,

@@ -220,7 +220,7 @@ );

GGLWE { data: MatZnx::alloc( - self.n().into(), + self.ring_degree().into(), dnum.into(), rank_in.into(), (rank_out + 1).into(),

@@ -270,7 +270,7 @@ dsize.0,

); MatZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), dnum.into(), rank_in.into(), (rank_out + 1).into(),

@@ -293,7 +293,7 @@ )

} } -impl<B: Backend> GGLWEAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GGLWEAlloc for Module<B> where Self: GetRingDegree {} impl GGLWE<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/gglwe_ksk.rs → poulpy-core/src/layouts/gglwe_ksk.rs

@@ -4,7 +4,7 @@ source::Source,

}; 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, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -13,7 +13,7 @@ use std::fmt;

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GLWESwitchingKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank_in: Rank,

@@ -23,7 +23,7 @@ pub dsize: Dsize,

} impl LWEInfos for GLWESwitchingKeyLayout { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }

@@ -98,7 +98,7 @@ }

} impl<D: Data> LWEInfos for GLWESwitchingKey<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }
M poulpy-core/src/layouts/gglwe_tsk.rs → poulpy-core/src/layouts/gglwe_tsk.rs

@@ -4,8 +4,8 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, - GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, + GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -13,7 +13,7 @@ use std::fmt;

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct TensorKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank: Rank,

@@ -27,7 +27,7 @@ pub(crate) keys: Vec<GLWESwitchingKey<D>>,

} impl<D: Data> LWEInfos for TensorKey<D> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.keys[0].n() }

@@ -69,7 +69,7 @@ }

} impl LWEInfos for TensorKeyLayout { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }
M poulpy-core/src/layouts/ggsw_ct.rs → poulpy-core/src/layouts/ggsw_ct.rs

@@ -6,7 +6,7 @@ source::Source,

}; 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 where

@@ -28,7 +28,7 @@ }

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GGSWLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank: Rank,

@@ -45,7 +45,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }

@@ -74,8 +74,8 @@ pub(crate) dsize: Dsize,

} impl<D: Data> LWEInfos for GGSW<D> { - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn base2k(&self) -> Base2K {

@@ -152,11 +152,11 @@ }

} } -impl<B: Backend> GGSWAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GGSWAlloc for Module<B> where Self: GetRingDegree {} pub trait GGSWAlloc where - Self: GetDegree, + Self: GetRingDegree, { 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;

@@ -175,7 +175,7 @@ );

GGSW { data: MatZnx::alloc( - self.n().into(), + self.ring_degree().into(), dnum.into(), (rank + 1).into(), (rank + 1).into(),

@@ -216,7 +216,7 @@ dsize.0,

); MatZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), dnum.into(), (rank + 1).into(), (rank + 1).into(),
M poulpy-core/src/layouts/glwe_ct.rs → poulpy-core/src/layouts/glwe_ct.rs

@@ -6,7 +6,7 @@ },

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 std::fmt;

@@ -32,14 +32,14 @@ }

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GLWELayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank: Rank, } impl LWEInfos for GLWELayout { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }

@@ -96,8 +96,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {

@@ -148,12 +148,12 @@ }

pub trait GLWEAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWE<Vec<u8>> { GLWE { data: VecZnx::alloc( - self.n().into(), + self.ring_degree().into(), (rank + 1).into(), k.0.div_ceil(base2k.0) as usize, ),

@@ -171,7 +171,7 @@ }

fn bytes_of_glwe(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize { VecZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), (rank + 1).into(), k.0.div_ceil(base2k.0) as usize, )

@@ -185,7 +185,7 @@ self.bytes_of_glwe(infos.base2k(), infos.k(), infos.rank())

} } -impl<B: Backend> GLWEAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GLWEAlloc for Module<B> where Self: GetRingDegree {} impl GLWE<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/glwe_pk.rs → poulpy-core/src/layouts/glwe_pk.rs

@@ -4,7 +4,7 @@ };

use crate::{ dist::Distribution, - layouts::{Base2K, Degree, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}, + layouts::{Base2K, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision}, }; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

@@ -18,7 +18,7 @@ }

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GLWEPublicKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank: Rank,

@@ -43,8 +43,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {

@@ -67,7 +67,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }

@@ -84,12 +84,12 @@ }

pub trait GLWEPublicKeyAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> GLWEPublicKey<Vec<u8>> { GLWEPublicKey { data: VecZnx::alloc( - self.n().into(), + self.ring_degree().into(), (rank + 1).into(), k.0.div_ceil(base2k.0) as usize, ),

@@ -108,7 +108,7 @@ }

fn bytes_of_glwe_public_key(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize { VecZnx::bytes_of( - self.n().into(), + self.ring_degree().into(), (rank + 1).into(), k.0.div_ceil(base2k.0) as usize, )

@@ -122,7 +122,7 @@ self.bytes_of_glwe_public_key(infos.base2k(), infos.k(), infos.rank())

} } -impl<B: Backend> GLWEPublicKeyAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GLWEPublicKeyAlloc for Module<B> where Self: GetRingDegree {} impl GLWEPublicKey<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/glwe_pt.rs → poulpy-core/src/layouts/glwe_pt.rs

@@ -3,12 +3,12 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, VecZnx, VecZnxToMut, VecZnxToRef, ZnxInfos}; 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)] pub struct GLWEPlaintextLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, }

@@ -22,7 +22,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }

@@ -62,8 +62,8 @@ fn size(&self) -> usize {

self.data.size() } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } }

@@ -87,11 +87,15 @@ }

pub trait GLWEPlaintextAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_glwe_plaintext(&self, base2k: Base2K, k: TorusPrecision) -> GLWEPlaintext<Vec<u8>> { 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, k, }

@@ -105,7 +109,11 @@ self.alloc_glwe_plaintext(infos.base2k(), infos.k())

} 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

@@ -116,7 +124,7 @@ self.bytes_of_glwe_plaintext(infos.base2k(), infos.k())

} } -impl<B: Backend> GLWEPlaintextAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GLWEPlaintextAlloc for Module<B> where Self: GetRingDegree {} impl GLWEPlaintext<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/glwe_sk.rs → poulpy-core/src/layouts/glwe_sk.rs

@@ -8,12 +8,12 @@ };

use crate::{ dist::Distribution, - layouts::{Base2K, Degree, GLWEInfos, GetDegree, LWEInfos, Rank, TorusPrecision}, + layouts::{Base2K, GLWEInfos, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision}, }; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GLWESecretLayout { - pub n: Degree, + pub n: RingDegree, pub rank: Rank, }

@@ -26,7 +26,7 @@ fn k(&self) -> TorusPrecision {

TorusPrecision(0) } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }

@@ -55,8 +55,8 @@ fn k(&self) -> TorusPrecision {

TorusPrecision(0) } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {

@@ -72,11 +72,11 @@ }

pub trait GLWESecretAlloc where - Self: GetDegree, + Self: GetRingDegree, { fn alloc_glwe_secret(&self, rank: Rank) -> GLWESecret<Vec<u8>> { GLWESecret { - data: ScalarZnx::alloc(self.n().into(), rank.into()), + data: ScalarZnx::alloc(self.ring_degree().into(), rank.into()), dist: Distribution::NONE, } }

@@ -89,7 +89,7 @@ self.alloc_glwe_secret(infos.rank())

} 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

@@ -100,7 +100,7 @@ self.bytes_of_glwe_secret(infos.rank())

} } -impl<B: Backend> GLWESecretAlloc for Module<B> where Self: GetDegree {} +impl<B: Backend> GLWESecretAlloc for Module<B> where Self: GetRingDegree {} impl GLWESecret<Vec<u8>> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
M poulpy-core/src/layouts/glwe_to_lwe_ksk.rs → poulpy-core/src/layouts/glwe_to_lwe_ksk.rs

@@ -4,15 +4,15 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, - GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, + GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision, }; use std::fmt; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct GLWEToLWEKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank_in: Rank,

@@ -20,7 +20,7 @@ pub dnum: Dnum,

} impl LWEInfos for GLWEToLWEKeyLayout { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n }

@@ -70,7 +70,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/lwe_ct.rs → poulpy-core/src/layouts/lwe_ct.rs

@@ -5,11 +5,11 @@ layouts::{Backend, Data, DataMut, DataRef, FillUniform, Module, ReaderFrom, WriterTo, Zn, ZnToMut, ZnToRef, ZnxInfos},

source::Source, }; -use crate::layouts::{Base2K, Degree, TorusPrecision}; +use crate::layouts::{Base2K, RingDegree, TorusPrecision}; use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; pub trait LWEInfos { - fn n(&self) -> Degree; + fn n(&self) -> RingDegree; fn k(&self) -> TorusPrecision; fn max_k(&self) -> TorusPrecision { TorusPrecision(self.k().0 * self.size() as u32)

@@ -34,7 +34,7 @@ }

#[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct LWELayout { - pub n: Degree, + pub n: RingDegree, pub k: TorusPrecision, pub base2k: Base2K, }

@@ -48,7 +48,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }

@@ -67,8 +67,8 @@

fn k(&self) -> TorusPrecision { self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32 - 1) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32 - 1) } fn size(&self) -> usize {

@@ -126,7 +126,7 @@ }

} 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 { data: Zn::alloc((n + 1).into(), 1, k.0.div_ceil(base2k.0) as usize), k,

@@ -141,7 +141,7 @@ {

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) }

@@ -164,7 +164,7 @@ {

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 M: LWEAlloc, {

@@ -179,7 +179,7 @@ {

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 M: LWEAlloc, {
M poulpy-core/src/layouts/lwe_ksk.rs → poulpy-core/src/layouts/lwe_ksk.rs

@@ -6,20 +6,20 @@ source::Source,

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

@@ -68,7 +68,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/lwe_pt.rs → poulpy-core/src/layouts/lwe_pt.rs

@@ -2,7 +2,7 @@ use std::fmt;

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)] pub struct LWEPlaintextLayout {

@@ -19,8 +19,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(0) + fn n(&self) -> RingDegree { + RingDegree(0) } fn size(&self) -> usize {

@@ -43,8 +43,8 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { - Degree(self.data.n() as u32 - 1) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32 - 1) } fn size(&self) -> usize {
M poulpy-core/src/layouts/lwe_sk.rs → poulpy-core/src/layouts/lwe_sk.rs

@@ -5,7 +5,7 @@ };

use crate::{ dist::Distribution, - layouts::{Base2K, Degree, LWEInfos, TorusPrecision}, + layouts::{Base2K, LWEInfos, RingDegree, TorusPrecision}, }; pub struct LWESecret<D: Data> {

@@ -14,7 +14,7 @@ pub(crate) dist: Distribution,

} pub trait LWESecretAlloc { - fn alloc_lwe_secret(&self, n: Degree) -> LWESecret<Vec<u8>> { + fn alloc_lwe_secret(&self, n: RingDegree) -> LWESecret<Vec<u8>> { LWESecret { data: ScalarZnx::alloc(n.into(), 1), dist: Distribution::NONE,

@@ -25,7 +25,7 @@

impl<B: Backend> LWESecretAlloc for Module<B> {} impl LWESecret<Vec<u8>> { - pub fn alloc<M>(module: &M, n: Degree) -> Self + pub fn alloc<M>(module: &M, n: RingDegree) -> Self where M: LWESecretAlloc, {

@@ -55,8 +55,8 @@ fn k(&self) -> TorusPrecision {

TorusPrecision(0) } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {
M poulpy-core/src/layouts/lwe_to_glwe_ksk.rs → poulpy-core/src/layouts/lwe_to_glwe_ksk.rs

@@ -6,13 +6,13 @@ source::Source,

}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, - GLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKey, GLWESwitchingKeyAlloc, GLWESwitchingKeyToMut, + GLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision, }; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub struct LWEToGLWESwitchingKeyLayout { - pub n: Degree, + pub n: RingDegree, pub base2k: Base2K, pub k: TorusPrecision, pub rank_out: Rank,

@@ -28,7 +28,7 @@ fn k(&self) -> TorusPrecision {

self.k } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.n } }

@@ -69,7 +69,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/mod.rs → poulpy-core/src/layouts/mod.rs

@@ -35,12 +35,12 @@ pub use lwe_to_glwe_ksk::*;

use poulpy_hal::layouts::{Backend, Module}; -pub trait GetDegree { - fn n(&self) -> Degree; +pub trait GetRingDegree { + fn ring_degree(&self) -> RingDegree; } -impl<B: Backend> GetDegree for Module<B> { - fn n(&self) -> Degree { +impl<B: Backend> GetRingDegree for Module<B> { + fn ring_degree(&self) -> RingDegree { Self::n(&self).into() } }

@@ -202,14 +202,14 @@ }

}; } -newtype_u32!(Degree); +newtype_u32!(RingDegree); newtype_u32!(TorusPrecision); newtype_u32!(Base2K); newtype_u32!(Dnum); newtype_u32!(Rank); newtype_u32!(Dsize); -impl Degree { +impl RingDegree { pub fn log2(&self) -> usize { let n: usize = self.0 as usize; (usize::BITS - (n - 1).leading_zeros()) as _
M poulpy-core/src/layouts/prepared/gglwe_atk.rs → poulpy-core/src/layouts/prepared/gglwe_atk.rs

@@ -1,7 +1,7 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use crate::layouts::{ - AutomorphismKeyToRef, Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, TorusPrecision, + AutomorphismKeyToRef, Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, Rank, RingDegree, TorusPrecision, prepared::{ GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPreparedToRef,

@@ -15,7 +15,7 @@ pub(crate) p: i64,

} impl<D: Data, B: Backend> LWEInfos for AutomorphismKeyPrepared<D, B> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }
M poulpy-core/src/layouts/prepared/gglwe_ct.rs → poulpy-core/src/layouts/prepared/gglwe_ct.rs

@@ -4,7 +4,7 @@ layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat, VmpPMatToMut, VmpPMatToRef, ZnxInfos},

}; 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)]

@@ -16,8 +16,8 @@ pub(crate) dsize: Dsize,

} impl<D: Data, B: Backend> LWEInfos for GGLWEPrepared<D, B> { - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn base2k(&self) -> Base2K {

@@ -59,7 +59,7 @@ }

pub trait GGLWEPreparedAlloc<B: Backend> where - Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, + Self: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, { fn alloc_gglwe_prepared( &self,

@@ -96,7 +96,7 @@ fn alloc_gglwe_prepared_from_infos<A>(&self, infos: &A) -> GGLWEPrepared<Vec<u8>, B>

where A: GGLWEInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.alloc_gglwe_prepared( infos.base2k(), infos.k(),

@@ -137,7 +137,7 @@ fn bytes_of_gglwe_prepared_from_infos<A>(&self, infos: &A) -> usize

where A: GGLWEInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.bytes_of_gglwe_prepared( infos.base2k(), infos.k(),

@@ -149,7 +149,7 @@ )

} } -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> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

@@ -201,7 +201,7 @@ }

pub trait GGLWEPrepare<B: Backend> where - Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B>, + Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B>, { fn prepare_gglwe_tmp_bytes<A>(&self, infos: &A) -> usize where

@@ -223,8 +223,8 @@ {

let mut res: GGLWEPrepared<&mut [u8], B> = res.to_mut(); let other: GGLWE<&[u8]> = other.to_ref(); - assert_eq!(res.n(), self.n()); - assert_eq!(other.n(), self.n()); + assert_eq!(res.n(), self.ring_degree()); + assert_eq!(other.n(), self.ring_degree()); assert_eq!(res.base2k, other.base2k); assert_eq!(res.k, other.k); assert_eq!(res.dsize, other.dsize);

@@ -233,7 +233,7 @@ self.vmp_prepare(&mut res.data, &other.data, scratch);

} } -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> { pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
M poulpy-core/src/layouts/prepared/gglwe_ksk.rs → poulpy-core/src/layouts/prepared/gglwe_ksk.rs

@@ -1,8 +1,8 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToRef, - GLWESwtichingKeyGetMetaData, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWESwitchingKeySetMetaData, GLWESwitchingKeyToRef, GLWESwtichingKeyGetMetaData, + LWEInfos, Rank, RingDegree, TorusPrecision, prepared::{GGLWEPrepare, GGLWEPrepared, GGLWEPreparedAlloc, GGLWEPreparedToMut, GGLWEPreparedToRef}, };

@@ -34,7 +34,7 @@ }

} impl<D: Data, B: Backend> LWEInfos for GLWESwitchingKeyPrepared<D, B> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.key.n() }
M poulpy-core/src/layouts/prepared/gglwe_tsk.rs → poulpy-core/src/layouts/prepared/gglwe_tsk.rs

@@ -1,7 +1,7 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; 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::{ GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPreparedToRef,

@@ -14,7 +14,7 @@ pub(crate) keys: Vec<GLWESwitchingKeyPrepared<D, B>>,

} impl<D: Data, B: Backend> LWEInfos for TensorKeyPrepared<D, B> { - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.keys[0].n() }
M poulpy-core/src/layouts/prepared/ggsw_ct.rs → poulpy-core/src/layouts/prepared/ggsw_ct.rs

@@ -4,7 +4,7 @@ layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat, VmpPMatToMut, VmpPMatToRef, ZnxInfos},

}; 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)]

@@ -16,8 +16,8 @@ pub(crate) dsize: Dsize,

} impl<D: Data, B: Backend> LWEInfos for GGSWPrepared<D, B> { - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn base2k(&self) -> Base2K {

@@ -51,7 +51,7 @@ }

pub trait GGSWPreparedAlloc<B: Backend> where - Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, + Self: GetRingDegree + VmpPMatAlloc<B> + VmpPMatBytesOf, { fn alloc_ggsw_prepared( &self,

@@ -92,7 +92,7 @@ fn alloc_ggsw_prepared_from_infos<A>(&self, infos: &A) -> GGSWPrepared<Vec<u8>, B>

where A: GGSWInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.alloc_ggsw_prepared( infos.base2k(), infos.k(),

@@ -124,7 +124,7 @@ fn bytes_of_ggsw_prepared_from_infos<A>(&self, infos: &A) -> usize

where A: GGSWInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.bytes_of_ggsw_prepared( infos.base2k(), infos.k(),

@@ -135,7 +135,7 @@ )

} } -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> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

@@ -177,13 +177,13 @@ }

pub trait GGSWPrepare<B: Backend> where - Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B>, + Self: GetRingDegree + VmpPrepareTmpBytes + VmpPrepare<B>, { fn ggsw_prepare_tmp_bytes<A>(&self, infos: &A) -> usize where A: GGSWInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.vmp_prepare_tmp_bytes( infos.dnum().into(), (infos.rank() + 1).into(),

@@ -198,8 +198,8 @@ O: GGSWToRef,

{ let mut res: GGSWPrepared<&mut [u8], B> = res.to_mut(); let other: GGSW<&[u8]> = other.to_ref(); - assert_eq!(res.n(), self.n()); - assert_eq!(other.n(), self.n()); + assert_eq!(res.n(), self.ring_degree()); + assert_eq!(other.n(), self.ring_degree()); assert_eq!(res.k, other.k); assert_eq!(res.base2k, other.base2k); assert_eq!(res.dsize, other.dsize);

@@ -207,7 +207,7 @@ self.vmp_prepare(&mut res.data, &other.data, scratch);

} } -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> { pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A) -> usize
M poulpy-core/src/layouts/prepared/glwe_pk.rs → poulpy-core/src/layouts/prepared/glwe_pk.rs

@@ -5,7 +5,9 @@ };

use crate::{ 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)]

@@ -39,8 +41,8 @@ fn size(&self) -> usize {

self.data.size() } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } }

@@ -52,7 +54,7 @@ }

pub trait GLWEPublicKeyPreparedAlloc<B: Backend> 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> { GLWEPublicKeyPrepared {

@@ -118,7 +120,7 @@ }

pub trait GLWEPublicKeyPrepare<B: Backend> where - Self: GetDegree + VecZnxDftApply<B>, + Self: GetRingDegree + VecZnxDftApply<B>, { fn prepare_glwe_public_key<R, O>(&self, res: &mut R, other: &O) where

@@ -129,8 +131,8 @@ {

let mut res: GLWEPublicKeyPrepared<&mut [u8], B> = res.to_mut(); let other: GLWEPublicKey<&[u8]> = other.to_ref(); - assert_eq!(res.n(), self.n()); - assert_eq!(other.n(), self.n()); + assert_eq!(res.n(), self.ring_degree()); + assert_eq!(other.n(), self.ring_degree()); assert_eq!(res.size(), other.size()); assert_eq!(res.k(), other.k()); assert_eq!(res.base2k(), other.base2k());

@@ -144,7 +146,7 @@ res.set_dist(other.get_dist());

} } -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> { pub fn prepare<O, M>(&mut self, module: &M, other: &O)
M poulpy-core/src/layouts/prepared/glwe_sk.rs → poulpy-core/src/layouts/prepared/glwe_sk.rs

@@ -6,7 +6,7 @@

use crate::{ dist::Distribution, layouts::{ - Base2K, Degree, GLWEInfos, GLWESecret, GLWESecretToRef, GetDegree, GetDist, LWEInfos, Rank, TorusPrecision, + Base2K, GLWEInfos, GLWESecret, GLWESecretToRef, GetDist, GetRingDegree, LWEInfos, Rank, RingDegree, TorusPrecision, prepared::SetDist, }, };

@@ -31,8 +31,8 @@ fn k(&self) -> TorusPrecision {

TorusPrecision(0) } - fn n(&self) -> Degree { - Degree(self.data.n() as u32) + fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } fn size(&self) -> usize {

@@ -47,7 +47,7 @@ }

pub trait GLWESecretPreparedAlloc<B: Backend> where - Self: GetDegree + SvpPPolBytesOf + SvpPPolAlloc<B>, + Self: GetRingDegree + SvpPPolBytesOf + SvpPPolAlloc<B>, { fn alloc_glwe_secret_prepared(&self, rank: Rank) -> GLWESecretPrepared<Vec<u8>, B> { GLWESecretPrepared {

@@ -59,7 +59,7 @@ fn alloc_glwe_secret_prepared_from_infos<A>(&self, infos: &A) -> GLWESecretPrepared<Vec<u8>, B>

where A: GLWEInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); self.alloc_glwe_secret_prepared(infos.rank()) }

@@ -70,12 +70,12 @@ fn bytes_of_glwe_secret_from_infos<A>(&self, infos: &A) -> usize

where A: GLWEInfos, { - assert_eq!(self.n(), infos.n()); + assert_eq!(self.ring_degree(), infos.n()); 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> { pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self

@@ -110,8 +110,8 @@ }

} impl<D: Data, B: Backend> GLWESecretPrepared<D, B> { - pub fn n(&self) -> Degree { - Degree(self.data.n() as u32) + pub fn n(&self) -> RingDegree { + RingDegree(self.data.n() as u32) } pub fn rank(&self) -> Rank {
M poulpy-core/src/layouts/prepared/glwe_to_lwe_ksk.rs → poulpy-core/src/layouts/prepared/glwe_to_lwe_ksk.rs

@@ -1,7 +1,7 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKeyToRef, LWEInfos, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, GLWEToLWESwitchingKeyToRef, LWEInfos, Rank, RingDegree, TorusPrecision, prepared::{ GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPreparedToRef,

@@ -20,7 +20,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/prepared/lwe_ksk.rs → poulpy-core/src/layouts/prepared/lwe_ksk.rs

@@ -1,7 +1,7 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKeyToRef, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWESwitchingKeyToRef, Rank, RingDegree, TorusPrecision, prepared::{ GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPreparedToRef,

@@ -20,7 +20,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-core/src/layouts/prepared/lwe_to_glwe_ksk.rs → poulpy-core/src/layouts/prepared/lwe_to_glwe_ksk.rs

@@ -1,7 +1,7 @@

use poulpy_hal::layouts::{Backend, Data, DataMut, DataRef, Module, Scratch}; use crate::layouts::{ - Base2K, Degree, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKeyToRef, Rank, TorusPrecision, + Base2K, Dnum, Dsize, GGLWEInfos, GLWEInfos, LWEInfos, LWEToGLWESwitchingKeyToRef, Rank, RingDegree, TorusPrecision, prepared::{ GLWESwitchingKeyPrepare, GLWESwitchingKeyPrepared, GLWESwitchingKeyPreparedAlloc, GLWESwitchingKeyPreparedToMut, GLWESwitchingKeyPreparedToRef,

@@ -21,7 +21,7 @@ fn k(&self) -> TorusPrecision {

self.0.k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.0.n() }
M poulpy-schemes/benches/circuit_bootstrapping.rs → poulpy-schemes/benches/circuit_bootstrapping.rs

@@ -188,8 +188,8 @@ {

// Scratch space (4MB) 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_lwe: poulpy_core::layouts::Degree = params.cbt_infos.layout_brk.n_lwe(); + let n_glwe: poulpy_core::layouts::RingDegree = params.cbt_infos.layout_brk.n_glwe(); + let n_lwe: poulpy_core::layouts::RingDegree = params.cbt_infos.layout_brk.n_lwe(); let rank: poulpy_core::layouts::Rank = params.cbt_infos.layout_brk.rank; let module: Module<B> = Module::<B>::new(n_glwe.as_u32() as u64);
M poulpy-schemes/examples/circuit_bootstrapping.rs → poulpy-schemes/examples/circuit_bootstrapping.rs

@@ -1,8 +1,8 @@

use poulpy_core::{ GLWEOperations, layouts::{ - AutomorphismKeyLayout, GGSW, GGSWLayout, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWELayout, - LWEInfos, LWEPlaintext, LWESecret, TensorKeyLayout, + AutomorphismKeyLayout, GGSW, GGSWLayout, GLWE, GLWELayout, GLWEPlaintext, GLWESecret, LWE, LWEInfos, LWELayout, + LWEPlaintext, LWESecret, TensorKeyLayout, prepared::{GGSWPrepared, GLWESecretPrepared, PrepareAlloc}, }, };
M poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/block.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/block.rs

@@ -38,7 +38,7 @@ fn k(&self) -> poulpy_core::layouts::TorusPrecision {

self.blocks[0].k() } - fn n(&self) -> poulpy_core::layouts::Degree { + fn n(&self) -> poulpy_core::layouts::RingDegree { self.blocks[0].n() } }
M poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/block_prepared.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/block_prepared.rs

@@ -225,7 +225,7 @@ fn k(&self) -> poulpy_core::layouts::TorusPrecision {

self.blocks[0].k() } - fn n(&self) -> poulpy_core::layouts::Degree { + fn n(&self) -> poulpy_core::layouts::RingDegree { self.blocks[0].n() } }

@@ -256,7 +256,7 @@ fn k(&self) -> poulpy_core::layouts::TorusPrecision {

self.blocks[0].k() } - fn n(&self) -> poulpy_core::layouts::Degree { + fn n(&self) -> poulpy_core::layouts::RingDegree { self.blocks[0].n() } }
M poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/word.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/ciphertexts/word.rs

@@ -87,7 +87,7 @@ fn k(&self) -> poulpy_core::layouts::TorusPrecision {

self.0.k() } - fn n(&self) -> poulpy_core::layouts::Degree { + fn n(&self) -> poulpy_core::layouts::RingDegree { self.0.n() } }
M poulpy-schemes/src/tfhe/bdd_arithmetic/parameters.rs → poulpy-schemes/src/tfhe/bdd_arithmetic/parameters.rs

@@ -1,7 +1,7 @@

#[cfg(test)] use poulpy_core::layouts::{ - AutomorphismKeyLayout, Base2K, Degree, Dnum, Dsize, GGSWLayout, GLWELayout, GLWEToLWEKeyLayout, Rank, - TensorKeyLayout, TorusPrecision, + AutomorphismKeyLayout, Base2K, Dnum, Dsize, GGSWLayout, GLWELayout, GLWEToLWEKeyLayout, Rank, RingDegree, TensorKeyLayout, + TorusPrecision, }; #[cfg(test)]

@@ -26,7 +26,7 @@ pub(crate) const TEST_RANK: u32 = 2;

#[cfg(test)] pub(crate) static TEST_GLWE_INFOS: GLWELayout = GLWELayout { - n: Degree(TEST_N_GLWE), + n: RingDegree(TEST_N_GLWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(TEST_K_GLWE), rank: Rank(TEST_RANK),

@@ -34,7 +34,7 @@ };

#[cfg(test)] pub(crate) static TEST_GGSW_INFOS: GGSWLayout = GGSWLayout { - n: Degree(TEST_N_GLWE), + n: RingDegree(TEST_N_GLWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(TEST_K_GGSW), rank: Rank(TEST_RANK),

@@ -46,15 +46,15 @@ #[cfg(test)]

pub(crate) static TEST_BDD_KEY_LAYOUT: BDDKeyLayout = BDDKeyLayout { cbt: CircuitBootstrappingKeyLayout { layout_brk: BlindRotationKeyLayout { - n_glwe: Degree(TEST_N_GLWE), - n_lwe: Degree(TEST_N_LWE), + n_glwe: RingDegree(TEST_N_GLWE), + n_lwe: RingDegree(TEST_N_LWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(52), dnum: Dnum(3), rank: Rank(TEST_RANK), }, layout_atk: AutomorphismKeyLayout { - n: Degree(TEST_N_GLWE), + n: RingDegree(TEST_N_GLWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(52), rank: Rank(TEST_RANK),

@@ -62,7 +62,7 @@ dnum: Dnum(3),

dsize: Dsize(1), }, layout_tsk: TensorKeyLayout { - n: Degree(TEST_N_GLWE), + n: RingDegree(TEST_N_GLWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(52), rank: Rank(TEST_RANK),

@@ -71,7 +71,7 @@ dsize: Dsize(1),

}, }, ks: GLWEToLWEKeyLayout { - n: Degree(TEST_N_GLWE), + n: RingDegree(TEST_N_GLWE), base2k: Base2K(TEST_BASE2K), k: TorusPrecision(39), rank_in: Rank(TEST_RANK),
M poulpy-schemes/src/tfhe/blind_rotation/cggi_algo.rs → poulpy-schemes/src/tfhe/blind_rotation/cggi_algo.rs

@@ -13,7 +13,7 @@ };

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::{
M poulpy-schemes/src/tfhe/blind_rotation/key.rs → poulpy-schemes/src/tfhe/blind_rotation/key.rs

@@ -8,7 +8,7 @@

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 rank: Rank,

} 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 @@ fn k(&self) -> TorusPrecision {

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> 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 @@ fn k(&self) -> TorusPrecision {

self.keys[0].k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.keys[0].n() }
M poulpy-schemes/src/tfhe/blind_rotation/key_compressed.rs → poulpy-schemes/src/tfhe/blind_rotation/key_compressed.rs

@@ -8,7 +8,7 @@

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, 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() }
M poulpy-schemes/src/tfhe/blind_rotation/key_prepared.rs → poulpy-schemes/src/tfhe/blind_rotation/key_prepared.rs

@@ -8,7 +8,7 @@

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(crate) _phantom: PhantomData<BRT>,

} 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 @@ fn k(&self) -> TorusPrecision {

self.data[0].k() } - fn n(&self) -> Degree { + fn n(&self) -> RingDegree { self.data[0].n() }
M poulpy-schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs → poulpy-schemes/src/tfhe/blind_rotation/tests/generic_blind_rotation.rs

@@ -23,7 +23,7 @@ BlindRotationKeyPrepared, CGGI, LookUpTable, cggi_blind_rotate_tmp_bytes, mod_switch_2n,

}; 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}, };
M poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs → poulpy-schemes/src/tfhe/circuit_bootstrapping/tests/circuit_bootstrapping.rs

@@ -31,9 +31,7 @@ CircuitBootstrappingKeyPrepared, CirtuitBootstrappingExecute,

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