mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 21:26:41 +01:00
wip
This commit is contained in:
@@ -7,9 +7,9 @@ use poulpy_hal::{
|
||||
layouts::{Backend, DataMut, DataRef, Module, Scratch},
|
||||
};
|
||||
|
||||
use crate::layouts::{GGLWEAutomorphismKey, GGLWEInfos, GGLWESwitchingKey, GGSWInfos, prepared::GGSWCiphertextPrepared};
|
||||
use crate::layouts::{AutomorphismKey, GGLWEInfos, GGSWInfos, GLWESwitchingKey, prepared::GGSWPrepared};
|
||||
|
||||
impl GGLWEAutomorphismKey<Vec<u8>> {
|
||||
impl AutomorphismKey<Vec<u8>> {
|
||||
pub fn external_product_scratch_space<B: Backend, OUT, IN, GGSW>(
|
||||
module: &Module<B>,
|
||||
out_infos: &OUT,
|
||||
@@ -22,7 +22,7 @@ impl GGLWEAutomorphismKey<Vec<u8>> {
|
||||
GGSW: GGSWInfos,
|
||||
Module<B>: VecZnxDftAllocBytes + VmpApplyDftToDftTmpBytes + VecZnxNormalizeTmpBytes,
|
||||
{
|
||||
GGLWESwitchingKey::external_product_scratch_space(module, out_infos, in_infos, ggsw_infos)
|
||||
GLWESwitchingKey::external_product_scratch_space(module, out_infos, in_infos, ggsw_infos)
|
||||
}
|
||||
|
||||
pub fn external_product_inplace_scratch_space<B: Backend, OUT, GGSW>(
|
||||
@@ -35,16 +35,16 @@ impl GGLWEAutomorphismKey<Vec<u8>> {
|
||||
GGSW: GGSWInfos,
|
||||
Module<B>: VecZnxDftAllocBytes + VmpApplyDftToDftTmpBytes + VecZnxNormalizeTmpBytes,
|
||||
{
|
||||
GGLWESwitchingKey::external_product_inplace_scratch_space(module, out_infos, ggsw_infos)
|
||||
GLWESwitchingKey::external_product_inplace_scratch_space(module, out_infos, ggsw_infos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<DataSelf: DataMut> GGLWEAutomorphismKey<DataSelf> {
|
||||
impl<DataSelf: DataMut> AutomorphismKey<DataSelf> {
|
||||
pub fn external_product<DataLhs: DataRef, DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
lhs: &GGLWEAutomorphismKey<DataLhs>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
lhs: &AutomorphismKey<DataLhs>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
@@ -64,7 +64,7 @@ impl<DataSelf: DataMut> GGLWEAutomorphismKey<DataSelf> {
|
||||
pub fn external_product_inplace<DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
|
||||
@@ -7,9 +7,9 @@ use poulpy_hal::{
|
||||
layouts::{Backend, DataMut, DataRef, Module, Scratch, ZnxZero},
|
||||
};
|
||||
|
||||
use crate::layouts::{GGLWEInfos, GGLWESwitchingKey, GGSWInfos, GLWECiphertext, prepared::GGSWCiphertextPrepared};
|
||||
use crate::layouts::{GGLWEInfos, GGSWInfos, GLWECiphertext, GLWESwitchingKey, prepared::GGSWPrepared};
|
||||
|
||||
impl GGLWESwitchingKey<Vec<u8>> {
|
||||
impl GLWESwitchingKey<Vec<u8>> {
|
||||
pub fn external_product_scratch_space<B: Backend, OUT, IN, GGSW>(
|
||||
module: &Module<B>,
|
||||
out_infos: &OUT,
|
||||
@@ -44,12 +44,12 @@ impl GGLWESwitchingKey<Vec<u8>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<DataSelf: DataMut> GGLWESwitchingKey<DataSelf> {
|
||||
impl<DataSelf: DataMut> GLWESwitchingKey<DataSelf> {
|
||||
pub fn external_product<DataLhs: DataRef, DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
lhs: &GGLWESwitchingKey<DataLhs>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
lhs: &GLWESwitchingKey<DataLhs>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
@@ -107,7 +107,7 @@ impl<DataSelf: DataMut> GGLWESwitchingKey<DataSelf> {
|
||||
pub fn external_product_inplace<DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
|
||||
@@ -7,9 +7,9 @@ use poulpy_hal::{
|
||||
layouts::{Backend, DataMut, DataRef, Module, Scratch, ZnxZero},
|
||||
};
|
||||
|
||||
use crate::layouts::{GGSWCiphertext, GGSWInfos, GLWECiphertext, GLWEInfos, prepared::GGSWCiphertextPrepared};
|
||||
use crate::layouts::{GGSW, GGSWInfos, GLWECiphertext, GLWEInfos, prepared::GGSWPrepared};
|
||||
|
||||
impl GGSWCiphertext<Vec<u8>> {
|
||||
impl GGSW<Vec<u8>> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn external_product_scratch_space<B: Backend, OUT, IN, GGSW>(
|
||||
module: &Module<B>,
|
||||
@@ -45,12 +45,12 @@ impl GGSWCiphertext<Vec<u8>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<DataSelf: DataMut> GGSWCiphertext<DataSelf> {
|
||||
impl<DataSelf: DataMut> GGSW<DataSelf> {
|
||||
pub fn external_product<DataLhs: DataRef, DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
lhs: &GGSWCiphertext<DataLhs>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
lhs: &GGSW<DataLhs>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
@@ -86,7 +86,7 @@ impl<DataSelf: DataMut> GGSWCiphertext<DataSelf> {
|
||||
rhs.rank()
|
||||
);
|
||||
|
||||
assert!(scratch.available() >= GGSWCiphertext::external_product_scratch_space(module, self, lhs, rhs))
|
||||
assert!(scratch.available() >= GGSW::external_product_scratch_space(module, self, lhs, rhs))
|
||||
}
|
||||
|
||||
let min_dnum: usize = self.dnum().min(lhs.dnum()).into();
|
||||
@@ -105,7 +105,7 @@ impl<DataSelf: DataMut> GGSWCiphertext<DataSelf> {
|
||||
pub fn external_product_inplace<DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: VecZnxDftAllocBytes
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
GLWEExternalProduct, GLWEExternalProductInplace,
|
||||
layouts::{
|
||||
GGSWInfos, GLWECiphertext, GLWECiphertextToMut, GLWECiphertextToRef, GLWEInfos, LWEInfos,
|
||||
prepared::{GGSWCiphertextPrepared, GGSWCiphertextPreparedToRef},
|
||||
prepared::{GGSWCiphertextPreparedToRef, GGSWPrepared},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ impl<DataSelf: DataMut> GLWECiphertext<DataSelf> {
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
lhs: &GLWECiphertext<DataLhs>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: GLWEExternalProduct<B>,
|
||||
@@ -85,7 +85,7 @@ impl<DataSelf: DataMut> GLWECiphertext<DataSelf> {
|
||||
pub fn external_product_inplace<DataRhs: DataRef, B: Backend>(
|
||||
&mut self,
|
||||
module: &Module<B>,
|
||||
rhs: &GGSWCiphertextPrepared<DataRhs, B>,
|
||||
rhs: &GGSWPrepared<DataRhs, B>,
|
||||
scratch: &mut Scratch<B>,
|
||||
) where
|
||||
Module<B>: GLWEExternalProductInplace<B>,
|
||||
@@ -113,7 +113,7 @@ where
|
||||
D: GGSWCiphertextPreparedToRef<BE>,
|
||||
{
|
||||
let res: &mut GLWECiphertext<&mut [u8]> = &mut res.to_mut();
|
||||
let rhs: &GGSWCiphertextPrepared<&[u8], BE> = &ggsw.to_ref();
|
||||
let rhs: &GGSWPrepared<&[u8], BE> = &ggsw.to_ref();
|
||||
|
||||
let basek_in: usize = res.base2k().into();
|
||||
let basek_ggsw: usize = rhs.base2k().into();
|
||||
@@ -237,7 +237,7 @@ where
|
||||
let res: &mut GLWECiphertext<&mut [u8]> = &mut res.to_mut();
|
||||
let lhs: &GLWECiphertext<&[u8]> = &lhs.to_ref();
|
||||
|
||||
let rhs: &GGSWCiphertextPrepared<&[u8], BE> = &rhs.to_ref();
|
||||
let rhs: &GGSWPrepared<&[u8], BE> = &rhs.to_ref();
|
||||
|
||||
let basek_in: usize = lhs.base2k().into();
|
||||
let basek_ggsw: usize = rhs.base2k().into();
|
||||
|
||||
Reference in New Issue
Block a user