[//]: # (SPDX-License-Identifier: CC-BY-4.0)

# Monolithic Build (C Backend)

This directory contains a minimal example for building mldsa-native for a single
parameter set of ML-DSA as a single compilation unit using the auto-generated
`mldsa_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-DSA parameter set (44, 65, or 87)

## Components

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

## Configuration

The configuration file [mldsa_native_config.h](mldsa_native/mldsa_native_config.h) sets:
- `MLD_CONFIG_PARAMETER_SET`: Security level (default 65)
- `MLD_CONFIG_NAMESPACE_PREFIX`: Symbol prefix (set to `mldsa`)
- `MLD_CONFIG_INTERNAL_API_QUALIFIER=static`: Makes internal functions static for single-CU builds

The auto-generated `mldsa_native.c`:
- Includes all mldsa-native C source files
- Clears all internal `#define`s 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

```bash
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.
