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

@@ -20,8 +20,7 @@ impl AutomorphismKeyCompressed<Vec<u8>> {
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes + SvpPPolAllocBytes,
{
assert_eq!(module.n() as u32, infos.n());
GLWESwitchingKeyCompressed::encrypt_sk_scratch_space(module, infos)
+ GLWESecret::alloc_bytes_with(infos.n(), infos.rank_out())
GLWESwitchingKeyCompressed::encrypt_sk_scratch_space(module, infos) + GLWESecret::bytes_of(infos.n(), infos.rank_out())
}
}

View File

@@ -12,12 +12,12 @@ use crate::{
encryption::{SIGMA, glwe_ct::GLWEEncryptSkInternal},
layouts::{
GGLWE, GGLWEInfos, LWEInfos,
compressed::{GGLWECiphertextCompressed, GGLWECiphertextCompressedToMut},
compressed::{GGLWECompressed, GGLWECompressedToMut},
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
impl<D: DataMut> GGLWECiphertextCompressed<D> {
impl<D: DataMut> GGLWECompressed<D> {
#[allow(clippy::too_many_arguments)]
pub fn encrypt_sk<DataPt: DataRef, DataSk: DataRef, B: Backend>(
&mut self,
@@ -34,7 +34,7 @@ impl<D: DataMut> GGLWECiphertextCompressed<D> {
}
}
impl GGLWECiphertextCompressed<Vec<u8>> {
impl GGLWECompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGLWEInfos,
@@ -54,7 +54,7 @@ pub trait GGLWECompressedEncryptSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGLWECiphertextCompressedToMut,
R: GGLWECompressedToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>;
}
@@ -78,11 +78,11 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGLWECiphertextCompressedToMut,
R: GGLWECompressedToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>,
{
let res: &mut GGLWECiphertextCompressed<&mut [u8]> = &mut res.to_mut();
let res: &mut GGLWECompressed<&mut [u8]> = &mut res.to_mut();
let pt: &ScalarZnx<&[u8]> = &pt.to_ref();
#[cfg(debug_assertions)]
@@ -107,10 +107,10 @@ where
assert_eq!(res.n(), sk.n());
assert_eq!(pt.n() as u32, sk.n());
assert!(
scratch.available() >= GGLWECiphertextCompressed::encrypt_sk_scratch_space(self, res),
scratch.available() >= GGLWECompressed::encrypt_sk_scratch_space(self, res),
"scratch.available: {} < GGLWECiphertext::encrypt_sk_scratch_space: {}",
scratch.available(),
GGLWECiphertextCompressed::encrypt_sk_scratch_space(self, res)
GGLWECompressed::encrypt_sk_scratch_space(self, res)
);
assert!(
res.dnum().0 * res.dsize().0 * res.base2k().0 <= res.k().0,

View File

@@ -23,9 +23,9 @@ impl GLWESwitchingKeyCompressed<Vec<u8>> {
A: GGLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes + SvpPPolAllocBytes,
{
(GGLWE::encrypt_sk_scratch_space(module, infos) | ScalarZnx::alloc_bytes(module.n(), 1))
+ ScalarZnx::alloc_bytes(module.n(), infos.rank_in().into())
+ GLWESecretPrepared::alloc_bytes(module, infos.rank_out())
(GGLWE::encrypt_sk_scratch_space(module, infos) | ScalarZnx::bytes_of(module.n(), 1))
+ ScalarZnx::bytes_of(module.n(), infos.rank_in().into())
+ GLWESecretPrepared::bytes_of(module, infos.rank_out())
}
}

View File

@@ -9,12 +9,12 @@ use crate::{
encryption::{SIGMA, glwe_ct::GLWEEncryptSkInternal},
layouts::{
GGSW, GGSWInfos, GLWEInfos, LWEInfos,
compressed::{GGSWCiphertextCompressed, GGSWCiphertextCompressedToMut},
compressed::{GGSWCompressed, GGSWCompressedToMut},
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
impl GGSWCiphertextCompressed<Vec<u8>> {
impl GGSWCompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GGSWInfos,
@@ -34,7 +34,7 @@ pub trait GGSWCompressedEncryptSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGSWCiphertextCompressedToMut,
R: GGSWCompressedToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>;
}
@@ -53,11 +53,11 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGSWCiphertextCompressedToMut,
R: GGSWCompressedToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>,
{
let res: &mut GGSWCiphertextCompressed<&mut [u8]> = &mut res.to_mut();
let res: &mut GGSWCompressed<&mut [u8]> = &mut res.to_mut();
let sk: &GLWESecretPrepared<&[u8], B> = &sk.to_ref();
let pt: &ScalarZnx<&[u8]> = &pt.to_ref();
@@ -113,7 +113,7 @@ where
}
}
impl<DataSelf: DataMut> GGSWCiphertextCompressed<DataSelf> {
impl<DataSelf: DataMut> GGSWCompressed<DataSelf> {
#[allow(clippy::too_many_arguments)]
pub fn encrypt_sk<DataPt: DataRef, DataSk: DataRef, B: Backend>(
&mut self,

View File

@@ -7,19 +7,19 @@ use poulpy_hal::{
use crate::{
encryption::{SIGMA, glwe_ct::GLWEEncryptSkInternal},
layouts::{
GLWECiphertext, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, LWEInfos,
compressed::{GLWECiphertextCompressed, GLWECiphertextCompressedToMut},
GLWE, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, LWEInfos,
compressed::{GLWECompressed, GLWECompressedToMut},
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
impl GLWECiphertextCompressed<Vec<u8>> {
impl GLWECompressed<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes,
{
GLWECiphertext::encrypt_sk_scratch_space(module, infos)
GLWE::encrypt_sk_scratch_space(module, infos)
}
}
@@ -33,7 +33,7 @@ pub trait GLWECompressedEncryptSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextCompressedToMut,
R: GLWECompressedToMut,
P: GLWEPlaintextToRef,
S: GLWESecretPreparedToRef<B>;
}
@@ -51,11 +51,11 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextCompressedToMut,
R: GLWECompressedToMut,
P: GLWEPlaintextToRef,
S: GLWESecretPreparedToRef<B>,
{
let res: &mut GLWECiphertextCompressed<&mut [u8]> = &mut res.to_mut();
let res: &mut GLWECompressed<&mut [u8]> = &mut res.to_mut();
let mut source_xa: Source = Source::new(seed_xa);
let cols: usize = (res.rank() + 1).into();
@@ -77,7 +77,7 @@ where
}
}
impl<D: DataMut> GLWECiphertextCompressed<D> {
impl<D: DataMut> GLWECompressed<D> {
#[allow(clippy::too_many_arguments)]
pub fn encrypt_sk<DataPt: DataRef, DataSk: DataRef, B: Backend>(
&mut self,

View File

@@ -27,7 +27,7 @@ impl AutomorphismKey<Vec<u8>> {
infos.rank_out(),
"rank_in != rank_out is not supported for GGLWEAutomorphismKey"
);
GLWESwitchingKey::encrypt_sk_scratch_space(module, infos) + GLWESecret::alloc_bytes(&infos.glwe_layout())
GLWESwitchingKey::encrypt_sk_scratch_space(module, infos) + GLWESecret::bytes_of(&infos.glwe_layout())
}
pub fn encrypt_pk_scratch_space<BE: Backend, A>(module: &Module<BE>, _infos: &A) -> usize

View File

@@ -11,7 +11,7 @@ use crate::{
TakeGLWEPt,
encryption::glwe_ct::GLWEEncryptSk,
layouts::{
GGLWE, GGLWECiphertextToMut, GGLWEInfos, GLWECiphertext, GLWEPlaintext, LWEInfos,
GGLWE, GGLWEInfos, GGLWEToMut, GLWE, GLWEPlaintext, LWEInfos,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -22,8 +22,8 @@ impl GGLWE<Vec<u8>> {
A: GGLWEInfos,
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes,
{
GLWECiphertext::encrypt_sk_scratch_space(module, &infos.glwe_layout())
+ (GLWEPlaintext::alloc_bytes(&infos.glwe_layout()) | module.vec_znx_normalize_tmp_bytes())
GLWE::encrypt_sk_scratch_space(module, &infos.glwe_layout())
+ (GLWEPlaintext::bytes_of(&infos.glwe_layout()) | module.vec_znx_normalize_tmp_bytes())
}
pub fn encrypt_pk_scratch_space<B: Backend, A>(_module: &Module<B>, _infos: &A) -> usize
@@ -44,7 +44,7 @@ pub trait GGLWEEncryptSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGLWECiphertextToMut,
R: GGLWEToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>;
}
@@ -64,7 +64,7 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GGLWECiphertextToMut,
R: GGLWEToMut,
P: ScalarZnxToRef,
S: GLWESecretPreparedToRef<B>,
{

View File

@@ -20,9 +20,9 @@ impl GLWESwitchingKey<Vec<u8>> {
A: GGLWEInfos,
Module<B>: SvpPPolAllocBytes + VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes,
{
(GGLWE::encrypt_sk_scratch_space(module, infos) | ScalarZnx::alloc_bytes(module.n(), 1))
+ ScalarZnx::alloc_bytes(module.n(), infos.rank_in().into())
+ GLWESecretPrepared::alloc_bytes_from_infos(module, &infos.glwe_layout())
(GGLWE::encrypt_sk_scratch_space(module, infos) | ScalarZnx::bytes_of(module.n(), 1))
+ ScalarZnx::bytes_of(module.n(), infos.rank_in().into())
+ GLWESecretPrepared::bytes_of_from_infos(module, &infos.glwe_layout())
}
pub fn encrypt_pk_scratch_space<B: Backend, A>(module: &Module<B>, _infos: &A) -> usize

View File

@@ -23,11 +23,11 @@ impl TensorKey<Vec<u8>> {
Module<B>:
SvpPPolAllocBytes + VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes + VecZnxBigAllocBytes,
{
GLWESecretPrepared::alloc_bytes(module, infos.rank_out())
+ module.vec_znx_dft_alloc_bytes(infos.rank_out().into(), 1)
+ module.vec_znx_big_alloc_bytes(1, 1)
+ module.vec_znx_dft_alloc_bytes(1, 1)
+ GLWESecret::alloc_bytes_with(Degree(module.n() as u32), Rank(1))
GLWESecretPrepared::bytes_of(module, infos.rank_out())
+ module.vec_znx_dft_bytes_of(infos.rank_out().into(), 1)
+ module.vec_znx_big_bytes_of(1, 1)
+ module.vec_znx_dft_bytes_of(1, 1)
+ GLWESecret::bytes_of(Degree(module.n() as u32), Rank(1))
+ GLWESwitchingKey::encrypt_sk_scratch_space(module, infos)
}
}

View File

@@ -8,7 +8,7 @@ use crate::{
SIGMA, TakeGLWEPt,
encryption::glwe_ct::GLWEEncryptSkInternal,
layouts::{
GGSW, GGSWInfos, GGSWToMut, GLWECiphertext, GLWEInfos, LWEInfos,
GGSW, GGSWInfos, GGSWToMut, GLWE, GLWEInfos, LWEInfos,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -20,10 +20,10 @@ impl GGSW<Vec<u8>> {
Module<B>: VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes,
{
let size = infos.size();
GLWECiphertext::encrypt_sk_scratch_space(module, &infos.glwe_layout())
+ VecZnx::alloc_bytes(module.n(), (infos.rank() + 1).into(), size)
+ VecZnx::alloc_bytes(module.n(), 1, size)
+ module.vec_znx_dft_alloc_bytes((infos.rank() + 1).into(), size)
GLWE::encrypt_sk_scratch_space(module, &infos.glwe_layout())
+ VecZnx::bytes_of(module.n(), (infos.rank() + 1).into(), size)
+ VecZnx::bytes_of(module.n(), 1, size)
+ module.vec_znx_dft_bytes_of((infos.rank() + 1).into(), size)
}
}

View File

@@ -13,12 +13,12 @@ use crate::{
dist::Distribution,
encryption::{SIGMA, SIGMA_BOUND},
layouts::{
GLWECiphertext, GLWECiphertextToMut, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, LWEInfos,
GLWE, GLWEInfos, GLWEPlaintext, GLWEPlaintextToRef, GLWEToMut, LWEInfos,
prepared::{GLWEPublicKeyPrepared, GLWEPublicKeyPreparedToRef, GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
impl GLWECiphertext<Vec<u8>> {
impl GLWE<Vec<u8>> {
pub fn encrypt_sk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
A: GLWEInfos,
@@ -26,9 +26,7 @@ impl GLWECiphertext<Vec<u8>> {
{
let size: usize = infos.size();
assert_eq!(module.n() as u32, infos.n());
module.vec_znx_normalize_tmp_bytes()
+ 2 * VecZnx::alloc_bytes(module.n(), 1, size)
+ module.vec_znx_dft_alloc_bytes(1, size)
module.vec_znx_normalize_tmp_bytes() + 2 * VecZnx::bytes_of(module.n(), 1, size) + module.vec_znx_dft_bytes_of(1, size)
}
pub fn encrypt_pk_scratch_space<B: Backend, A>(module: &Module<B>, infos: &A) -> usize
where
@@ -37,14 +35,13 @@ impl GLWECiphertext<Vec<u8>> {
{
let size: usize = infos.size();
assert_eq!(module.n() as u32, infos.n());
((module.vec_znx_dft_alloc_bytes(1, size) + module.vec_znx_big_alloc_bytes(1, size))
| ScalarZnx::alloc_bytes(module.n(), 1))
+ module.svp_ppol_alloc_bytes(1)
((module.vec_znx_dft_bytes_of(1, size) + module.vec_znx_big_bytes_of(1, size)) | ScalarZnx::bytes_of(module.n(), 1))
+ module.svp_ppol_bytes_of(1)
+ module.vec_znx_normalize_tmp_bytes()
}
}
impl<D: DataMut> GLWECiphertext<D> {
impl<D: DataMut> GLWE<D> {
pub fn encrypt_sk<R, P, S, B: Backend>(
&mut self,
module: &Module<B>,
@@ -116,7 +113,7 @@ pub trait GLWEEncryptSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
S: GLWESecretPreparedToRef<B>;
}
@@ -135,11 +132,11 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
S: GLWESecretPreparedToRef<B>,
{
let mut res: GLWECiphertext<&mut [u8]> = res.to_mut();
let mut res: GLWE<&mut [u8]> = res.to_mut();
let pt: GLWEPlaintext<&[u8]> = pt.to_ref();
#[cfg(debug_assertions)]
@@ -150,10 +147,10 @@ where
assert_eq!(sk.n(), self.n() as u32);
assert_eq!(pt.n(), self.n() as u32);
assert!(
scratch.available() >= GLWECiphertext::encrypt_sk_scratch_space(self, &res),
scratch.available() >= GLWE::encrypt_sk_scratch_space(self, &res),
"scratch.available(): {} < GLWECiphertext::encrypt_sk_scratch_space: {}",
scratch.available(),
GLWECiphertext::encrypt_sk_scratch_space(self, &res)
GLWE::encrypt_sk_scratch_space(self, &res)
)
}
@@ -183,7 +180,7 @@ pub trait GLWEEncryptZeroSk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
S: GLWESecretPreparedToRef<B>;
}
@@ -200,10 +197,10 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
S: GLWESecretPreparedToRef<B>,
{
let mut res: GLWECiphertext<&mut [u8]> = res.to_mut();
let mut res: GLWE<&mut [u8]> = res.to_mut();
#[cfg(debug_assertions)]
{
@@ -212,10 +209,10 @@ where
assert_eq!(res.n(), self.n() as u32);
assert_eq!(sk.n(), self.n() as u32);
assert!(
scratch.available() >= GLWECiphertext::encrypt_sk_scratch_space(self, &res),
scratch.available() >= GLWE::encrypt_sk_scratch_space(self, &res),
"scratch.available(): {} < GLWECiphertext::encrypt_sk_scratch_space: {}",
scratch.available(),
GLWECiphertext::encrypt_sk_scratch_space(self, &res)
GLWE::encrypt_sk_scratch_space(self, &res)
)
}
@@ -246,7 +243,7 @@ pub trait GLWEEncryptPk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
K: GLWEPublicKeyPreparedToRef<B>;
}
@@ -264,7 +261,7 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
K: GLWEPublicKeyPreparedToRef<B>,
{
@@ -281,7 +278,7 @@ pub trait GLWEEncryptZeroPk<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
K: GLWEPublicKeyPreparedToRef<B>;
}
@@ -297,7 +294,7 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
K: GLWEPublicKeyPreparedToRef<B>,
{
self.glwe_encrypt_pk_internal(
@@ -321,7 +318,7 @@ pub(crate) trait GLWEEncryptPkInternal<B: Backend> {
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
K: GLWEPublicKeyPreparedToRef<B>;
}
@@ -345,11 +342,11 @@ where
source_xe: &mut Source,
scratch: &mut Scratch<B>,
) where
R: GLWECiphertextToMut,
R: GLWEToMut,
P: GLWEPlaintextToRef,
K: GLWEPublicKeyPreparedToRef<B>,
{
let res: &mut GLWECiphertext<&mut [u8]> = &mut res.to_mut();
let res: &mut GLWE<&mut [u8]> = &mut res.to_mut();
let pk: &GLWEPublicKeyPrepared<&[u8], B> = &pk.to_ref();
#[cfg(debug_assertions)]

View File

@@ -7,7 +7,7 @@ use poulpy_hal::{
use crate::{
encryption::glwe_ct::GLWEEncryptZeroSk,
layouts::{
GLWECiphertext, GLWEPublicKey, GLWEPublicKeyToMut,
GLWE, GLWEPublicKey, GLWEPublicKeyToMut,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -45,9 +45,9 @@ where
}
// Its ok to allocate scratch space here since pk is usually generated only once.
let mut scratch: ScratchOwned<B> = ScratchOwned::alloc(GLWECiphertext::encrypt_sk_scratch_space(self, res));
let mut scratch: ScratchOwned<B> = ScratchOwned::alloc(GLWE::encrypt_sk_scratch_space(self, res));
let mut tmp: GLWECiphertext<Vec<u8>> = GLWECiphertext::alloc(res);
let mut tmp: GLWE<Vec<u8>> = GLWE::alloc_from_infos(res);
tmp.encrypt_zero_sk(self, sk, source_xa, source_xe, scratch.borrow());
res.dist = sk.dist;

View File

@@ -22,9 +22,8 @@ impl GLWEToLWESwitchingKey<Vec<u8>> {
A: GGLWEInfos,
Module<B>: SvpPPolAllocBytes + VecZnxNormalizeTmpBytes + VecZnxDftAllocBytes + VecZnxNormalizeTmpBytes,
{
GLWESecretPrepared::alloc_bytes(module, infos.rank_in())
+ (GLWESwitchingKey::encrypt_sk_scratch_space(module, infos)
| GLWESecret::alloc_bytes_with(infos.n(), infos.rank_in()))
GLWESecretPrepared::bytes_of(module, infos.rank_in())
+ (GLWESwitchingKey::encrypt_sk_scratch_space(module, infos) | GLWESecret::bytes_of(infos.n(), infos.rank_in()))
}
}

View File

@@ -7,10 +7,10 @@ use poulpy_hal::{
use crate::{
encryption::{SIGMA, SIGMA_BOUND},
layouts::{LWECiphertext, LWEInfos, LWEPlaintext, LWESecret},
layouts::{LWE, LWEInfos, LWEPlaintext, LWESecret},
};
impl<DataSelf: DataMut> LWECiphertext<DataSelf> {
impl<DataSelf: DataMut> LWE<DataSelf> {
pub fn encrypt_sk<DataPt, DataSk, B>(
&mut self,
module: &Module<B>,

View File

@@ -38,8 +38,8 @@ impl LWESwitchingKey<Vec<u8>> {
1,
"rank_out > 1 is not supported for LWESwitchingKey"
);
GLWESecret::alloc_bytes_with(Degree(module.n() as u32), Rank(1))
+ GLWESecretPrepared::alloc_bytes(module, Rank(1))
GLWESecret::bytes_of(Degree(module.n() as u32), Rank(1))
+ GLWESecretPrepared::bytes_of(module, Rank(1))
+ GLWESwitchingKey::encrypt_sk_scratch_space(module, infos)
}
}

View File

@@ -26,7 +26,7 @@ impl LWEToGLWESwitchingKey<Vec<u8>> {
"rank_in != 1 is not supported for LWEToGLWESwitchingKey"
);
GLWESwitchingKey::encrypt_sk_scratch_space(module, infos)
+ GLWESecret::alloc_bytes_with(Degree(module.n() as u32), infos.rank_in())
+ GLWESecret::bytes_of(Degree(module.n() as u32), infos.rank_in())
}
}