| 1 |
[//]: # (SPDX-License-Identifier: CC-BY-4.0) |
| 2 |
|
| 3 |
# Monolithic Build (Native Backend) |
| 4 |
|
| 5 |
This directory contains a minimal example for building mldsa-native as a single compilation unit |
| 6 |
with native assembly backends, using the auto-generated `mldsa_native.c` and `mldsa_native.S` files. |
| 7 |
|
| 8 |
## Use Case |
| 9 |
|
| 10 |
Use this approach when: |
| 11 |
- You need only one ML-DSA parameter set (44, 65, or 87) |
| 12 |
- You want simple build integration with optimal performance |
| 13 |
|
| 14 |
## Components |
| 15 |
|
| 16 |
1. Source tree [mldsa_native/*](mldsa_native), including top-level compilation unit |
| 17 |
[mldsa_native.c](mldsa_native/mldsa_native.c) (gathering all C sources), |
| 18 |
[mldsa_native.S](mldsa_native/mldsa_native.S) (gathering all assembly sources), |
| 19 |
and the mldsa-native API [mldsa_native.h](mldsa_native/mldsa_native.h). |
| 20 |
2. A secure random number generator implementing [`randombytes.h`](../../mldsa/src/randombytes.h) |
| 21 |
3. Your application source code |
| 22 |
|
| 23 |
## Configuration |
| 24 |
|
| 25 |
The configuration file [mldsa_native_config.h](mldsa_native/mldsa_native_config.h) sets: |
| 26 |
- `MLD_CONFIG_PARAMETER_SET`: Security level (default 65) |
| 27 |
- `MLD_CONFIG_NAMESPACE_PREFIX`: Symbol prefix (set to `mldsa`) |
| 28 |
- `MLD_CONFIG_USE_NATIVE_BACKEND_ARITH`: Enables native arithmetic backend |
| 29 |
- `MLD_CONFIG_USE_NATIVE_BACKEND_FIPS202`: Enables native FIPS-202 backend |
| 30 |
|
| 31 |
## Notes |
| 32 |
|
| 33 |
- Both `mldsa_native.c` and `mldsa_native.S` must be compiled and linked |
| 34 |
- Native backends are auto-selected based on target architecture |
| 35 |
- On unsupported platforms, the C backend is used automatically |
| 36 |
|
| 37 |
## Usage |
| 38 |
|
| 39 |
```bash |
| 40 |
make build # Build the example |
| 41 |
make run # Run the example |
| 42 |
``` |
| 43 |
|
| 44 |
## Warning |
| 45 |
|
| 46 |
The `randombytes()` implementation in `test_only_rng/` is for TESTING ONLY. |
| 47 |
You MUST provide a cryptographically secure RNG for production use. |