Part 1 ended with three names: ML-KEM (FIPS 203) to agree a key, ML-DSA (FIPS 204) to sign, and SLH-DSA (FIPS 205) as the hash-based backup signer. This post puts each of them to work. You need a recent Go or OpenSSL 3.5 or later; I used Go 1.27.4 and OpenSSL 3.5.9.
Agreeing a key with ML-KEM in Go#
Go’s standard library has crypto/mlkem, which “implements the quantum-resistant
key encapsulation method ML-KEM (formerly known as Kyber), as specified in NIST FIPS 203”. Its documentation adds that
“Most applications should use the ML-KEM-768 parameter set”.
A KEM works a little differently from the Diffie-Hellman exchange it replaces. Alice publishes a key. Bob uses it to make a fresh secret and a ciphertext, a sealed envelope only Alice can open. Alice opens it and now holds the same secret. Here is the whole exchange:
package main
import (
"bytes"
"crypto/mlkem"
"fmt"
"log"
)
func main() {
// Alice makes a key pair and publishes the encapsulation key.
alice, err := mlkem.GenerateKey768()
if err != nil {
log.Fatal(err)
}
public := alice.EncapsulationKey().Bytes()
// Bob uses Alice's public key to make a shared secret and a ciphertext.
ek, err := mlkem.NewEncapsulationKey768(public)
if err != nil {
log.Fatal(err)
}
bobSecret, ciphertext := ek.Encapsulate()
// Alice opens the ciphertext with her private key.
aliceSecret, err := alice.Decapsulate(ciphertext)
if err != nil {
log.Fatal(err)
}
fmt.Printf("public key: %d bytes\n", len(public))
fmt.Printf("ciphertext: %d bytes\n", len(ciphertext))
fmt.Printf("shared secret: %d bytes\n", len(bobSecret))
fmt.Printf("same secret: %v\n", bytes.Equal(aliceSecret, bobSecret))
}Save it as main.go in a new folder, run go mod init mlkemdemo, then go run .:
public key: 1184 bytes
ciphertext: 1088 bytes
shared secret: 32 bytes
same secret: trueTwo things to notice. The shared secret is 32 bytes, the same size you’d feed to AES, which is why the symmetric half of cryptography doesn’t change. And the price is size: the public key is 1,184 bytes, where an X25519 key is 32.
Signing with all three in OpenSSL#
OpenSSL 3.5.0 (8 April 2025) added “Support for PQC
algorithms (ML-KEM, ML-DSA and SLH-DSA)”. If openssl version says 3.5 or later, this loop signs one file with
today’s Ed25519 and with both new signature standards, then checks each signature:
echo "hello, 2035" > msg.txt
for alg in ED25519 ML-DSA-65 SLH-DSA-SHA2-128s; do
openssl genpkey -algorithm "$alg" -out "$alg.key"
openssl pkey -in "$alg.key" -pubout -out "$alg.pub.pem"
openssl pkey -in "$alg.key" -pubout -outform DER -out "$alg.pub.der"
openssl pkeyutl -sign -rawin -inkey "$alg.key" -in msg.txt -out "$alg.sig"
printf "%s: " "$alg"
openssl pkeyutl -verify -rawin -pubin -inkey "$alg.pub.pem" -in msg.txt -sigfile "$alg.sig"
echo " public key (DER): $(wc -c < "$alg.pub.der") bytes, signature: $(wc -c < "$alg.sig") bytes"
doneAll three printed “Signature Verified Successfully”. The sizes were:
| Algorithm | Standard | Public key (DER file) | Signature |
|---|---|---|---|
| Ed25519 | Today’s; breaks under Shor | 44 bytes | 64 bytes |
| ML-DSA-65 | FIPS 204 | 1,974 bytes | 3,309 bytes |
| SLH-DSA-SHA2-128s | FIPS 205 | 50 bytes | 7,856 bytes |
This table explained the design to me better than the papers did. ML-DSA is the everyday signer: bigger than Ed25519, but balanced. SLH-DSA has a tiny key and a huge signature, the cost of resting on nothing but hash functions, and that’s exactly why it’s the backup.
On the same build, openssl list -kem-algorithms also lists X25519MLKEM768 and SecP256r1MLKEM768. These are
hybrids: they run a classic curve and ML-KEM together, so the connection stays safe if either one holds.
Where the new locks already run#
| Where | What it gives you |
|---|---|
Go crypto/tls | Since Go 1.24 the default TLS key exchange includes the hybrid X25519MLKEM768, unless you set CurvePreferences yourself |
| OpenSSL 3.5 | “The default TLS keyshares have been changed to offer X25519MLKEM768”. Distributions can change that: the OpenSSL 3.5.8 in my Ubuntu (under WSL) offered plain X25519 unless I asked |
| pyca/cryptography | 48.0.0 (May 2026) “Added support for ML-KEM key encapsulation and ML-DSA signing when using OpenSSL 3.5.0 or later” |
| mlkem-native | ML-KEM in C whose C code “is proved memory-safe”; used inside liboqs and AWS-LC |
| liboqs | The standards plus many candidates, for experiments; its README doesn’t recommend it for production yet |
| Cloudflare | By late 2025 the “majority of human-initiated traffic with Cloudflare is using post-quantum encryption” |
One check you can do right now: open pq.cloudflareresearch.com in your browser. It checks whether your connection to it used post-quantum key agreement. For a lot of web traffic the first lock is already being changed, quietly, by browser and library updates. Not everywhere, though: on 4 December 2026 GitHub still refused the hybrid when I offered nothing else, a story I tell in another post. The harder question is everything else I run, and who is helping with that.
Keywords#
| Keyword | Meaning here |
|---|---|
| KEM | Key-encapsulation mechanism: one side publishes a key, the other returns a sealed secret |
| Encapsulation key / ciphertext | ML-KEM’s public key, and the sealed envelope that carries the shared secret |
| ML-KEM-768 | The parameter set Go recommends for most applications |
| Hybrid key exchange | A classic curve and ML-KEM together (X25519MLKEM768), safe if either holds |
| DER | The binary encoding OpenSSL uses for keys; it adds a few bytes of labels around the raw key |
Next in this series: Who’s already working on it?
Takeaways#
- ML-KEM, ML-DSA and SLH-DSA run today in Go’s standard library and in OpenSSL 3.5, with no extra installs.
- ML-KEM still ends in a 32-byte secret for AES; what grows is the key and the ciphertext.
- ML-DSA is the everyday signer; SLH-DSA trades huge signatures for resting only on hashes.
- Hybrid ML-KEM is already the default in Go and OpenSSL TLS, so web traffic is changing without anyone asking.
References#
- Package crypto/mlkem: Go standard library documentation (go1.27.4); FIPS 203 quote, ML-KEM-768 advice, API and sizes used in the example
- Package crypto/tls: Go standard library documentation; X25519MLKEM768 in the default key exchange since Go 1.24
- OpenSSL 3.5 NEWS: OpenSSL project; 3.5.0 of 8 April 2025 adds ML-KEM, ML-DSA, SLH-DSA and the hybrid default keyshare
- pyca/cryptography changelog: ML-KEM and ML-DSA with OpenSSL 3.5 from 48.0.0
- mlkem-native: PQ Code Package; formally verified ML-KEM in C and its users
- RFC 7748, Elliptic Curves for Security: IRTF; X25519’s 32-byte keys
- liboqs: Open Quantum Safe; algorithm list and the production warning
- State of the post-quantum Internet in 2025: Cloudflare, October 2025; share of human-initiated traffic using post-quantum key agreement
- Post-Quantum Key Agreement at Cloudflare: Cloudflare Research; live connection check



