This directory contains a minimal example for building mlkem-native for a single
parameter set of ML-KEM as a single compilation unit using the auto-generated
mlkem_native.c file.
Use this approach when:
- You want the simplest possible build integration (one
.cfile) - You're using only C (no native backends)
- You need only one ML-KEM parameter set (512, 768, or 1024)
- Source tree mlkem_native/*, including top-level compilation unit mlkem_native.c (gathering all C sources) and the mlkem-native API mlkem_native.h.
- A secure random number generator implementing
randombytes.h - Your application source code
The configuration file mlkem_native_config.h sets:
MLK_CONFIG_PARAMETER_SET: Security level (default 768)MLK_CONFIG_NAMESPACE_PREFIX: Symbol prefix (set tomlkem)MLK_CONFIG_INTERNAL_API_QUALIFIER=static: Makes internal functions static for single-CU builds
The auto-generated mlkem_native.c:
- Includes all mlkem-native C source files
- Clears all internal
#defines at the end, allowing multiple inclusion
- The monolithic
.cfile is auto-generated byscripts/autogen - Internal functions become
static, enabling better compiler optimization
make build # Build the example
make run # Run the exampleThe randombytes() implementation in test_only_rng/ is for TESTING ONLY.
You MUST provide a cryptographically secure RNG for production use.