Removed traits on structs not dependent on Module API

This commit is contained in:
Pro7ech
2025-10-20 10:32:02 +02:00
parent 60fbd3e625
commit 53bc78f421
50 changed files with 858 additions and 2010 deletions

View File

@@ -8,7 +8,7 @@ use crate::{
ScratchTakeCore,
encryption::compressed::gglwe_ksk::GLWESwitchingKeyCompressedEncryptSk,
layouts::{
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretAlloc, GLWESecretToRef, LWEInfos,
GGLWEInfos, GLWEInfos, GLWESecret, GLWESecretToRef, LWEInfos,
compressed::{AutomorphismKeyCompressed, AutomorphismKeyCompressedToMut},
},
};
@@ -68,7 +68,7 @@ where
where
A: GGLWEInfos,
{
self.glwe_switching_key_compressed_encrypt_sk_tmp_bytes(infos) + self.bytes_of_glwe_secret(infos.rank())
self.glwe_switching_key_compressed_encrypt_sk_tmp_bytes(infos) + GLWESecret::bytes_of(self.n().into(), infos.rank())
}
fn automorphism_key_compressed_encrypt_sk<R, S>(

View File

@@ -11,7 +11,7 @@ use crate::{
glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
},
layouts::{
GGLWECompressedSeedMut, GGLWEInfos, GLWEPlaintextAlloc, GLWESecretPrepared, LWEInfos,
GGLWECompressedSeedMut, GGLWEInfos, GLWEPlaintext, GLWESecretPrepared, LWEInfos,
compressed::{GGLWECompressed, GGLWECompressedToMut},
prepared::GLWESecretPreparedToRef,
},
@@ -82,7 +82,7 @@ where
{
self.glwe_encrypt_sk_tmp_bytes(infos)
.max(self.vec_znx_normalize_tmp_bytes())
+ self.bytes_of_glwe_plaintext_from_infos(infos)
+ GLWEPlaintext::bytes_of_from_infos(infos)
}
fn gglwe_compressed_encrypt_sk<R, P, S>(

View File

@@ -80,7 +80,7 @@ where
infos.rank_out(),
"rank_in != rank_out is not supported for GGLWEAutomorphismKey"
);
self.glwe_switching_key_encrypt_sk_tmp_bytes(infos) + GLWESecret::bytes_of_from_infos(self, infos)
self.glwe_switching_key_encrypt_sk_tmp_bytes(infos) + GLWESecret::bytes_of_from_infos(infos)
}
fn automorphism_key_encrypt_sk<R, S>(

View File

@@ -85,8 +85,7 @@ where
where
A: GGLWEInfos,
{
self.glwe_encrypt_sk_tmp_bytes(infos)
+ GLWEPlaintext::bytes_of_from_infos(self, infos).max(self.vec_znx_normalize_tmp_bytes())
self.glwe_encrypt_sk_tmp_bytes(infos) + GLWEPlaintext::bytes_of_from_infos(infos).max(self.vec_znx_normalize_tmp_bytes())
}
fn gglwe_encrypt_sk<R, P, S>(

View File

@@ -82,7 +82,7 @@ where
+ self.bytes_of_vec_znx_dft(infos.rank_out().into(), 1)
+ self.bytes_of_vec_znx_big(1, 1)
+ self.bytes_of_vec_znx_dft(1, 1)
+ GLWESecret::bytes_of(self, Rank(1))
+ GLWESecret::bytes_of(self.n().into(), Rank(1))
+ GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos)
}

View File

@@ -8,7 +8,7 @@ use crate::{
SIGMA, ScratchTakeCore,
encryption::glwe_ct::{GLWEEncryptSk, GLWEEncryptSkInternal},
layouts::{
GGSW, GGSWInfos, GGSWToMut, GLWEInfos, GLWEPlaintextAlloc, LWEInfos,
GGSW, GGSWInfos, GGSWToMut, GLWEInfos, GLWEPlaintext, LWEInfos,
prepared::{GLWESecretPrepared, GLWESecretPreparedToRef},
},
};
@@ -79,7 +79,7 @@ where
{
self.glwe_encrypt_sk_tmp_bytes(infos)
.max(self.vec_znx_normalize_tmp_bytes())
+ self.bytes_of_glwe_plaintext_from_infos(infos)
+ GLWEPlaintext::bytes_of_from_infos(infos)
}
fn ggsw_encrypt_sk<R, P, S>(

View File

@@ -55,7 +55,7 @@ where
// Its ok to allocate scratch space here since pk is usually generated only once.
let mut scratch: ScratchOwned<BE> = ScratchOwned::alloc(self.glwe_encrypt_sk_tmp_bytes(res));
let mut tmp: GLWE<Vec<u8>> = GLWE::alloc_from_infos(self, res);
let mut tmp: GLWE<Vec<u8>> = GLWE::alloc_from_infos(res);
tmp.encrypt_zero_sk(self, sk, source_xa, source_xe, scratch.borrow());
}

View File

@@ -72,7 +72,7 @@ where
A: GGLWEInfos,
{
GLWESecretPrepared::bytes_of(self, infos.rank_in())
+ (GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos) | GLWESecret::bytes_of(self, infos.rank_in()))
+ (GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos) | GLWESecret::bytes_of(self.n().into(), infos.rank_in()))
}
fn glwe_to_lwe_switching_key_encrypt_sk<R, S1, S2>(

View File

@@ -85,7 +85,7 @@ where
1,
"rank_out > 1 is not supported for LWESwitchingKey"
);
GLWESecret::bytes_of(self, Rank(1))
GLWESecret::bytes_of(self.n().into(), Rank(1))
+ GLWESecretPrepared::bytes_of(self, Rank(1))
+ GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos)
}

View File

@@ -75,7 +75,7 @@ where
Rank(1),
"rank_in != 1 is not supported for LWEToGLWESwitchingKey"
);
GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos) + GLWESecret::bytes_of(self, infos.rank_in())
GLWESwitchingKey::encrypt_sk_tmp_bytes(self, infos) + GLWESecret::bytes_of(self.n().into(), infos.rank_in())
}
fn lwe_to_glwe_switching_key_encrypt_sk<R, S1, S2>(