chore: split up more xof key gen function

This commit is contained in:
Thomas Montaigu
2025-09-23 20:27:59 +02:00
committed by tmontaigu
parent 736185bb31
commit 8b5d7321fb
8 changed files with 605 additions and 513 deletions

View File

@@ -534,7 +534,7 @@ pub fn allocate_and_generate_lwe_bootstrapping_key_with_pre_seeded_generator<
decomp_level_count: DecompositionLevelCount,
noise_distribution: DynamicDistribution<GlweCont::Element>,
ciphertext_modulus: CiphertextModulus<GlweCont::Element>,
noise_generator: &mut EncryptionRandomGenerator<ByteGen>,
generator: &mut EncryptionRandomGenerator<ByteGen>,
) -> SeededLweBootstrapKeyOwned<GlweCont::Element>
where
LweCont: Container,
@@ -560,7 +560,7 @@ where
output_glwe_secret_key,
&mut lwe_bootstrapping_key,
noise_distribution,
noise_generator,
generator,
);
lwe_bootstrapping_key

View File

@@ -563,6 +563,7 @@ where
pub fn allocate_and_generate_lwe_key_switching_key_with_pre_seeded_generator<
InputLweCont,
OutputLweCont,
Gen,
>(
input_lwe_secret_key: &LweSecretKey<InputLweCont>,
output_lwe_secret_key: &LweSecretKey<OutputLweCont>,
@@ -570,13 +571,14 @@ pub fn allocate_and_generate_lwe_key_switching_key_with_pre_seeded_generator<
decomp_level_count: DecompositionLevelCount,
noise_distribution: DynamicDistribution<InputLweCont::Element>,
ciphertext_modulus: CiphertextModulus<InputLweCont::Element>,
noise_generator: &mut EncryptionRandomGenerator<DefaultRandomGenerator>,
generator: &mut EncryptionRandomGenerator<Gen>,
) -> SeededLweKeyswitchKeyOwned<InputLweCont::Element>
where
InputLweCont: Container,
InputLweCont::Element:
UnsignedInteger + Encryptable<Uniform, DynamicDistribution<InputLweCont::Element>>,
OutputLweCont: Container<Element = InputLweCont::Element>,
Gen: ByteRandomGenerator,
{
let mut key_switching_key = SeededLweKeyswitchKeyOwned::new(
InputLweCont::Element::ZERO,
@@ -592,7 +594,7 @@ where
output_lwe_secret_key,
&mut key_switching_key,
noise_distribution,
noise_generator,
generator,
);
key_switching_key

View File

@@ -19,11 +19,8 @@ pub use tfhe_csprng::seeders::{Seed, Seeder, XofSeed};
/// Module to proxy the serialization for `tfhe-csprng::Seed` to avoid adding serde as a
/// dependency to `tfhe-csprng`
pub mod serialization_proxy {
// use crate::core_crypto::backward_compatibility::commons::math::random::{
// XofSeedSerdeDefVersioned, XofSeedSerdeDefVersionedOwned,
// };
pub(crate) use serde::{Deserialize, Serialize};
pub(crate) use tfhe_csprng::seeders::{Seed, XofSeed};
pub(crate) use tfhe_csprng::seeders::Seed;
// See https://serde.rs/remote-derive.html
// Serde calls this the definition of the remote type. It is just a copy of the remote data
// structure. The `remote` attribute gives the path to the actual type we intend to derive code
@@ -31,16 +28,6 @@ pub mod serialization_proxy {
#[derive(Serialize, Deserialize)]
#[serde(remote = "Seed")]
pub(crate) struct SeedSerdeDef(pub u128);
#[derive(Serialize, Deserialize)]
#[serde(remote = "XofSeed")]
pub(crate) struct XofSeedSerdeDef(#[serde(getter = "XofSeed::bytes")] Vec<u8>);
impl From<XofSeedSerdeDef> for XofSeed {
fn from(value: XofSeedSerdeDef) -> Self {
Self::from_bytes(value.0)
}
}
}
pub(crate) use serialization_proxy::*;

View File

@@ -1,15 +1,9 @@
use serde::{Deserialize, Serialize};
use tfhe_versionable::VersionsDispatch;
use crate::high_level_api::xof_key_set::{CompressedXofKeySet, XofKeySet};
#[derive(Serialize)]
pub enum CompressedXofKeySetVersioned<'vers> {
V0(&'vers CompressedXofKeySet),
}
#[derive(Serialize, Deserialize)]
pub enum CompressedXofKeySetVersionedOwned {
#[derive(VersionsDispatch)]
pub enum CompressedXofKeySetVersions {
V0(CompressedXofKeySet),
}

File diff suppressed because it is too large Load Diff