pub trait MlKemParams:
Sealed
+ Sized
+ Copy
+ Debug
+ 'static {
type PublicKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug;
type SecretKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug;
type CiphertextBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug;
Show 14 associated constants and 3 methods
const K: usize;
const ETA1: usize;
const DU: usize;
const DV: usize;
const PUBLIC_KEY_BYTES: usize;
const SECRET_KEY_BYTES: usize;
const CIPHERTEXT_BYTES: usize;
const ALGORITHM_ID: &'static str;
const OID: &'static str;
const ETA2: usize = 2;
const N: usize = 256;
const Q: usize = 3329;
const SHARED_SECRET_BYTES: usize = 32;
const SYM_BYTES: usize = 32;
// Required methods
fn zero_public_key() -> Self::PublicKeyBytes;
fn zero_secret_key() -> Self::SecretKeyBytes;
fn zero_ciphertext() -> Self::CiphertextBytes;
}Expand description
FIPS 203 parameter pack — every constant and type the algorithm needs to specialise to one of the three ML-KEM variants.
Implemented by the zero-sized marker types
MlKem512, MlKem768,
MlKem1024. Sealed: third-party crates cannot
add new implementations.
All associated constants come from FIPS 203 §6 (“Parameter sets”) and the IETF LAMPS draft for the OIDs / algorithm identifiers.
§Example
use kyberlib::{MlKem768, MlKemParams};
const PK_LEN: usize = <MlKem768 as MlKemParams>::PUBLIC_KEY_BYTES;
const CT_LEN: usize = <MlKem768 as MlKemParams>::CIPHERTEXT_BYTES;
assert_eq!(PK_LEN, 1184);
assert_eq!(CT_LEN, 1088);Required Associated Constants§
Sourceconst ETA1: usize
const ETA1: usize
Centred-binomial width η₁ for the secret-key sampling. 3 for ML-KEM-512, 2 for ML-KEM-768 and ML-KEM-1024.
Sourceconst DU: usize
const DU: usize
Ciphertext compression bit-width for the u half. 10 for ML-KEM-512/768, 11 for ML-KEM-1024.
Sourceconst DV: usize
const DV: usize
Ciphertext compression bit-width for the v half. 4 for ML-KEM-512/768, 5 for ML-KEM-1024.
Sourceconst PUBLIC_KEY_BYTES: usize
const PUBLIC_KEY_BYTES: usize
Public encapsulation-key byte length.
K * 384 + 32 per FIPS 203 §6.
Sourceconst SECRET_KEY_BYTES: usize
const SECRET_KEY_BYTES: usize
Secret decapsulation-key byte length.
24*K*N/8 + 96 per FIPS 203 §6.1.
Sourceconst CIPHERTEXT_BYTES: usize
const CIPHERTEXT_BYTES: usize
Ciphertext byte length.
32*(K*DU + DV) per FIPS 203 §6.
Sourceconst ALGORITHM_ID: &'static str
const ALGORITHM_ID: &'static str
Stable algorithm identifier — "ML-KEM-512", "ML-KEM-768",
or "ML-KEM-1024".
Provided Associated Constants§
Sourceconst SHARED_SECRET_BYTES: usize = 32
const SHARED_SECRET_BYTES: usize = 32
Shared-secret length in bytes. Always 32.
Required Associated Types§
Sourcetype PublicKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug
type PublicKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug
Concrete encapsulation-key byte buffer type. Each impl
instantiates as [u8; PUBLIC_KEY_BYTES].
Sourcetype SecretKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug
type SecretKeyBytes: AsRef<[u8]> + AsMut<[u8]> + Copy + Debug
Concrete decapsulation-key byte buffer type. Each impl
instantiates as [u8; SECRET_KEY_BYTES]. Zeroized on drop
at the wrapper level (see crate::ml_kem).
Required Methods§
Sourcefn zero_public_key() -> Self::PublicKeyBytes
fn zero_public_key() -> Self::PublicKeyBytes
Create a new zeroed public-key buffer. Helper so generic code can construct buffers without naming the concrete array size.
Sourcefn zero_secret_key() -> Self::SecretKeyBytes
fn zero_secret_key() -> Self::SecretKeyBytes
Create a new zeroed secret-key buffer.
Sourcefn zero_ciphertext() -> Self::CiphertextBytes
fn zero_ciphertext() -> Self::CiphertextBytes
Create a new zeroed ciphertext buffer.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".