This commit is contained in:
Pro7ech
2025-10-14 18:46:25 +02:00
parent 0533cdff8a
commit 72dca47cbe
153 changed files with 3099 additions and 1956 deletions

View File

@@ -80,7 +80,7 @@ pub trait AutomorphismKeyPreparedAlloc<B: Backend>
where
Self: GLWESwitchingKeyPreparedAlloc<B>,
{
fn automorphism_key_prepared_alloc(
fn alloc_automorphism_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -89,12 +89,12 @@ where
dsize: Dsize,
) -> AutomorphismKeyPrepared<Vec<u8>, B> {
AutomorphismKeyPrepared::<Vec<u8>, B> {
key: self.glwe_switching_key_prepared_alloc(base2k, k, rank, rank, dnum, dsize),
key: self.alloc_glwe_switching_key_prepared(base2k, k, rank, rank, dnum, dsize),
p: 0,
}
}
fn automorphism_key_prepared_alloc_from_infos<A>(&self, infos: &A) -> AutomorphismKeyPrepared<Vec<u8>, B>
fn alloc_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> AutomorphismKeyPrepared<Vec<u8>, B>
where
A: GGLWEInfos,
{
@@ -103,7 +103,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for AutomorphismKeyPrepared"
);
self.automorphism_key_prepared_alloc(
self.alloc_automorphism_key_prepared(
infos.base2k(),
infos.k(),
infos.rank(),
@@ -112,7 +112,7 @@ where
)
}
fn automorphism_key_prepared_alloc_bytes(
fn bytes_of_automorphism_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -120,10 +120,10 @@ where
dnum: Dnum,
dsize: Dsize,
) -> usize {
self.glwe_switching_key_prepared_alloc_bytes(base2k, k, rank, rank, dnum, dsize)
self.bytes_of_glwe_switching_key_prepared(base2k, k, rank, rank, dnum, dsize)
}
fn automorphism_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_automorphism_key_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -132,7 +132,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for GGLWEAutomorphismKeyPrepared"
);
self.automorphism_key_prepared_alloc_bytes(
self.bytes_of_automorphism_key_prepared(
infos.base2k(),
infos.k(),
infos.rank(),
@@ -150,29 +150,29 @@ impl<B: Backend> AutomorphismKeyPrepared<Vec<u8>, B> {
A: GGLWEInfos,
Module<B>: AutomorphismKeyPreparedAlloc<B>,
{
module.automorphism_key_prepared_alloc_from_infos(infos)
module.alloc_automorphism_key_prepared_from_infos(infos)
}
pub fn alloc_with(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> Self
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> Self
where
Module<B>: AutomorphismKeyPreparedAlloc<B>,
{
module.automorphism_key_prepared_alloc(base2k, k, rank, dnum, dsize)
module.alloc_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
pub fn alloc_bytes<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: AutomorphismKeyPreparedAlloc<B>,
{
module.automorphism_key_prepared_alloc_bytes_from_infos(infos)
module.bytes_of_automorphism_key_prepared_from_infos(infos)
}
pub fn alloc_bytes_with(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
where
Module<B>: AutomorphismKeyPreparedAlloc<B>,
{
module.automorphism_key_prepared_alloc_bytes(base2k, k, rank, dnum, dsize)
module.bytes_of_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
}
@@ -180,19 +180,19 @@ pub trait AutomorphismKeyPrepare<B: Backend>
where
Self: GLWESwitchingKeyPrepare<B>,
{
fn automorphism_key_prepare_tmp_bytes<A>(&self, infos: &A) -> usize
fn prepare_automorphism_key_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepare_tmp_bytes(infos)
self.prepare_glwe_switching_key_tmp_bytes(infos)
}
fn automorphism_key_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
fn prepare_automorphism_key<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: AutomorphismKeyPreparedToMut<B> + SetAutomorphismGaloisElement,
O: AutomorphismKeyToRef + GetAutomorphismGaloisElement,
{
self.glwe_switching_prepare(&mut res.to_mut().key, &other.to_ref().key, scratch);
self.prepare_glwe_switching(&mut res.to_mut().key, &other.to_ref().key, scratch);
res.set_p(other.p());
}
}
@@ -204,7 +204,7 @@ impl<B: Backend> AutomorphismKeyPrepared<Vec<u8>, B> {
where
Module<B>: GLWESwitchingKeyPrepare<B>,
{
module.automorphism_key_prepare_tmp_bytes(self)
module.prepare_automorphism_key_tmp_bytes(self)
}
}
@@ -214,7 +214,7 @@ impl<D: DataMut, B: Backend> AutomorphismKeyPrepared<D, B> {
O: AutomorphismKeyToRef + GetAutomorphismGaloisElement,
Module<B>: AutomorphismKeyPrepare<B>,
{
module.automorphism_key_prepare(self, other, scratch);
module.prepare_automorphism_key(self, other, scratch);
}
}

View File

@@ -61,7 +61,7 @@ pub trait GGLWEPreparedAlloc<B: Backend>
where
Self: GetDegree + VmpPMatAlloc<B> + VmpPMatAllocBytes,
{
fn gglwe_prepared_alloc(
fn alloc_gglwe_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -92,12 +92,12 @@ where
}
}
fn gglwe_prepared_alloc_from_infos<A>(&self, infos: &A) -> GGLWEPrepared<Vec<u8>, B>
fn alloc_gglwe_prepared_from_infos<A>(&self, infos: &A) -> GGLWEPrepared<Vec<u8>, B>
where
A: GGLWEInfos,
{
assert_eq!(self.n(), infos.n());
self.gglwe_prepared_alloc(
self.alloc_gglwe_prepared(
infos.base2k(),
infos.k(),
infos.rank_in(),
@@ -107,7 +107,7 @@ where
)
}
fn gglwe_prepared_alloc_bytes(
fn bytes_of_gglwe_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -130,15 +130,15 @@ where
dsize.0,
);
self.vmp_pmat_alloc_bytes(dnum.into(), rank_in.into(), (rank_out + 1).into(), size)
self.vmp_pmat_bytes_of(dnum.into(), rank_in.into(), (rank_out + 1).into(), size)
}
fn gglwe_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_gglwe_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
assert_eq!(self.n(), infos.n());
self.gglwe_prepared_alloc_bytes(
self.bytes_of_gglwe_prepared(
infos.base2k(),
infos.k(),
infos.rank_in(),
@@ -159,7 +159,7 @@ where
where
A: GGLWEInfos,
{
module.gglwe_prepared_alloc_from_infos(infos)
module.alloc_gglwe_prepared_from_infos(infos)
}
pub fn alloc(
@@ -171,17 +171,17 @@ where
dnum: Dnum,
dsize: Dsize,
) -> Self {
module.gglwe_prepared_alloc(base2k, k, rank_in, rank_out, dnum, dsize)
module.alloc_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.gglwe_prepared_alloc_bytes_from_infos(infos)
module.bytes_of_gglwe_prepared_from_infos(infos)
}
pub fn alloc_bytes(
pub fn bytes_of(
module: &Module<B>,
base2k: Base2K,
k: TorusPrecision,
@@ -190,7 +190,7 @@ where
dnum: Dnum,
dsize: Dsize,
) -> usize {
module.gglwe_prepared_alloc_bytes(base2k, k, rank_in, rank_out, dnum, dsize)
module.bytes_of_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
}
@@ -198,7 +198,7 @@ pub trait GGLWEPrepare<B: Backend>
where
Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B>,
{
fn gglwe_prepare_tmp_bytes<A>(&self, infos: &A) -> usize
fn prepare_gglwe_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -210,7 +210,7 @@ where
)
}
fn gglwe_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
fn prepare_gglwe<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: GGLWEPreparedToMut<B>,
O: GGLWEToRef,
@@ -238,7 +238,7 @@ where
where
O: GGLWEToRef,
{
module.gglwe_prepare(self, other, scratch);
module.prepare_gglwe(self, other, scratch);
}
}
@@ -247,7 +247,7 @@ impl<B: Backend> GGLWEPrepared<Vec<u8>, B> {
where
Module<B>: GGLWEPrepare<B>,
{
module.gglwe_prepare_tmp_bytes(self)
module.prepare_gglwe_tmp_bytes(self)
}
}

View File

@@ -79,7 +79,7 @@ pub trait GLWESwitchingKeyPreparedAlloc<B: Backend>
where
Self: GGLWEPreparedAlloc<B>,
{
fn glwe_switching_key_prepared_alloc(
fn alloc_glwe_switching_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -89,7 +89,7 @@ where
dsize: Dsize,
) -> GLWESwitchingKeyPrepared<Vec<u8>, B> {
GLWESwitchingKeyPrepared::<Vec<u8>, B> {
key: self.gglwe_prepared_alloc(base2k, k, rank_in, rank_out, dnum, dsize),
key: self.alloc_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize),
sk_in_n: 0,
sk_out_n: 0,
}
@@ -99,7 +99,7 @@ where
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepared_alloc(
self.alloc_glwe_switching_key_prepared(
infos.base2k(),
infos.k(),
infos.rank_in(),
@@ -109,7 +109,7 @@ where
)
}
fn glwe_switching_key_prepared_alloc_bytes(
fn bytes_of_glwe_switching_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -118,14 +118,14 @@ where
dnum: Dnum,
dsize: Dsize,
) -> usize {
self.gglwe_prepared_alloc_bytes(base2k, k, rank_in, rank_out, dnum, dsize)
self.bytes_of_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
fn glwe_switching_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn glwe_switching_key_prepared_bytes_of_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepared_alloc_bytes(
self.bytes_of_glwe_switching_key_prepared(
infos.base2k(),
infos.k(),
infos.rank_in(),
@@ -158,17 +158,17 @@ where
dnum: Dnum,
dsize: Dsize,
) -> Self {
module.glwe_switching_key_prepared_alloc(base2k, k, rank_in, rank_out, dnum, dsize)
module.alloc_glwe_switching_key_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.glwe_switching_key_prepared_alloc_bytes_from_infos(infos)
module.glwe_switching_key_prepared_bytes_of_from_infos(infos)
}
pub fn alloc_bytes(
pub fn bytes_of(
module: &Module<B>,
base2k: Base2K,
k: TorusPrecision,
@@ -177,7 +177,7 @@ where
dnum: Dnum,
dsize: Dsize,
) -> usize {
module.glwe_switching_key_prepared_alloc_bytes(base2k, k, rank_in, rank_out, dnum, dsize)
module.bytes_of_glwe_switching_key_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
}
@@ -185,19 +185,19 @@ pub trait GLWESwitchingKeyPrepare<B: Backend>
where
Self: GGLWEPrepare<B>,
{
fn glwe_switching_key_prepare_tmp_bytes<A>(&self, infos: &A) -> usize
fn prepare_glwe_switching_key_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.gglwe_prepare_tmp_bytes(infos)
self.prepare_gglwe_tmp_bytes(infos)
}
fn glwe_switching_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
fn prepare_glwe_switching<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: GLWESwitchingKeyPreparedToMut<B> + GLWESwitchingKeySetMetaData,
O: GLWESwitchingKeyToRef + GLWESwtichingKeyGetMetaData,
{
self.gglwe_prepare(&mut res.to_mut().key, &other.to_ref().key, scratch);
self.prepare_gglwe(&mut res.to_mut().key, &other.to_ref().key, scratch);
res.set_sk_in_n(other.sk_in_n());
res.set_sk_out_n(other.sk_out_n());
}
@@ -211,7 +211,7 @@ impl<D: DataMut, B: Backend> GLWESwitchingKeyPrepared<D, B> {
O: GLWESwitchingKeyToRef + GLWESwtichingKeyGetMetaData,
Module<B>: GLWESwitchingKeyPrepare<B>,
{
module.glwe_switching_prepare(self, other, scratch);
module.prepare_glwe_switching(self, other, scratch);
}
}
@@ -220,7 +220,7 @@ where
Module<B>: GLWESwitchingKeyPrepare<B>,
{
pub fn prepare_tmp_bytes(&self, module: &Module<B>) -> usize {
module.gglwe_prepare_tmp_bytes(self)
module.prepare_gglwe_tmp_bytes(self)
}
}

View File

@@ -59,7 +59,7 @@ pub trait TensorKeyPreparedAlloc<B: Backend>
where
Self: GLWESwitchingKeyPreparedAlloc<B>,
{
fn tensor_key_prepared_alloc(
fn alloc_tensor_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -70,12 +70,12 @@ where
let pairs: u32 = (((rank.as_u32() + 1) * rank.as_u32()) >> 1).max(1);
TensorKeyPrepared {
keys: (0..pairs)
.map(|_| self.glwe_switching_key_prepared_alloc(base2k, k, Rank(1), rank, dnum, dsize))
.map(|_| self.alloc_glwe_switching_key_prepared(base2k, k, Rank(1), rank, dnum, dsize))
.collect(),
}
}
fn tensor_key_prepared_alloc_from_infos<A>(&self, infos: &A) -> TensorKeyPrepared<Vec<u8>, B>
fn alloc_tensor_key_prepared_from_infos<A>(&self, infos: &A) -> TensorKeyPrepared<Vec<u8>, B>
where
A: GGLWEInfos,
{
@@ -84,7 +84,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for GGLWETensorKeyPrepared"
);
self.tensor_key_prepared_alloc(
self.alloc_tensor_key_prepared(
infos.base2k(),
infos.k(),
infos.dnum(),
@@ -93,16 +93,16 @@ where
)
}
fn tensor_key_prepared_alloc_bytes(&self, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize {
fn bytes_of_tensor_key_prepared(&self, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize {
let pairs: usize = (((rank.0 + 1) * rank.0) >> 1).max(1) as usize;
pairs * self.glwe_switching_key_prepared_alloc_bytes(base2k, k, Rank(1), rank, dnum, dsize)
pairs * self.bytes_of_glwe_switching_key_prepared(base2k, k, Rank(1), rank, dnum, dsize)
}
fn tensor_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_tensor_key_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.tensor_key_prepared_alloc_bytes(
self.bytes_of_tensor_key_prepared(
infos.base2k(),
infos.k(),
infos.rank(),
@@ -122,29 +122,22 @@ where
where
A: GGLWEInfos,
{
module.tensor_key_prepared_alloc_from_infos(infos)
module.alloc_tensor_key_prepared_from_infos(infos)
}
pub fn alloc_with(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> Self {
module.tensor_key_prepared_alloc(base2k, k, dnum, dsize, rank)
module.alloc_tensor_key_prepared(base2k, k, dnum, dsize, rank)
}
pub fn alloc_bytes<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.tensor_key_prepared_alloc_bytes_from_infos(infos)
module.bytes_of_tensor_key_prepared_from_infos(infos)
}
pub fn alloc_bytes_with(
module: &Module<B>,
base2k: Base2K,
k: TorusPrecision,
rank: Rank,
dnum: Dnum,
dsize: Dsize,
) -> usize {
module.tensor_key_prepared_alloc_bytes(base2k, k, rank, dnum, dsize)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize {
module.bytes_of_tensor_key_prepared(base2k, k, rank, dnum, dsize)
}
}
@@ -174,14 +167,14 @@ pub trait TensorKeyPrepare<B: Backend>
where
Self: GLWESwitchingKeyPrepare<B>,
{
fn tensor_key_prepare_tmp_bytes<A>(&self, infos: &A) -> usize
fn prepare_tensor_key_tmp_bytes<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepare_tmp_bytes(infos)
self.prepare_glwe_switching_key_tmp_bytes(infos)
}
fn tensor_key_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
fn prepare_tensor_key<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: TensorKeyPreparedToMut<B>,
O: TensorKeyToRef,
@@ -192,7 +185,7 @@ where
assert_eq!(res.keys.len(), other.keys.len());
for (a, b) in res.keys.iter_mut().zip(other.keys.iter()) {
self.glwe_switching_prepare(a, b, scratch);
self.prepare_glwe_switching(a, b, scratch);
}
}
}
@@ -207,7 +200,7 @@ where
where
A: GGLWEInfos,
{
module.tensor_key_prepare_tmp_bytes(infos)
module.prepare_tensor_key_tmp_bytes(infos)
}
}
@@ -219,7 +212,7 @@ where
where
O: TensorKeyToRef,
{
module.tensor_key_prepare(self, other, scratch);
module.prepare_tensor_key(self, other, scratch);
}
}

View File

@@ -53,7 +53,7 @@ pub trait GGSWPreparedAlloc<B: Backend>
where
Self: GetDegree + VmpPMatAlloc<B> + VmpPMatAllocBytes,
{
fn ggsw_prepared_alloc(
fn alloc_ggsw_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
@@ -88,12 +88,12 @@ where
}
}
fn ggsw_prepared_alloc_from_infos<A>(&self, infos: &A) -> GGSWPrepared<Vec<u8>, B>
fn alloc_ggsw_prepared_from_infos<A>(&self, infos: &A) -> GGSWPrepared<Vec<u8>, B>
where
A: GGSWInfos,
{
assert_eq!(self.n(), infos.n());
self.ggsw_prepared_alloc(
self.alloc_ggsw_prepared(
infos.base2k(),
infos.k(),
infos.dnum(),
@@ -102,7 +102,7 @@ where
)
}
fn ggsw_prepared_alloc_bytes(&self, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> usize {
fn bytes_of_ggsw_prepared(&self, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> usize {
let size: usize = k.0.div_ceil(base2k.0) as usize;
debug_assert!(
size as u32 > dsize.0,
@@ -117,15 +117,15 @@ where
dsize.0,
);
self.vmp_pmat_alloc_bytes(dnum.into(), (rank + 1).into(), (rank + 1).into(), size)
self.vmp_pmat_bytes_of(dnum.into(), (rank + 1).into(), (rank + 1).into(), size)
}
fn ggsw_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_ggsw_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GGSWInfos,
{
assert_eq!(self.n(), infos.n());
self.ggsw_prepared_alloc_bytes(
self.bytes_of_ggsw_prepared(
infos.base2k(),
infos.k(),
infos.dnum(),
@@ -145,29 +145,22 @@ where
where
A: GGSWInfos,
{
module.ggsw_prepared_alloc_from_infos(infos)
module.alloc_ggsw_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> Self {
module.ggsw_prepared_alloc(base2k, k, dnum, dsize, rank)
module.alloc_ggsw_prepared(base2k, k, dnum, dsize, rank)
}
pub fn alloc_bytes<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGSWInfos,
{
module.ggsw_prepared_alloc_bytes_from_infos(infos)
module.bytes_of_ggsw_prepared_from_infos(infos)
}
pub fn alloc_bytes_with(
module: &Module<B>,
base2k: Base2K,
k: TorusPrecision,
dnum: Dnum,
dsize: Dsize,
rank: Rank,
) -> usize {
module.ggsw_prepared_alloc_bytes(base2k, k, dnum, dsize, rank)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> usize {
module.bytes_of_ggsw_prepared(base2k, k, dnum, dsize, rank)
}
}

View File

@@ -54,7 +54,7 @@ pub trait GLWEPublicKeyPreparedAlloc<B: Backend>
where
Self: GetDegree + VecZnxDftAlloc<B> + VecZnxDftAllocBytes,
{
fn glwe_public_key_prepared_alloc(&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 {
data: self.vec_znx_dft_alloc((rank + 1).into(), k.0.div_ceil(base2k.0) as usize),
base2k,
@@ -63,22 +63,22 @@ where
}
}
fn glwe_public_key_alloc_from_infos<A>(&self, infos: &A) -> GLWEPublicKeyPrepared<Vec<u8>, B>
fn alloc_glwe_public_key_prepared_from_infos<A>(&self, infos: &A) -> GLWEPublicKeyPrepared<Vec<u8>, B>
where
A: GLWEInfos,
{
self.glwe_public_key_prepared_alloc(infos.base2k(), infos.k(), infos.rank())
self.alloc_glwe_public_key_prepared(infos.base2k(), infos.k(), infos.rank())
}
fn glwe_public_key_prepared_alloc_bytes(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
self.vec_znx_dft_alloc_bytes((rank + 1).into(), k.0.div_ceil(base2k.0) as usize)
fn bytes_of_glwe_public_key_prepared(&self, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
self.vec_znx_dft_bytes_of((rank + 1).into(), k.0.div_ceil(base2k.0) as usize)
}
fn glwe_public_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_glwe_public_key_prepared_from_infos<A>(&self, infos: &A) -> usize
where
A: GLWEInfos,
{
self.glwe_public_key_prepared_alloc_bytes(infos.base2k(), infos.k(), infos.rank())
self.bytes_of_glwe_public_key_prepared(infos.base2k(), infos.k(), infos.rank())
}
}
@@ -92,22 +92,22 @@ where
where
A: GLWEInfos,
{
module.glwe_public_key_alloc_from_infos(infos)
module.alloc_glwe_public_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> Self {
module.glwe_public_key_prepared_alloc(base2k, k, rank)
module.alloc_glwe_public_key_prepared(base2k, k, rank)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GLWEInfos,
{
module.glwe_public_key_prepared_alloc_bytes_from_infos(infos)
module.bytes_of_glwe_public_key_prepared_from_infos(infos)
}
pub fn alloc_bytes(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
module.glwe_public_key_prepared_alloc_bytes(base2k, k, rank)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
module.bytes_of_glwe_public_key_prepared(base2k, k, rank)
}
}
@@ -115,7 +115,7 @@ pub trait GLWEPublicKeyPrepare<B: Backend>
where
Self: GetDegree + VecZnxDftApply<B>,
{
fn glwe_public_key_prepare<R, O>(&self, res: &mut R, other: &O)
fn prepare_glwe_public_key<R, O>(&self, res: &mut R, other: &O)
where
R: GLWEPublicKeyPreparedToMut<B> + SetDist,
O: GLWEPublicKeyToRef + GetDist,
@@ -149,7 +149,7 @@ where
where
O: GLWEPublicKeyToRef + GetDist,
{
module.glwe_public_key_prepare(self, other);
module.prepare_glwe_public_key(self, other);
}
}

View File

@@ -49,29 +49,29 @@ pub trait GLWESecretPreparedAlloc<B: Backend>
where
Self: GetDegree + SvpPPolAllocBytes + SvpPPolAlloc<B>,
{
fn glwe_secret_prepared_alloc(&self, rank: Rank) -> GLWESecretPrepared<Vec<u8>, B> {
fn alloc_glwe_secret_prepared(&self, rank: Rank) -> GLWESecretPrepared<Vec<u8>, B> {
GLWESecretPrepared {
data: self.svp_ppol_alloc(rank.into()),
dist: Distribution::NONE,
}
}
fn glwe_secret_prepared_alloc_from_infos<A>(&self, infos: &A) -> GLWESecretPrepared<Vec<u8>, B>
fn alloc_glwe_secret_prepared_from_infos<A>(&self, infos: &A) -> GLWESecretPrepared<Vec<u8>, B>
where
A: GLWEInfos,
{
assert_eq!(self.n(), infos.n());
self.glwe_secret_prepared_alloc(infos.rank())
self.alloc_glwe_secret_prepared(infos.rank())
}
fn glwe_secret_alloc_bytes(&self, rank: Rank) -> usize {
self.svp_ppol_alloc_bytes(rank.into())
fn bytes_of_glwe_secret(&self, rank: Rank) -> usize {
self.svp_ppol_bytes_of(rank.into())
}
fn glwe_secret_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn bytes_of_glwe_secret_from_infos<A>(&self, infos: &A) -> usize
where
A: GLWEInfos,
{
assert_eq!(self.n(), infos.n());
self.glwe_secret_alloc_bytes(infos.rank())
self.bytes_of_glwe_secret(infos.rank())
}
}
@@ -85,22 +85,22 @@ where
where
A: GLWEInfos,
{
module.glwe_secret_prepared_alloc_from_infos(infos)
module.alloc_glwe_secret_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, rank: Rank) -> Self {
module.glwe_secret_prepared_alloc(rank)
module.alloc_glwe_secret_prepared(rank)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GLWEInfos,
{
module.glwe_secret_alloc_bytes_from_infos(infos)
module.bytes_of_glwe_secret_from_infos(infos)
}
pub fn alloc_bytes(module: &Module<B>, rank: Rank) -> usize {
module.glwe_secret_alloc_bytes(rank)
pub fn bytes_of(module: &Module<B>, rank: Rank) -> usize {
module.bytes_of_glwe_secret(rank)
}
}
@@ -118,7 +118,7 @@ pub trait GLWESecretPrepare<B: Backend>
where
Self: SvpPrepare<B>,
{
fn glwe_secret_prepare<R, O>(&self, res: &mut R, other: &O)
fn prepare_glwe_secret<R, O>(&self, res: &mut R, other: &O)
where
R: GLWESecretPreparedToMut<B> + SetDist,
O: GLWESecretToRef + GetDist,

View File

@@ -64,7 +64,7 @@ where
rank_in: Rank,
dnum: Dnum,
) -> GLWEToLWESwitchingKeyPrepared<Vec<u8>, B> {
GLWEToLWESwitchingKeyPrepared(self.glwe_switching_key_prepared_alloc(base2k, k, rank_in, Rank(1), dnum, Dsize(1)))
GLWEToLWESwitchingKeyPrepared(self.alloc_glwe_switching_key_prepared(base2k, k, rank_in, Rank(1), dnum, Dsize(1)))
}
fn glwe_to_lwe_switching_key_prepared_alloc_from_infos<A>(&self, infos: &A) -> GLWEToLWESwitchingKeyPrepared<Vec<u8>, B>
where
@@ -83,17 +83,11 @@ where
self.glwe_to_lwe_switching_key_prepared_alloc(infos.base2k(), infos.k(), infos.rank_in(), infos.dnum())
}
fn glwe_to_lwe_switching_key_prepared_alloc_bytes(
&self,
base2k: Base2K,
k: TorusPrecision,
rank_in: Rank,
dnum: Dnum,
) -> usize {
self.glwe_switching_key_prepared_alloc_bytes(base2k, k, rank_in, Rank(1), dnum, Dsize(1))
fn glwe_to_lwe_switching_key_prepared_bytes_of(&self, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> usize {
self.bytes_of_glwe_switching_key_prepared(base2k, k, rank_in, Rank(1), dnum, Dsize(1))
}
fn glwe_to_lwe_switching_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn glwe_to_lwe_switching_key_prepared_bytes_of_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -107,7 +101,7 @@ where
1,
"dsize > 1 is not supported for GLWEToLWESwitchingKeyPrepared"
);
self.glwe_to_lwe_switching_key_prepared_alloc_bytes(infos.base2k(), infos.k(), infos.rank_in(), infos.dnum())
self.glwe_to_lwe_switching_key_prepared_bytes_of(infos.base2k(), infos.k(), infos.rank_in(), infos.dnum())
}
}
@@ -128,15 +122,15 @@ where
module.glwe_to_lwe_switching_key_prepared_alloc(base2k, k, rank_in, dnum)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.glwe_to_lwe_switching_key_prepared_alloc_bytes_from_infos(infos)
module.glwe_to_lwe_switching_key_prepared_bytes_of_from_infos(infos)
}
pub fn alloc_bytes_with(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> usize {
module.glwe_to_lwe_switching_key_prepared_alloc_bytes(base2k, k, rank_in, dnum)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> usize {
module.glwe_to_lwe_switching_key_prepared_bytes_of(base2k, k, rank_in, dnum)
}
}
@@ -148,7 +142,7 @@ where
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepare_tmp_bytes(infos);
self.prepare_glwe_switching_key_tmp_bytes(infos);
}
fn glwe_to_lwe_switching_key_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
@@ -156,7 +150,7 @@ where
R: GLWEToLWESwitchingKeyPreparedToMut<B>,
O: GLWEToLWESwitchingKeyToRef,
{
self.glwe_switching_prepare(&mut res.to_mut().0, &other.to_ref().0, scratch);
self.prepare_glwe_switching(&mut res.to_mut().0, &other.to_ref().0, scratch);
}
}

View File

@@ -56,13 +56,13 @@ pub trait LWESwitchingKeyPreparedAlloc<B: Backend>
where
Self: GLWESwitchingKeyPreparedAlloc<B>,
{
fn lwe_switching_key_prepared_alloc(
fn alloc_lwe_switching_key_prepared(
&self,
base2k: Base2K,
k: TorusPrecision,
dnum: Dnum,
) -> LWESwitchingKeyPrepared<Vec<u8>, B> {
LWESwitchingKeyPrepared(self.glwe_switching_key_prepared_alloc(base2k, k, Rank(1), Rank(1), dnum, Dsize(1)))
LWESwitchingKeyPrepared(self.alloc_glwe_switching_key_prepared(base2k, k, Rank(1), Rank(1), dnum, Dsize(1)))
}
fn lwe_switching_key_prepared_alloc_from_infos<A>(&self, infos: &A) -> LWESwitchingKeyPrepared<Vec<u8>, B>
@@ -84,14 +84,14 @@ where
1,
"rank_out > 1 is not supported for LWESwitchingKey"
);
self.lwe_switching_key_prepared_alloc(infos.base2k(), infos.k(), infos.dnum())
self.alloc_lwe_switching_key_prepared(infos.base2k(), infos.k(), infos.dnum())
}
fn lwe_switching_key_prepared_alloc_bytes(&self, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
self.glwe_switching_key_prepared_alloc_bytes(base2k, k, Rank(1), Rank(1), dnum, Dsize(1))
fn lwe_switching_key_prepared_bytes_of(&self, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
self.bytes_of_glwe_switching_key_prepared(base2k, k, Rank(1), Rank(1), dnum, Dsize(1))
}
fn lwe_switching_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn lwe_switching_key_prepared_bytes_of_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -110,7 +110,7 @@ where
1,
"rank_out > 1 is not supported for LWESwitchingKey"
);
self.lwe_switching_key_prepared_alloc_bytes(infos.base2k(), infos.k(), infos.dnum())
self.lwe_switching_key_prepared_bytes_of(infos.base2k(), infos.k(), infos.dnum())
}
}
@@ -128,18 +128,18 @@ where
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> Self {
module.lwe_switching_key_prepared_alloc(base2k, k, dnum)
module.alloc_lwe_switching_key_prepared(base2k, k, dnum)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.lwe_switching_key_prepared_alloc_bytes_from_infos(infos)
module.lwe_switching_key_prepared_bytes_of_from_infos(infos)
}
pub fn alloc_bytes(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
module.lwe_switching_key_prepared_alloc_bytes(base2k, k, dnum)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
module.lwe_switching_key_prepared_bytes_of(base2k, k, dnum)
}
}
@@ -151,14 +151,14 @@ where
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepare_tmp_bytes(infos);
self.prepare_glwe_switching_key_tmp_bytes(infos);
}
fn lwe_switching_key_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
where
R: LWESwitchingKeyPreparedToMut<B>,
O: LWESwitchingKeyToRef,
{
self.glwe_switching_prepare(&mut res.to_mut().0, &other.to_ref().0, scratch);
self.prepare_glwe_switching(&mut res.to_mut().0, &other.to_ref().0, scratch);
}
}

View File

@@ -65,7 +65,7 @@ where
rank_out: Rank,
dnum: Dnum,
) -> LWEToGLWESwitchingKeyPrepared<Vec<u8>, B> {
LWEToGLWESwitchingKeyPrepared(self.glwe_switching_key_prepared_alloc(base2k, k, Rank(1), rank_out, dnum, Dsize(1)))
LWEToGLWESwitchingKeyPrepared(self.alloc_glwe_switching_key_prepared(base2k, k, Rank(1), rank_out, dnum, Dsize(1)))
}
fn lwe_to_glwe_switching_key_prepared_alloc_from_infos<A>(&self, infos: &A) -> LWEToGLWESwitchingKeyPrepared<Vec<u8>, B>
where
@@ -84,17 +84,17 @@ where
self.lwe_to_glwe_switching_key_prepared_alloc(infos.base2k(), infos.k(), infos.rank_out(), infos.dnum())
}
fn lwe_to_glwe_switching_key_prepared_alloc_bytes(
fn lwe_to_glwe_switching_key_prepared_bytes_of(
&self,
base2k: Base2K,
k: TorusPrecision,
rank_out: Rank,
dnum: Dnum,
) -> usize {
self.glwe_switching_key_prepared_alloc_bytes(base2k, k, Rank(1), rank_out, dnum, Dsize(1))
self.bytes_of_glwe_switching_key_prepared(base2k, k, Rank(1), rank_out, dnum, Dsize(1))
}
fn lwe_to_glwe_switching_key_prepared_alloc_bytes_from_infos<A>(&self, infos: &A) -> usize
fn lwe_to_glwe_switching_key_prepared_bytes_of_from_infos<A>(&self, infos: &A) -> usize
where
A: GGLWEInfos,
{
@@ -108,7 +108,7 @@ where
1,
"dsize > 1 is not supported for LWEToGLWESwitchingKey"
);
self.lwe_to_glwe_switching_key_prepared_alloc_bytes(infos.base2k(), infos.k(), infos.rank_out(), infos.dnum())
self.lwe_to_glwe_switching_key_prepared_bytes_of(infos.base2k(), infos.k(), infos.rank_out(), infos.dnum())
}
}
@@ -129,15 +129,15 @@ where
module.lwe_to_glwe_switching_key_prepared_alloc(base2k, k, rank_out, dnum)
}
pub fn alloc_bytes_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
{
module.lwe_to_glwe_switching_key_prepared_alloc_bytes_from_infos(infos)
module.lwe_to_glwe_switching_key_prepared_bytes_of_from_infos(infos)
}
pub fn alloc_bytes_with(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> usize {
module.lwe_to_glwe_switching_key_prepared_alloc_bytes(base2k, k, rank_out, dnum)
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> usize {
module.lwe_to_glwe_switching_key_prepared_bytes_of(base2k, k, rank_out, dnum)
}
}
@@ -149,7 +149,7 @@ where
where
A: GGLWEInfos,
{
self.glwe_switching_key_prepare_tmp_bytes(infos);
self.prepare_glwe_switching_key_tmp_bytes(infos);
}
fn lwe_to_glwe_switching_key_prepare<R, O>(&self, res: &mut R, other: &O, scratch: &mut Scratch<B>)
@@ -157,7 +157,7 @@ where
R: LWEToGLWESwitchingKeyPreparedToMut<B>,
O: LWEToGLWESwitchingKeyToRef,
{
self.glwe_switching_prepare(&mut res.to_mut().0, &other.to_ref().0, scratch);
self.prepare_glwe_switching(&mut res.to_mut().0, &other.to_ref().0, scratch);
}
}