Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Monolithic Build (C Backend)

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 Case

Use this approach when:

  • You want the simplest possible build integration (one .c file)
  • You're using only C (no native backends)
  • You need only one ML-KEM parameter set (512, 768, or 1024)

Components

  1. Source tree mlkem_native/*, including top-level compilation unit mlkem_native.c (gathering all C sources) and the mlkem-native API mlkem_native.h.
  2. A secure random number generator implementing randombytes.h
  3. Your application source code

Configuration

The configuration file mlkem_native_config.h sets:

  • MLK_CONFIG_PARAMETER_SET: Security level (default 768)
  • MLK_CONFIG_NAMESPACE_PREFIX: Symbol prefix (set to mlkem)
  • 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

Notes

  • The monolithic .c file is auto-generated by scripts/autogen
  • Internal functions become static, enabling better compiler optimization

Usage

make build   # Build the example
make run     # Run the example

Warning

The randombytes() implementation in test_only_rng/ is for TESTING ONLY. You MUST provide a cryptographically secure RNG for production use.