This commit is contained in:
Pro7ech
2025-10-15 10:48:14 +02:00
parent a5df85170d
commit 008b800c01
74 changed files with 890 additions and 871 deletions

View File

@@ -145,32 +145,32 @@ where
impl<B: Backend> AutomorphismKeyPreparedAlloc<B> for Module<B> where Module<B>: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> AutomorphismKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
Module<B>: AutomorphismKeyPreparedAlloc<B>,
M: AutomorphismKeyPreparedAlloc<B>,
{
module.alloc_automorphism_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> Self
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> Self
where
Module<B>: AutomorphismKeyPreparedAlloc<B>,
M: AutomorphismKeyPreparedAlloc<B>,
{
module.alloc_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
Module<B>: AutomorphismKeyPreparedAlloc<B>,
M: AutomorphismKeyPreparedAlloc<B>,
{
module.bytes_of_automorphism_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
where
Module<B>: AutomorphismKeyPreparedAlloc<B>,
M: AutomorphismKeyPreparedAlloc<B>,
{
module.bytes_of_automorphism_key_prepared(base2k, k, rank, dnum, dsize)
}
@@ -200,19 +200,19 @@ where
impl<B: Backend> PrepareAutomorphismKey<B> for Module<B> where Module<B>: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> AutomorphismKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes(&self, module: &Module<B>) -> usize
pub fn prepare_tmp_bytes<M>(&self, module: &M) -> usize
where
Module<B>: GLWESwitchingKeyPrepare<B>,
M: PrepareAutomorphismKey<B>,
{
module.prepare_automorphism_key_tmp_bytes(self)
}
}
impl<D: DataMut, B: Backend> AutomorphismKeyPrepared<D, B> {
pub fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: AutomorphismKeyToRef + GetAutomorphismGaloisElement,
Module<B>: PrepareAutomorphismKey<B>,
M: PrepareAutomorphismKey<B>,
{
module.prepare_automorphism_key(self, other, scratch);
}

View File

@@ -151,45 +151,50 @@ where
impl<B: Backend> GGLWEPreparedAlloc<B> for Module<B> where Module<B>: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {}
impl<B: Backend> GGLWEPrepared<Vec<u8>, B>
where
Module<B>: GGLWEPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GGLWEPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: GGLWEPreparedAlloc<B>,
{
module.alloc_gglwe_prepared_from_infos(infos)
}
pub fn alloc(
module: &Module<B>,
pub fn alloc<M>(
module: &M,
base2k: Base2K,
k: TorusPrecision,
rank_in: Rank,
rank_out: Rank,
dnum: Dnum,
dsize: Dsize,
) -> Self {
) -> Self
where
M: GGLWEPreparedAlloc<B>,
{
module.alloc_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: GGLWEPreparedAlloc<B>,
{
module.bytes_of_gglwe_prepared_from_infos(infos)
}
pub fn bytes_of(
module: &Module<B>,
pub fn bytes_of<M>(
module: &M,
base2k: Base2K,
k: TorusPrecision,
rank_in: Rank,
rank_out: Rank,
dnum: Dnum,
dsize: Dsize,
) -> usize {
) -> usize
where
M: GGLWEPreparedAlloc<B>,
{
module.bytes_of_gglwe_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
}
@@ -230,22 +235,20 @@ where
impl<B: Backend> GGLWEPrepare<B> for Module<B> where Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B> {}
impl<D: DataMut, B: Backend> GGLWEPrepared<D, B>
where
Module<B>: GGLWEPrepare<B>,
{
pub fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
impl<D: DataMut, B: Backend> GGLWEPrepared<D, B> {
pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: GGLWEToRef,
M: GGLWEPrepare<B>,
{
module.prepare_gglwe(self, other, scratch);
}
}
impl<B: Backend> GGLWEPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes(&self, module: &Module<B>) -> usize
pub fn prepare_tmp_bytes<M>(&self, module: &M) -> usize
where
Module<B>: GGLWEPrepare<B>,
M: GGLWEPrepare<B>,
{
module.prepare_gglwe_tmp_bytes(self)
}

View File

@@ -136,47 +136,52 @@ where
}
}
impl<B: Backend> GLWESwitchingKeyPreparedAlloc<B> for Module<B> where Module<B>: GGLWEPreparedAlloc<B> {}
impl<B: Backend> GLWESwitchingKeyPreparedAlloc<B> for Module<B> where Self: GGLWEPreparedAlloc<B> {}
impl<B: Backend> GLWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: GLWESwitchingKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GLWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: GLWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_glwe_switching_key_prepared_from_infos(infos)
}
pub fn alloc(
module: &Module<B>,
pub fn alloc<M>(
module: &M,
base2k: Base2K,
k: TorusPrecision,
rank_in: Rank,
rank_out: Rank,
dnum: Dnum,
dsize: Dsize,
) -> Self {
) -> Self
where
M: GLWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_glwe_switching_key_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: GLWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_switching_key_prepared_from_infos(infos)
}
pub fn bytes_of(
module: &Module<B>,
pub fn bytes_of<M>(
module: &M,
base2k: Base2K,
k: TorusPrecision,
rank_in: Rank,
rank_out: Rank,
dnum: Dnum,
dsize: Dsize,
) -> usize {
) -> usize
where
M: GLWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_switching_key_prepared(base2k, k, rank_in, rank_out, dnum, dsize)
}
}
@@ -206,21 +211,21 @@ where
impl<B: Backend> GLWESwitchingKeyPrepare<B> for Module<B> where Self: GGLWEPrepare<B> {}
impl<D: DataMut, B: Backend> GLWESwitchingKeyPrepared<D, B> {
pub fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: GLWESwitchingKeyToRef + GLWESwtichingKeyGetMetaData,
Module<B>: GLWESwitchingKeyPrepare<B>,
M: GLWESwitchingKeyPrepare<B>,
{
module.prepare_glwe_switching(self, other, scratch);
}
}
impl<B: Backend> GLWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: GLWESwitchingKeyPrepare<B>,
{
pub fn prepare_tmp_bytes(&self, module: &Module<B>) -> usize {
module.prepare_gglwe_tmp_bytes(self)
impl<B: Backend> GLWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<M>(&self, module: &M) -> usize
where
M: GLWESwitchingKeyPrepare<B>,
{
module.prepare_glwe_switching_key_tmp_bytes(self)
}
}

View File

@@ -114,29 +114,34 @@ where
impl<B: Backend> TensorKeyPreparedAlloc<B> for Module<B> where Module<B>: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> TensorKeyPrepared<Vec<u8>, B>
where
Module<B>: TensorKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> TensorKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: TensorKeyPreparedAlloc<B>,
{
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 {
pub fn alloc_with<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> Self
where
M: TensorKeyPreparedAlloc<B>,
{
module.alloc_tensor_key_prepared(base2k, k, dnum, dsize, rank)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: TensorKeyPreparedAlloc<B>,
{
module.bytes_of_tensor_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank, dnum: Dnum, dsize: Dsize) -> usize
where
M: TensorKeyPreparedAlloc<B>,
{
module.bytes_of_tensor_key_prepared(base2k, k, rank, dnum, dsize)
}
}
@@ -190,27 +195,23 @@ where
}
}
impl<B: Backend> TensorKeyPrepare<B> for Module<B> where Module<B>: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> TensorKeyPrepare<B> for Module<B> where Self: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> TensorKeyPrepared<Vec<u8>, B>
where
Module<B>: TensorKeyPrepare<B>,
{
fn prepare_tmp_bytes<A>(&self, module: &Module<B>, infos: &A) -> usize
impl<B: Backend> TensorKeyPrepared<Vec<u8>, B> {
fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: TensorKeyPrepare<B>,
{
module.prepare_tensor_key_tmp_bytes(infos)
}
}
impl<D: DataMut, B: Backend> TensorKeyPrepared<D, B>
where
Module<B>: TensorKeyPrepare<B>,
{
fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
impl<D: DataMut, B: Backend> TensorKeyPrepared<D, B> {
fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: TensorKeyToRef,
M: TensorKeyPrepare<B>,
{
module.prepare_tensor_key(self, other, scratch);
}

View File

@@ -135,31 +135,36 @@ where
}
}
impl<B: Backend> GGSWPreparedAlloc<B> for Module<B> where Module<B>: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {}
impl<B: Backend> GGSWPreparedAlloc<B> for Module<B> where Self: GetDegree + VmpPMatAlloc<B> + VmpPMatBytesOf {}
impl<B: Backend> GGSWPrepared<Vec<u8>, B>
where
Module<B>: GGSWPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GGSWPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGSWInfos,
M: GGSWPreparedAlloc<B>,
{
module.alloc_ggsw_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> Self
where
M: GGSWPreparedAlloc<B>,
{
module.alloc_ggsw_prepared(base2k, k, dnum, dsize, rank)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGSWInfos,
M: GGSWPreparedAlloc<B>,
{
module.bytes_of_ggsw_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum, dsize: Dsize, rank: Rank) -> usize
where
M: GGSWPreparedAlloc<B>,
{
module.bytes_of_ggsw_prepared(base2k, k, dnum, dsize, rank)
}
}
@@ -204,25 +209,21 @@ where
impl<B: Backend> GGSWPrepare<B> for Module<B> where Self: GetDegree + VmpPrepareTmpBytes + VmpPrepare<B> {}
impl<B: Backend> GGSWPrepared<Vec<u8>, B>
where
Module<B>: GGSWPrepare<B>,
{
pub fn prepare_tmp_bytes<A>(&self, module: Module<B>, infos: &A) -> usize
impl<B: Backend> GGSWPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A) -> usize
where
A: GGSWInfos,
M: GGSWPrepare<B>,
{
module.ggsw_prepare_tmp_bytes(infos)
}
}
impl<D: DataMut, B: Backend> GGSWPrepared<D, B>
where
Module<B>: GGSWPrepare<B>,
{
pub fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
impl<D: DataMut, B: Backend> GGSWPrepared<D, B> {
pub fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: GGSWToRef,
M: GGSWPrepare<B>,
{
module.ggsw_prepare(self, other, scratch);
}
@@ -243,11 +244,11 @@ impl<D: DataMut, B: Backend> GGSWPreparedToMut<B> for GGSWPrepared<D, B> {
}
}
pub trait GGSWCiphertextPreparedToRef<B: Backend> {
pub trait GGSWPreparedToRef<B: Backend> {
fn to_ref(&self) -> GGSWPrepared<&[u8], B>;
}
impl<D: DataRef, B: Backend> GGSWCiphertextPreparedToRef<B> for GGSWPrepared<D, B> {
impl<D: DataRef, B: Backend> GGSWPreparedToRef<B> for GGSWPrepared<D, B> {
fn to_ref(&self) -> GGSWPrepared<&[u8], B> {
GGSWPrepared {
base2k: self.base2k,

View File

@@ -84,29 +84,34 @@ where
impl<B: Backend> GLWEPublicKeyPreparedAlloc<B> for Module<B> where Self: VecZnxDftAlloc<B> + VecZnxDftBytesOf {}
impl<B: Backend> GLWEPublicKeyPrepared<Vec<u8>, B>
where
Module<B>: GLWEPublicKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GLWEPublicKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GLWEInfos,
M: GLWEPublicKeyPreparedAlloc<B>,
{
module.alloc_glwe_public_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank) -> Self
where
M: GLWEPublicKeyPreparedAlloc<B>,
{
module.alloc_glwe_public_key_prepared(base2k, k, rank)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GLWEInfos,
M: GLWEPublicKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_public_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank: Rank) -> usize
where
M: GLWEPublicKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_public_key_prepared(base2k, k, rank)
}
}
@@ -141,13 +146,11 @@ where
impl<B: Backend> GLWEPublicKeyPrepare<B> for Module<B> where Self: GetDegree + VecZnxDftApply<B> {}
impl<D: DataMut, B: Backend> GLWEPublicKeyPrepared<D, B>
where
Module<B>: GLWEPublicKeyPrepare<B>,
{
pub fn prepare<O>(&mut self, module: &Module<B>, other: &O)
impl<D: DataMut, B: Backend> GLWEPublicKeyPrepared<D, B> {
pub fn prepare<O, M>(&mut self, module: &M, other: &O)
where
O: GLWEPublicKeyToRef + GetDist,
M: GLWEPublicKeyPrepare<B>,
{
module.prepare_glwe_public_key(self, other);
}

View File

@@ -77,29 +77,34 @@ where
impl<B: Backend> GLWESecretPreparedAlloc<B> for Module<B> where Self: GetDegree + SvpPPolBytesOf + SvpPPolAlloc<B> {}
impl<B: Backend> GLWESecretPrepared<Vec<u8>, B>
where
Module<B>: GLWESecretPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GLWESecretPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GLWEInfos,
M: GLWESecretPreparedAlloc<B>,
{
module.alloc_glwe_secret_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, rank: Rank) -> Self {
pub fn alloc<M>(module: &M, rank: Rank) -> Self
where
M: GLWESecretPreparedAlloc<B>,
{
module.alloc_glwe_secret_prepared(rank)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GLWEInfos,
M: GLWESecretPreparedAlloc<B>,
{
module.bytes_of_glwe_secret_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, rank: Rank) -> usize {
pub fn bytes_of<M>(module: &M, rank: Rank) -> usize
where
M: GLWESecretPreparedAlloc<B>,
{
module.bytes_of_glwe_secret(rank)
}
}
@@ -138,6 +143,16 @@ where
impl<B: Backend> GLWESecretPrepare<B> for Module<B> where Self: SvpPrepare<B> {}
impl<D: DataMut, B: Backend> GLWESecretPrepared<D, B> {
pub fn prepare<M, O>(&mut self, module: &M, other: &O)
where
M: GLWESecretPrepare<B>,
O: GLWESecretToRef + GetDist,
{
module.prepare_glwe_secret(self, other);
}
}
pub trait GLWESecretPreparedToRef<B: Backend> {
fn to_ref(&self) -> GLWESecretPrepared<&[u8], B>;
}

View File

@@ -105,31 +105,36 @@ where
}
}
impl<B: Backend> GLWEToLWESwitchingKeyPreparedAlloc<B> for Module<B> where Module<B>: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> GLWEToLWESwitchingKeyPreparedAlloc<B> for Module<B> where Self: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> GLWEToLWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: GLWEToLWESwitchingKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> GLWEToLWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: GLWEToLWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_glwe_to_lwe_switching_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> Self
where
M: GLWEToLWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_glwe_to_lwe_switching_key_prepared(base2k, k, rank_in, dnum)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: GLWEToLWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_to_lwe_switching_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank_in: Rank, dnum: Dnum) -> usize
where
M: GLWEToLWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_glwe_to_lwe_switching_key_prepared(base2k, k, rank_in, dnum)
}
}
@@ -157,20 +162,20 @@ where
impl<B: Backend> GLWEToLWESwitchingKeyPrepare<B> for Module<B> where Self: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> GLWEToLWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A>(&self, module: &Module<B>, infos: &A)
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A)
where
A: GGLWEInfos,
Module<B>: GLWEToLWESwitchingKeyPrepare<B>,
M: GLWEToLWESwitchingKeyPrepare<B>,
{
module.prepare_glwe_to_lwe_switching_key_tmp_bytes(infos);
}
}
impl<D: DataMut, B: Backend> GLWEToLWESwitchingKeyPrepared<D, B> {
fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: GLWEToLWESwitchingKeyToRef,
Module<B>: GLWEToLWESwitchingKeyPrepare<B>,
M: GLWEToLWESwitchingKeyPrepare<B>,
{
module.prepare_glwe_to_lwe_switching_key(self, other, scratch);
}

View File

@@ -116,29 +116,34 @@ where
impl<B: Backend> LWESwitchingKeyPreparedAlloc<B> for Module<B> where Self: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: LWESwitchingKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_lwe_switching_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> Self
where
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_lwe_switching_key_prepared(base2k, k, dnum)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_lwe_switching_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, dnum: Dnum) -> usize
where
M: LWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_lwe_switching_key_prepared(base2k, k, dnum)
}
}
@@ -165,20 +170,20 @@ where
impl<B: Backend> LWESwitchingKeyPrepare<B> for Module<B> where Self: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> LWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A>(&self, module: &Module<B>, infos: &A)
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A)
where
A: GGLWEInfos,
Module<B>: LWESwitchingKeyPrepare<B>,
M: LWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_switching_key_tmp_bytes(infos);
}
}
impl<D: DataMut, B: Backend> LWESwitchingKeyPrepared<D, B> {
fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: LWESwitchingKeyToRef,
Module<B>: LWESwitchingKeyPrepare<B>,
M: LWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_switching_key(self, other, scratch);
}

View File

@@ -114,29 +114,28 @@ where
impl<B: Backend> LWEToGLWESwitchingKeyPreparedAlloc<B> for Module<B> where Self: GLWESwitchingKeyPreparedAlloc<B> {}
impl<B: Backend> LWEToGLWESwitchingKeyPrepared<Vec<u8>, B>
where
Module<B>: LWEToGLWESwitchingKeyPreparedAlloc<B>,
{
pub fn alloc_from_infos<A>(module: &Module<B>, infos: &A) -> Self
impl<B: Backend> LWEToGLWESwitchingKeyPrepared<Vec<u8>, B>{
pub fn alloc_from_infos<A, M>(module: &M, infos: &A) -> Self
where
A: GGLWEInfos,
M: LWEToGLWESwitchingKeyPreparedAlloc<B>,
{
module.alloc_lwe_to_glwe_switching_key_prepared_from_infos(infos)
}
pub fn alloc(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> Self {
pub fn alloc<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> Self where M: LWEToGLWESwitchingKeyPreparedAlloc<B>, {
module.alloc_lwe_to_glwe_switching_key_prepared(base2k, k, rank_out, dnum)
}
pub fn bytes_of_from_infos<A>(module: &Module<B>, infos: &A) -> usize
pub fn bytes_of_from_infos<A, M>(module: &M, infos: &A) -> usize
where
A: GGLWEInfos,
M: LWEToGLWESwitchingKeyPreparedAlloc<B>,
{
module.bytes_of_lwe_to_glwe_switching_key_prepared_from_infos(infos)
}
pub fn bytes_of(module: &Module<B>, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> usize {
pub fn bytes_of<M>(module: &M, base2k: Base2K, k: TorusPrecision, rank_out: Rank, dnum: Dnum) -> usize where M: LWEToGLWESwitchingKeyPreparedAlloc<B>,{
module.bytes_of_lwe_to_glwe_switching_key_prepared(base2k, k, rank_out, dnum)
}
}
@@ -164,20 +163,20 @@ where
impl<B: Backend> LWEToGLWESwitchingKeyPrepare<B> for Module<B> where Self: GLWESwitchingKeyPrepare<B> {}
impl<B: Backend> LWEToGLWESwitchingKeyPrepared<Vec<u8>, B> {
pub fn prepare_tmp_bytes<A>(&self, module: &Module<B>, infos: &A)
pub fn prepare_tmp_bytes<A, M>(&self, module: &M, infos: &A)
where
A: GGLWEInfos,
Module<B>: LWEToGLWESwitchingKeyPrepare<B>,
M: LWEToGLWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_to_glwe_switching_key_tmp_bytes(infos);
}
}
impl<D: DataMut, B: Backend> LWEToGLWESwitchingKeyPrepared<D, B> {
fn prepare<O>(&mut self, module: &Module<B>, other: &O, scratch: &mut Scratch<B>)
fn prepare<O, M>(&mut self, module: &M, other: &O, scratch: &mut Scratch<B>)
where
O: LWEToGLWESwitchingKeyToRef,
Module<B>: LWEToGLWESwitchingKeyPrepare<B>,
M: LWEToGLWESwitchingKeyPrepare<B>,
{
module.prepare_lwe_to_glwe_switching_key(self, other, scratch);
}