package mlkem

  1. Overview
  2. Docs
Pure OCaml implementation of FIPS 203 ML-KEM

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1.1.tar.gz
md5=20087fca24222c6de0db3a2d2b05f9c1
sha512=69bdfe62d0a93ff4dbe85280b7fd3db9970adbc36f52891f63e727a4eb32a19bfccf727a62d3740d4771522489cdcbb4feaa3537cdd9b183962252065674ed32

Description

Portable, typed implementations of ML-KEM-512, ML-KEM-768, and ML-KEM-1024 with no C stubs or runtime package dependencies.

Tags

cryptography post-quantum

Added to opam-repository:

README

ocaml-pq

ocaml-pq implements the three NIST post-quantum cryptography standards in pure OCaml. Each algorithm is available as a separate opam package:

Package

Purpose

Standard

mlkem

Establish a shared secret

FIPS 203 (ML-KEM)

mldsa

Sign and verify messages

FIPS 204 (ML-DSA)

slhdsa

Sign and verify messages using hash-based signatures

FIPS 205 (SLH-DSA)

All standardized parameter sets are supported. The packages require OCaml 4.13 or newer, have no C stubs or runtime package dependencies, and work in native programs, MirageOS unikernels, and js_of_ocaml applications.

Security status: The 0.1.x series has not received an independent cryptographic audit. Constant-time execution is not guaranteed, and ML-DSA signing has timing limitations. Read the security policy before use.

Install

From a checkout of this repository:

opam install .

Add the package you use to your Dune stanza, for example (libraries mlkem).

Example: establish a shared secret

The receiver generates a key pair and shares the public encapsulation key. The sender uses it to produce a ciphertext and shared secret; the receiver recovers the same secret from the ciphertext with the private key.

Supply secure_random : int -> string, a function that returns exactly the requested number of cryptographically secure random bytes.

let private_key, public_key = Mlkem.Mlkem768.generate ~random:secure_random () in
let ciphertext, sender_secret =
  Mlkem.Mlkem768.encapsulate ~random:secure_random public_key
in
let receiver_secret = Mlkem.Mlkem768.decapsulate private_key ciphertext in
assert (
  Mlkem.Mlkem768.shared_secret_to_octets sender_secret =
  Mlkem.Mlkem768.shared_secret_to_octets receiver_secret)

Documentation

  • API usage: parameter sets, signing examples, randomness, and key formats.
  • Design notes: package boundaries, implementation, and security limitations.
  • Development: building, testing, fuzzing, and benchmarks.
  • Releasing: maintainer instructions.
  • Changelog: release history.

Licensed under the ISC license.

Dependencies (2)

  1. dune >= "3.0"
  2. ocaml >= "4.13.0"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest with-test

Used by

None

Conflicts

None