mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
compiling CBT but failing tests
This commit is contained in:
@@ -16,9 +16,9 @@ impl GLWEAutomorphismKeyCompressed<Vec<u8>> {
|
||||
pub fn encrypt_sk_tmp_bytes<M, BE: Backend, A>(module: &M, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
M: AutomorphismKeyCompressedEncryptSk<BE>,
|
||||
M: GLWEAutomorphismKeyCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.automorphism_key_compressed_encrypt_sk_tmp_bytes(infos)
|
||||
module.glwe_automorphism_key_compressed_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,18 +34,18 @@ impl<DataSelf: DataMut> GLWEAutomorphismKeyCompressed<DataSelf> {
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
S: GLWESecretToRef + GLWEInfos,
|
||||
M: AutomorphismKeyCompressedEncryptSk<BE>,
|
||||
M: GLWEAutomorphismKeyCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.automorphism_key_compressed_encrypt_sk(self, p, sk, seed_xa, source_xe, scratch);
|
||||
module.glwe_automorphism_key_compressed_encrypt_sk(self, p, sk, seed_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AutomorphismKeyCompressedEncryptSk<BE: Backend> {
|
||||
fn automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
pub trait GLWEAutomorphismKeyCompressedEncryptSk<BE: Backend> {
|
||||
fn glwe_automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
|
||||
fn automorphism_key_compressed_encrypt_sk<R, S>(
|
||||
fn glwe_automorphism_key_compressed_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
p: i64,
|
||||
@@ -58,12 +58,12 @@ pub trait AutomorphismKeyCompressedEncryptSk<BE: Backend> {
|
||||
S: GLWESecretToRef + GLWEInfos;
|
||||
}
|
||||
|
||||
impl<BE: Backend> AutomorphismKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
impl<BE: Backend> GLWEAutomorphismKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Self: ModuleN + GaloisElement + VecZnxAutomorphism + GGLWECompressedEncryptSk<BE> + GLWESecretPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
fn glwe_automorphism_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
@@ -73,7 +73,7 @@ where
|
||||
+ GLWESecretPrepared::bytes_of_from_infos(self, infos)
|
||||
}
|
||||
|
||||
fn automorphism_key_compressed_encrypt_sk<R, S>(
|
||||
fn glwe_automorphism_key_compressed_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
p: i64,
|
||||
|
||||
@@ -8,10 +8,10 @@ use poulpy_hal::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
GGLWECompressedEncryptSk, GetDistribution, ScratchTakeCore, TensorKeyEncryptSk,
|
||||
GGLWECompressedEncryptSk, GLWETensorKeyEncryptSk, GetDistribution, ScratchTakeCore,
|
||||
layouts::{
|
||||
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepared, GLWESecretPreparedFactory, GLWESecretToRef, LWEInfos, Rank,
|
||||
TensorKeyCompressedAtMut, compressed::GLWETensorKeyCompressed,
|
||||
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretPrepared, GLWESecretPreparedFactory, GLWESecretToRef,
|
||||
GLWETensorKeyCompressedAtMut, LWEInfos, Rank, compressed::GLWETensorKeyCompressed,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -19,9 +19,9 @@ impl GLWETensorKeyCompressed<Vec<u8>> {
|
||||
pub fn encrypt_sk_tmp_bytes<M, A, BE: Backend>(module: &M, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
M: GGLWETensorKeyCompressedEncryptSk<BE>,
|
||||
M: GLWETensorKeyCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.tensor_key_compressed_encrypt_sk_tmp_bytes(infos)
|
||||
module.glwe_tensor_key_compressed_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,18 +35,18 @@ impl<DataSelf: DataMut> GLWETensorKeyCompressed<DataSelf> {
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
S: GLWESecretToRef + GetDistribution,
|
||||
M: GGLWETensorKeyCompressedEncryptSk<BE>,
|
||||
M: GLWETensorKeyCompressedEncryptSk<BE>,
|
||||
{
|
||||
module.tensor_key_compressed_encrypt_sk(self, sk, seed_xa, source_xe, scratch);
|
||||
module.glwe_tensor_key_compressed_encrypt_sk(self, sk, seed_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GGLWETensorKeyCompressedEncryptSk<BE: Backend> {
|
||||
fn tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
pub trait GLWETensorKeyCompressedEncryptSk<BE: Backend> {
|
||||
fn glwe_tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
|
||||
fn tensor_key_compressed_encrypt_sk<R, S, D>(
|
||||
fn glwe_tensor_key_compressed_encrypt_sk<R, S, D>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
sk: &S,
|
||||
@@ -55,15 +55,15 @@ pub trait GGLWETensorKeyCompressedEncryptSk<BE: Backend> {
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
D: DataMut,
|
||||
R: TensorKeyCompressedAtMut<D> + GGLWEInfos,
|
||||
R: GLWETensorKeyCompressedAtMut<D> + GGLWEInfos,
|
||||
S: GLWESecretToRef + GetDistribution;
|
||||
}
|
||||
|
||||
impl<BE: Backend> GGLWETensorKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
impl<BE: Backend> GLWETensorKeyCompressedEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Self: ModuleN
|
||||
+ GGLWECompressedEncryptSk<BE>
|
||||
+ TensorKeyEncryptSk<BE>
|
||||
+ GLWETensorKeyEncryptSk<BE>
|
||||
+ VecZnxDftApply<BE>
|
||||
+ SvpApplyDftToDft<BE>
|
||||
+ VecZnxIdftApplyTmpA<BE>
|
||||
@@ -75,7 +75,7 @@ where
|
||||
+ GLWESecretPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeBasic + ScratchTakeCore<BE>,
|
||||
{
|
||||
fn tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
fn glwe_tensor_key_compressed_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
@@ -87,7 +87,7 @@ where
|
||||
+ self.gglwe_compressed_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
|
||||
fn tensor_key_compressed_encrypt_sk<R, S, D>(
|
||||
fn glwe_tensor_key_compressed_encrypt_sk<R, S, D>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
sk: &S,
|
||||
@@ -96,7 +96,7 @@ where
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
D: DataMut,
|
||||
R: GGLWEInfos + TensorKeyCompressedAtMut<D>,
|
||||
R: GGLWEInfos + GLWETensorKeyCompressedAtMut<D>,
|
||||
S: GLWESecretToRef + GetDistribution,
|
||||
{
|
||||
let (mut sk_dft_prep, scratch_1) = scratch.take_glwe_secret_prepared(self, res.rank());
|
||||
|
||||
@@ -7,30 +7,30 @@ use poulpy_hal::{
|
||||
use crate::{
|
||||
GGLWEEncryptSk, ScratchTakeCore,
|
||||
layouts::{
|
||||
AutomorphismKey, GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWEInfos, GLWESecret, GLWESecretPrepared,
|
||||
GGLWEInfos, GGLWEToMut, GGLWEToRef, GLWEAutomorphismKey, GLWEInfos, GLWESecret, GLWESecretPrepared,
|
||||
GLWESecretPreparedFactory, GLWESecretToRef, LWEInfos, SetGaloisElement,
|
||||
},
|
||||
};
|
||||
|
||||
impl AutomorphismKey<Vec<u8>> {
|
||||
impl GLWEAutomorphismKey<Vec<u8>> {
|
||||
pub fn encrypt_sk_tmp_bytes<M, A, BE: Backend>(module: &M, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
M: AutomorphismKeyEncryptSk<BE>,
|
||||
M: GLWEAutomorphismKeyEncryptSk<BE>,
|
||||
{
|
||||
module.automorphism_key_encrypt_sk_tmp_bytes(infos)
|
||||
module.glwe_automorphism_key_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
|
||||
pub fn encrypt_pk_tmp_bytes<M, A, BE: Backend>(module: &M, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
M: GGLWEAutomorphismKeyEncryptPk<BE>,
|
||||
M: GLWEAutomorphismKeyEncryptPk<BE>,
|
||||
{
|
||||
module.automorphism_key_encrypt_pk_tmp_bytes(infos)
|
||||
module.glwe_automorphism_key_encrypt_pk_tmp_bytes(infos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<DM: DataMut> AutomorphismKey<DM>
|
||||
impl<DM: DataMut> GLWEAutomorphismKey<DM>
|
||||
where
|
||||
Self: GGLWEToRef,
|
||||
{
|
||||
@@ -44,18 +44,18 @@ where
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
S: GLWESecretToRef,
|
||||
M: AutomorphismKeyEncryptSk<BE>,
|
||||
M: GLWEAutomorphismKeyEncryptSk<BE>,
|
||||
{
|
||||
module.automorphism_key_encrypt_sk(self, p, sk, source_xa, source_xe, scratch);
|
||||
module.glwe_automorphism_key_encrypt_sk(self, p, sk, source_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AutomorphismKeyEncryptSk<BE: Backend> {
|
||||
fn automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
pub trait GLWEAutomorphismKeyEncryptSk<BE: Backend> {
|
||||
fn glwe_automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
|
||||
fn automorphism_key_encrypt_sk<R, S>(
|
||||
fn glwe_automorphism_key_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
p: i64,
|
||||
@@ -68,12 +68,12 @@ pub trait AutomorphismKeyEncryptSk<BE: Backend> {
|
||||
S: GLWESecretToRef;
|
||||
}
|
||||
|
||||
impl<BE: Backend> AutomorphismKeyEncryptSk<BE> for Module<BE>
|
||||
impl<BE: Backend> GLWEAutomorphismKeyEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Self: GGLWEEncryptSk<BE> + VecZnxAutomorphism + GaloisElement + SvpPPolBytesOf + GLWESecretPreparedFactory<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
fn glwe_automorphism_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
@@ -88,7 +88,7 @@ where
|
||||
.max(GLWESecret::bytes_of_from_infos(infos))
|
||||
}
|
||||
|
||||
fn automorphism_key_encrypt_sk<R, S>(
|
||||
fn glwe_automorphism_key_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
p: i64,
|
||||
@@ -106,10 +106,10 @@ where
|
||||
assert_eq!(res.rank_out(), res.rank_in());
|
||||
assert_eq!(sk.rank(), res.rank_out());
|
||||
assert!(
|
||||
scratch.available() >= self.automorphism_key_encrypt_sk_tmp_bytes(res),
|
||||
scratch.available() >= self.glwe_automorphism_key_encrypt_sk_tmp_bytes(res),
|
||||
"scratch.available(): {} < AutomorphismKey::encrypt_sk_tmp_bytes: {:?}",
|
||||
scratch.available(),
|
||||
self.automorphism_key_encrypt_sk_tmp_bytes(res)
|
||||
self.glwe_automorphism_key_encrypt_sk_tmp_bytes(res)
|
||||
);
|
||||
|
||||
let (mut sk_out_prepared, scratch_1) = scratch.take_glwe_secret_prepared(self, sk.rank());
|
||||
@@ -141,18 +141,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GGLWEAutomorphismKeyEncryptPk<BE: Backend> {
|
||||
fn automorphism_key_encrypt_pk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
pub trait GLWEAutomorphismKeyEncryptPk<BE: Backend> {
|
||||
fn glwe_automorphism_key_encrypt_pk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
}
|
||||
|
||||
impl<BE: Backend> GGLWEAutomorphismKeyEncryptPk<BE> for Module<BE>
|
||||
impl<BE: Backend> GLWEAutomorphismKeyEncryptPk<BE> for Module<BE>
|
||||
where
|
||||
Self:,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn automorphism_key_encrypt_pk_tmp_bytes<A>(&self, _infos: &A) -> usize
|
||||
fn glwe_automorphism_key_encrypt_pk_tmp_bytes<A>(&self, _infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
|
||||
@@ -10,22 +10,22 @@ use poulpy_hal::{
|
||||
use crate::{
|
||||
GGLWEEncryptSk, GetDistribution, ScratchTakeCore,
|
||||
layouts::{
|
||||
GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos, Rank, TensorKey, TensorKeyToMut,
|
||||
GGLWE, GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, GLWETensorKey, GLWETensorKeyToMut, LWEInfos, Rank,
|
||||
prepared::{GLWESecretPrepared, GLWESecretPreparedFactory},
|
||||
},
|
||||
};
|
||||
|
||||
impl TensorKey<Vec<u8>> {
|
||||
impl GLWETensorKey<Vec<u8>> {
|
||||
pub fn encrypt_sk_tmp_bytes<M, A, BE: Backend>(module: &M, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
M: TensorKeyEncryptSk<BE>,
|
||||
M: GLWETensorKeyEncryptSk<BE>,
|
||||
{
|
||||
module.tensor_key_encrypt_sk_tmp_bytes(infos)
|
||||
module.glwe_tensor_key_encrypt_sk_tmp_bytes(infos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<DataSelf: DataMut> TensorKey<DataSelf> {
|
||||
impl<DataSelf: DataMut> GLWETensorKey<DataSelf> {
|
||||
pub fn encrypt_sk<M, S, BE: Backend>(
|
||||
&mut self,
|
||||
module: &M,
|
||||
@@ -34,20 +34,20 @@ impl<DataSelf: DataMut> TensorKey<DataSelf> {
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
M: TensorKeyEncryptSk<BE>,
|
||||
M: GLWETensorKeyEncryptSk<BE>,
|
||||
S: GLWESecretToRef + GetDistribution + GLWEInfos,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
module.tensor_key_encrypt_sk(self, sk, source_xa, source_xe, scratch);
|
||||
module.glwe_tensor_key_encrypt_sk(self, sk, source_xa, source_xe, scratch);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TensorKeyEncryptSk<BE: Backend> {
|
||||
fn tensor_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
pub trait GLWETensorKeyEncryptSk<BE: Backend> {
|
||||
fn glwe_tensor_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos;
|
||||
|
||||
fn tensor_key_encrypt_sk<R, S>(
|
||||
fn glwe_tensor_key_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
sk: &S,
|
||||
@@ -55,11 +55,11 @@ pub trait TensorKeyEncryptSk<BE: Backend> {
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
R: TensorKeyToMut,
|
||||
R: GLWETensorKeyToMut,
|
||||
S: GLWESecretToRef + GetDistribution + GLWEInfos;
|
||||
}
|
||||
|
||||
impl<BE: Backend> TensorKeyEncryptSk<BE> for Module<BE>
|
||||
impl<BE: Backend> GLWETensorKeyEncryptSk<BE> for Module<BE>
|
||||
where
|
||||
Self: ModuleN
|
||||
+ GGLWEEncryptSk<BE>
|
||||
@@ -72,7 +72,7 @@ where
|
||||
+ VecZnxBigNormalize<BE>,
|
||||
Scratch<BE>: ScratchTakeCore<BE>,
|
||||
{
|
||||
fn tensor_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
fn glwe_tensor_key_encrypt_sk_tmp_bytes<A>(&self, infos: &A) -> usize
|
||||
where
|
||||
A: GGLWEInfos,
|
||||
{
|
||||
@@ -84,7 +84,7 @@ where
|
||||
+ GGLWE::encrypt_sk_tmp_bytes(self, infos)
|
||||
}
|
||||
|
||||
fn tensor_key_encrypt_sk<R, S>(
|
||||
fn glwe_tensor_key_encrypt_sk<R, S>(
|
||||
&self,
|
||||
res: &mut R,
|
||||
sk: &S,
|
||||
@@ -92,10 +92,10 @@ where
|
||||
source_xe: &mut Source,
|
||||
scratch: &mut Scratch<BE>,
|
||||
) where
|
||||
R: TensorKeyToMut,
|
||||
R: GLWETensorKeyToMut,
|
||||
S: GLWESecretToRef + GetDistribution + GLWEInfos,
|
||||
{
|
||||
let res: &mut TensorKey<&mut [u8]> = &mut res.to_mut();
|
||||
let res: &mut GLWETensorKey<&mut [u8]> = &mut res.to_mut();
|
||||
|
||||
// let n: RingDegree = sk.n();
|
||||
let rank: Rank = res.rank_out();
|
||||
|
||||
Reference in New Issue
Block a user