package core:crypto/mlkem
Overview
ML-KEM Module-Lattice-Based Key-Encapsulation Mechanism.
See: https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.pdf
Index
Types (3)
Constants (2)
Procedures (15)
- decaps
- decapsulation_key_bytes
- decapsulation_key_clear
- decapsulation_key_encaps_bytes
- decapsulation_key_expanded_bytes
- decapsulation_key_generate
- decapsulation_key_set_bytes
- encaps_ek
- encaps_ek_raw_bytes
- encapsulation_key_bytes
- encapsulation_key_clear
- encapsulation_key_set_bytes
- encapsulation_key_set_decaps
- key_size
- params
Procedure Groups (1)
Types
Decapsulation_Key ¶
Decapsulation_Key :: _mlkem.Decapsulation_Key
Decapsulation_Key is a ML-KEM decapsulation (aka "private") key. This implementation opts to include the encapsulation (aka "public") key as well for cases where the decapsulation key is reused (eg: HPKE with X-Wing).
Encapsulation_Key ¶
Encapsulation_Key :: _mlkem.Encapsulation_Key
Encapsulation_Key is a ML-KEM encapsulation (aka "public") key.
Related Procedures With Parameters
Parameters ¶
Parameters :: enum int { Invalid, ML_KEM_512, ML_KEM_768, ML_KEM_1024, }
Parameters are the supported ML-KEM parameter sets.
Related Procedures With Parameters
Related Procedures With Returns
Constants
DECAPSULATION_KEY_SEED_SIZE ¶
DECAPSULATION_KEY_SEED_SIZE :: 64
DECAPSULATION_KEY_SEED_SIZE is the size of a Decapsulation key in bytes.
SHARED_SECRET_SIZE ¶
SHARED_SECRET_SIZE :: 32
SHARED_SECRET_SIZE is the size of the final shared secret in bytes.
Variables
CIPHERTEXT_SIZES ¶
CIPHERTEXT_SIZES: [Parameters]int = …
CIPHERTEXT_SIZES are the per-parameter set sizes of the ciphertext in bytes.
DECAPSULATION_KEY_EXPANDED_SIZES ¶
DECAPSULATION_KEY_EXPANDED_SIZES: [Parameters]int = …
DECAPSULATION_KEY_EXPANDED_SIZES are the per-parameter sizes of the decapsulation key in bytes.
ENCAPSULATION_KEY_SIZES ¶
ENCAPSULATION_KEY_SIZES: [Parameters]int = …
ENCAPSULATION_KEY_SIZES are the per-parameter sizes of the encapsulation key in bytes.
Procedures
decaps ¶
decaps :: proc(dk: ^_mlkem.Decapsulation_Key, ciphertext, shared_secret: []u8) -> bool {…}
decaps uses the decapsulation key to generate a shared secret from a ciphertext. Due to ML-KEM's implicit rejection mechanism, this function will only return false iff the lengths of the inputs are invalid or the decapsulation key is uninitialized.
This routine returning true does not guarantee that the shared secret matches that generated by the peer.
decapsulation_key_bytes ¶
decapsulation_key_bytes :: proc(dk: ^_mlkem.Decapsulation_Key, dst: []u8) {…}
decapsulation_key_bytes sets dst to byte-encoding of dk in the (d, z) "seed" format.
decapsulation_key_clear ¶
decapsulation_key_clear :: proc(dk: ^_mlkem.Decapsulation_Key) {…}
decapsulation_key_clear clears dk to the uninitialized state.
decapsulation_key_encaps_bytes ¶
decapsulation_key_encaps_bytes :: proc(dk: ^_mlkem.Decapsulation_Key, dst: []u8) {…}
decapsulation_key_encaps_bytes sets dst to the byte-encoding of the encasulation key corresponding to dk.
decapsulation_key_expanded_bytes ¶
decapsulation_key_expanded_bytes :: proc(dk: ^_mlkem.Decapsulation_Key, dst: []u8) {…}
decapsulation_key_expanded_bytes sets dst to the byte-encoding of dk. in the expanded FIPS 203 format. This primarily exists for export purposes.
decapsulation_key_generate ¶
decapsulation_key_generate :: proc(dk: ^_mlkem.Decapsulation_Key, params: Parameters) -> bool {…}
decapsulation_key_generate uses the system entropy source to generate a decapsulation key. This will only fail iff the system entropy source is missing or broken.
decapsulation_key_set_bytes ¶
decapsulation_key_set_bytes :: proc(dk: ^_mlkem.Decapsulation_Key, params: Parameters, seed: []u8) -> bool {…}
decapsulation_key_set_bytes decodes a byte-encoded decapsulation key in (d, z) "seed" format, and returns true iff the operation was successful.
encaps_ek ¶
encaps_ek :: proc(ek: ^_mlkem.Encapsulation_Key, shared_secret, ciphertext: []u8) -> bool {…}
encaps_ek uses the encapsulation key to generate a shared secret and an associated ciphertext. This routine will fail if the system entropy source is unavailable.
Related Procedure Groups
encaps_ek_raw_bytes ¶
encaps_ek_raw_bytes :: proc(params: Parameters, raw_ek, shared_secret, ciphertext: []u8) -> bool {…}
encaps_raw_ek_bytes uses the byte encoded encapsulation key to generate a shared secret and an associated ciphertext. This routine will fail if the system entropy source is unavailable, or of the encapsulation key is invalid.
Related Procedure Groups
encapsulation_key_bytes ¶
encapsulation_key_bytes :: proc(ek: ^_mlkem.Encapsulation_Key, dst: []u8) {…}
encapsulation_key_encaps_bytes sets dst to the byte-encoding of ek.
encapsulation_key_clear ¶
encapsulation_key_clear :: proc(ek: ^_mlkem.Encapsulation_Key) {…}
encapsulation_key_clear clears ek to the uninitialized state.
encapsulation_key_set_bytes ¶
encapsulation_key_set_bytes :: proc(ek: ^_mlkem.Encapsulation_Key, params: Parameters, b: []u8) -> bool {…}
encapsulation_key_set_bytes decodes a byte-encoded encapsulation key, and returns true iff the operation was successful.
encapsulation_key_set_decaps ¶
encapsulation_key_set_decaps :: proc(ek: ^_mlkem.Encapsulation_Key, dk: ^_mlkem.Decapsulation_Key) {…}
encapsulation_key_set_decaps sets ek to the encapsulation key corresponding to dk.
key_size ¶
key_size :: proc(k: ^$T) -> int {…}
key_size returns the key size of a Decapsulation_Key or Encapsulation_Key in bytes.
params ¶
params :: proc(k: ^$T) -> Parameters {…}
params returns the Parameters used by a Decapsulation_Key or Encapsulation_Key instance.
Procedure Groups
encaps ¶
encaps :: proc{ encaps_ek, encaps_ek_raw_bytes, }
Source Files
Generation Information
Generated with odin version dev-2026-06 (vendor "odin") Windows_amd64 @ 2026-06-02 22:54:54.163594900 +0000 UTC