pub trait KemCore: Sealed + Sized {
type EncapsulationKey;
type DecapsulationKey;
type Ciphertext;
const ALGORITHM_ID: &'static str;
const OID: &'static str;
// Required methods
fn generate<R: RngCore + CryptoRng>(
rng: &mut R,
) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>;
fn generate_from_seed(
d: &[u8; 32],
z: &[u8; 32],
) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>;
}Expand description
Required Associated Constants§
Sourceconst ALGORITHM_ID: &'static str
const ALGORITHM_ID: &'static str
Stable algorithm identifier per the IETF LAMPS draft —
"ML-KEM-512", "ML-KEM-768", or "ML-KEM-1024".
Required Associated Types§
Sourcetype EncapsulationKey
type EncapsulationKey
Encapsulation key (public side).
Sourcetype DecapsulationKey
type DecapsulationKey
Decapsulation key (secret side). Zeroized on drop.
Sourcetype Ciphertext
type Ciphertext
Ciphertext.
Required Methods§
Sourcefn generate<R: RngCore + CryptoRng>(
rng: &mut R,
) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>
fn generate<R: RngCore + CryptoRng>( rng: &mut R, ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>
Generate a fresh decapsulation / encapsulation key pair.
§Errors
Returns KyberLibError::RandomBytesGeneration if the supplied
RNG fails to produce randomness. All other errors are
internal-invariant violations and should not occur with a
well-behaved RNG.
Sourcefn generate_from_seed(
d: &[u8; 32],
z: &[u8; 32],
) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>
fn generate_from_seed( d: &[u8; 32], z: &[u8; 32], ) -> Result<(Self::DecapsulationKey, Self::EncapsulationKey), KyberLibError>
Derive a key pair from the seed (d, z): FIPS 203 Algorithm 16,
ML-KEM.KeyGen_internal(d, z).
d ‖ z is the seed form of an ML-KEM private key: keeping these
64 bytes is enough to rebuild the key pair (for example, X-Wing
stores a 32-byte seed and expands it into d and z). Both
halves must come from an approved RNG and stay secret.
§Errors
None in practice: the seeded path draws no randomness. The
Result matches KemCore::generate.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".