This commit is contained in:
Pro7ech
2025-10-15 15:39:52 +02:00
parent 58bee4805e
commit 15ee02e21d
65 changed files with 927 additions and 922 deletions

View File

@@ -13,13 +13,13 @@ use crate::{
};
impl AutomorphismKeyCompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftBytesOf + VecZnxNormalizeTmpBytes + SvpPPolBytesOf,
{
assert_eq!(module.n() as u32, infos.n());
GLWESwitchingKeyCompressed::encrypt_sk_scratch_space(module, infos) + GLWESecret::bytes_of(infos.n(), infos.rank_out())
GLWESwitchingKeyCompressed::encrypt_sk_tmp_bytes(module, infos) + GLWESecret::bytes_of(infos.n(), infos.rank_out())
}
}
@@ -63,10 +63,10 @@ where
assert_eq!(res.rank_out(), res.rank_in());
assert_eq!(sk.rank(), res.rank_out());
assert!(
scratch.available() >= AutomorphismKeyCompressed::encrypt_sk_scratch_space(self, res),
"scratch.available(): {} < AutomorphismKey::encrypt_sk_scratch_space: {}",
scratch.available() >= AutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res),
"scratch.available(): {} < AutomorphismKey::encrypt_sk_tmp_bytes: {}",
scratch.available(),
AutomorphismKeyCompressed::encrypt_sk_scratch_space(self, res)
AutomorphismKeyCompressed::encrypt_sk_tmp_bytes(self, res)
)
}

View File

@@ -34,12 +34,12 @@ impl<D: DataMut> GGLWECompressed<D> {
}
impl GGLWECompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftBytesOf + VecZnxNormalizeTmpBytes,
{
GGLWE::encrypt_sk_scratch_space(module, infos)
GGLWE::encrypt_sk_tmp_bytes(module, infos)
}
}
@@ -106,10 +106,10 @@ where
assert_eq!(res.n(), sk.n());
assert_eq!(pt.n() as u32, sk.n());
assert!(
scratch.available() >= GGLWECompressed::encrypt_sk_scratch_space(self, res),
"scratch.available: {} < GGLWECiphertext::encrypt_sk_scratch_space: {}",
scratch.available() >= GGLWECompressed::encrypt_sk_tmp_bytes(self, res),
"scratch.available: {} < GGLWECiphertext::encrypt_sk_tmp_bytes: {}",
scratch.available(),
GGLWECompressed::encrypt_sk_scratch_space(self, res)
GGLWECompressed::encrypt_sk_tmp_bytes(self, res)
);
assert!(
res.dnum().0 * res.dsize().0 * res.base2k().0 <= res.k().0,

View File

@@ -14,12 +14,12 @@ use crate::{
};
impl GLWESwitchingKeyCompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftBytesOf + VecZnxNormalizeTmpBytes + SvpPPolBytesOf,
{
(GGLWE::encrypt_sk_scratch_space(module, infos) | ScalarZnx::bytes_of(module.n(), 1))
(GGLWE::encrypt_sk_tmp_bytes(module, infos) | ScalarZnx::bytes_of(module.n(), 1))
+ ScalarZnx::bytes_of(module.n(), infos.rank_in().into())
+ GLWESecretPrepared::bytes_of(module, infos.rank_out())
}
@@ -91,10 +91,10 @@ where
assert!(sk_in.n().0 <= self.n() as u32);
assert!(sk_out.n().0 <= self.n() as u32);
assert!(
scratch.available() >= GLWESwitchingKey::encrypt_sk_scratch_space(self, res),
"scratch.available()={} < GLWESwitchingKey::encrypt_sk_scratch_space={}",
scratch.available() >= GLWESwitchingKey::encrypt_sk_tmp_bytes(self, res),
"scratch.available()={} < GLWESwitchingKey::encrypt_sk_tmp_bytes={}",
scratch.available(),
GLWESwitchingKey::encrypt_sk_scratch_space(self, res)
GLWESwitchingKey::encrypt_sk_tmp_bytes(self, res)
)
}

View File

@@ -16,12 +16,12 @@ use crate::{
};
impl TensorKeyCompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: SvpPPolBytesOf + VecZnxNormalizeTmpBytes + VecZnxDftBytesOf + VecZnxNormalizeTmpBytes + VecZnxBigBytesOf,
{
TensorKey::encrypt_sk_scratch_space(module, infos)
TensorKey::encrypt_sk_tmp_bytes(module, infos)
}
}

View File

@@ -14,12 +14,12 @@ use crate::{
};
impl GGSWCompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGSWInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftBytesOf,
{
GGSW::encrypt_sk_scratch_space(module, infos)
GGSW::encrypt_sk_tmp_bytes(module, infos)
}
}

View File

@@ -14,12 +14,12 @@ use crate::{
};
impl GLWECompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
pub fn encrypt_sk_tmp_bytes<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftBytesOf,
{
GLWE::encrypt_sk_scratch_space(module, infos)
GLWE::encrypt_sk_tmp_bytes(module, infos)
}
}