↓ Skip to main content
Security

Holding the new locks in my hand

Getting ready for quantum computers - This article is part of a series.
Part 2: This Article
I can read about a lock all day. I only trust it once I’ve turned the key myself. So before looking for the old locks in my code, I ran the new ones on my own machine.
Left: a Go program using crypto/mlkem. Alice publishes a 1,184-byte public key, Bob returns a 1,088-byte ciphertext, and both end with the same 32-byte secret. Right: signing one file with OpenSSL 3.5. Ed25519: 44-byte public key, 64-byte signature. ML-DSA-65: 1,974 and 3,309 bytes. SLH-DSA-SHA2-128s: 50 and 7,856 bytes. Bottom: where the new locks already run: Go TLS, OpenSSL 3.5, pyca/cryptography, mlkem-native, liboqs, Cloudflare.
The new locks, measured

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:   true

Two 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"
done

All three printed “Signature Verified Successfully”. The sizes were:

AlgorithmStandardPublic key (DER file)Signature
Ed25519Today’s; breaks under Shor44 bytes64 bytes
ML-DSA-65FIPS 2041,974 bytes3,309 bytes
SLH-DSA-SHA2-128sFIPS 20550 bytes7,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
#

WhereWhat it gives you
Go crypto/tlsSince 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/cryptography48.0.0 (May 2026) “Added support for ML-KEM key encapsulation and ML-DSA signing when using OpenSSL 3.5.0 or later”
mlkem-nativeML-KEM in C whose C code “is proved memory-safe”; used inside liboqs and AWS-LC
liboqsThe standards plus many candidates, for experiments; its README doesn’t recommend it for production yet
CloudflareBy 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
#

KeywordMeaning here
KEMKey-encapsulation mechanism: one side publishes a key, the other returns a sealed secret
Encapsulation key / ciphertextML-KEM’s public key, and the sealed envelope that carries the shared secret
ML-KEM-768The parameter set Go recommends for most applications
Hybrid key exchangeA classic curve and ML-KEM together (X25519MLKEM768), safe if either holds
DERThe 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
#

Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.
Getting ready for quantum computers - This article is part of a series.
Part 2: This Article

Related

My antivirus answered for GitHub

··7 mins
I wrote a small program to check whether GitHub already uses post-quantum key exchange. It said yes. I was about to write that down as a fact when a different tool gave me a different answer, and the reason was sitting on my own machine. Two connections, one of them hidden A result that looked too good # While writing about the locks I use without noticing I wanted one line of evidence: which key exchange does a real site use today? Go makes that easy. Since Go 1.25 a connection reports the key-exchange group it used, and Python can do the same since 3.15, so this is the whole program in either:

Saved today, read tomorrow

In 1943 the US Army started keeping copies of Soviet telegrams it couldn’t read. Some of them were read years later, and they named spies. I think of that story every time someone tells me quantum computers are “still years away”. If names like RSA, X25519 or ECDSA are new to you, the primer explains what each one does, in plain words.

The locks I use without noticing

··9 mins
I type gh pr list dozens of times a day. The answer comes back in under a second from a server I’ve never met, and nobody in between can read it or change it. One evening I got curious about what actually happens in that second. Three jobs, four families Following one command onto the wire # First, where does gh go? Its debug switch shows every request: