pq-code-package / mlkem-c-embedded

MLKEM implementation optimized for embedded microcontrollers
Apache License 2.0
11 stars 5 forks source link

MLKEM-C-EMBEDDED is a collection of MLKEM implementations optimized for embedded microcontrollers. It is free software licensed under an Apache-2.0 license.

It originates from the pqm4 project, but there are some core differences:

Goals of MLKEM-C-EMBEDDED

The goals and features of a future MLKEM-C-EMBEDDED v1.0 release include:

In the medium term, we hope to include:

In the long term, possible extensions are

Current state

MLKEM-C-EMBEDDED is currently a work in progress and we do not recommend relying on it at this point. WE DO NOT CURRENTLY RECOMMEND RELYING ON THIS LIBRARY IN A PRODUCTION ENVIRONMENT OR TO PROTECT ANY SENSITIVE DATA. Once we have the first stable version, this notice will be removed

The current code is compatible with the standard branch of the official MLKEM repository.

Call for contributors

We are actively seeking contributors who can help us build MLKEM-C-EMBEDDED. If you are interested, please contact us, or volunteer for any of the open issues.

Call for potential consumers

If you are a potential consumer of MLKEM-C-EMBEDDED, please reach out to us. We're interested in hearing the way you are considering using MLKEM-C-EMBEDDED and could benefit from additional features. If you have specific feature requests, please open an issue.

Environment Setup

All the develop and build dependencies are specified in flake.nix.

For further details, please refer to scripts/README.md

Running tests and benchmarks

The build system compiles tests and benchmarks for each mlkem parameter set on specified platform, supported platform can be found by running tests --list-platforms. The PLATFORM configuration is optional, with the default platform set to stm32f4discovery.

For example,

Manual testing on board

After generating the specified hex files, you can flash it to the development board using openocd. For example,

    openocd -f hal/stm32f4discovery.cfg -c "program bin/mlkem768-test.hex verify reset exit"

To receive output from the develop board, you can, for example, use pyserial-miniterm:

    pyserial-miniterm /dev/<tty_device> 38400

Usage of the tests script

Make sure to run make clean between running tests on QEMU or on board or running func/stack/speed and nistkat tests. In case of any inconsistencies, refer to the help command for the most up-to-date usage information

▶ tests --help
Usage: tests [OPTIONS] COMMAND [ARGS]...

Options:
  --list-platforms  List the supported platforms
  --help  Show this message and exit.

Commands:
  func     Run functional tests
  nistkat  Run nistkat tests
  run      Run for the specified platform and hex file without parsing the
           output
  speed    Run speed tests
  stack    Run stack tests

func/speed tests depends on the iteration parameter, which is passed to the tests in compile time, therefore it is preferred to build the binaries with the tests script

▶ tests func --help
Usage: tests func [OPTIONS] {stm32f4discovery|mps2-an386|nucleo-f767zi|mps2-an
                  500|nucleo-f207zg|mps2-an385}

Options:
  -v, --verbose             Show verbose output or not
  -u, --uart PATH           TTY serial device for UART, default to the 1st
                            serial device connected to your board or an empty
                            string
  -i, --iterations INTEGER  Number of tests  [default: 1]
  --help                    Show this message and exit.