mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
wip
This commit is contained in:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user