mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 22:57:59 -05:00
chore: split up more xof key gen function
This commit is contained in:
committed by
tmontaigu
parent
736185bb31
commit
8b5d7321fb
@@ -15,6 +15,8 @@ rust-version = "1.72"
|
||||
aes = "0.8.2"
|
||||
rayon = { workspace = true, optional = true }
|
||||
getrandom = { workspace = true }
|
||||
serde = "1.0.226"
|
||||
tfhe-versionable = { version = "0.6.2", path = "../utils/tfhe-versionable" }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
libc = "0.2.133"
|
||||
|
||||
8
tfhe-csprng/src/seeders/backward_compatibility/mod.rs
Normal file
8
tfhe-csprng/src/seeders/backward_compatibility/mod.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
use tfhe_versionable::VersionsDispatch;
|
||||
|
||||
use crate::seeders::XofSeed;
|
||||
|
||||
#[derive(VersionsDispatch)]
|
||||
pub enum XofSeedVersions {
|
||||
V0(XofSeed),
|
||||
}
|
||||
@@ -9,14 +9,15 @@
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct Seed(pub u128);
|
||||
|
||||
/// A Seed as described in the [NIST document]
|
||||
/// A Seed as described in the [Threshold (Fully) Homomorphic Encryption]
|
||||
///
|
||||
/// This seed contains 2 information:
|
||||
/// * The domain separator bytes (ASCII string)
|
||||
/// * The seed bytes
|
||||
///
|
||||
/// [NIST document]: https://eprint.iacr.org/2025/699
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
/// [Threshold (Fully) Homomorphic Encryption]: https://eprint.iacr.org/2025/699
|
||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Deserialize, serde::Serialize, Versionize)]
|
||||
#[versionize(XofSeedVersions)]
|
||||
pub struct XofSeed {
|
||||
// We store the domain separator concatenated with the seed bytes (str||seed)
|
||||
// as it makes it easier to create the iterator of u128 blocks
|
||||
@@ -97,7 +98,8 @@ pub enum SeedKind {
|
||||
/// Initializes the Aes-Ctr with a counter starting at 0
|
||||
/// and uses the seed as the Aes key.
|
||||
Ctr(Seed),
|
||||
/// Seed that initialized the Aes-Ctr following the NIST document (see [XofSeed]).
|
||||
/// Seed that initialized the Aes-Ctr following the Threshold (Fully) Homomorphic Encryption
|
||||
/// document (see [XofSeed]).
|
||||
///
|
||||
/// An Aes-Key and starting counter will be derived from the XofSeed, to
|
||||
/// then initialize the Aes-Ctr random generator
|
||||
@@ -128,11 +130,15 @@ pub trait Seeder {
|
||||
Self: Sized;
|
||||
}
|
||||
|
||||
pub mod backward_compatibility;
|
||||
mod implem;
|
||||
// This import statement can be empty if seeder features are disabled, rustc's behavior changed to
|
||||
// warn of empty modules, we know this can happen, so allow it.
|
||||
#[allow(unused_imports)]
|
||||
pub use implem::*;
|
||||
use tfhe_versionable::Versionize;
|
||||
|
||||
use crate::seeders::backward_compatibility::XofSeedVersions;
|
||||
|
||||
#[cfg(test)]
|
||||
mod generic_tests {
|
||||
|
||||
Reference in New Issue
Block a user