NIST FIPS 203 / 204 / 205

Post-Quantum Cryptography in Pure Go

Three independent, spec-faithful implementations of the NIST post-quantum standards. No CGO, no assembly, constant-time arithmetic. Ready for the post-ECDLP era.

ACVP Vectors 606/606 Field Ops Verified 33M+ Adversarial Attacks 0 breaks
View on GitHub See the Code
The Quantum Threat

ECDLP is broken in 9 minutes.

In March 2026, Google Quantum AI demonstrated that Shor's algorithm can break the 256-bit Elliptic Curve Discrete Logarithm on secp256k1 with dramatically fewer resources than previously estimated. On-spend attacks on Bitcoin and Ethereum transactions are within reach of near-term quantum hardware.

<1,200
logical qubits
To break secp256k1 via Shor's algorithm
~9
minutes
Key derivation on superconducting architecture
500K
physical qubits
Estimated hardware requirement
6.9M
BTC vulnerable
Exposed via P2PK, P2TR, and address reuse

Three Standards. One Library.

Each package is self-contained, independently testable, and faithful to the NIST specification.

FIPS 203
ML-KEM
Module-Lattice Key Encapsulation
Lattice (MLWE)

Establish shared secret keys over insecure channels. Replaces ECDH key exchange with quantum-resistant lattice-based key encapsulation using the Fujisaki-Okamoto transform.

ML-KEM-512   ek: 800B   ct: 768B
ML-KEM-768   ek: 1184B   ct: 1088B
ML-KEM-1024   ek: 1568B   ct: 1568B
FIPS 204
ML-DSA
Module-Lattice Digital Signatures
Lattice (MLWE + MSIS)

Sign and verify messages with quantum-resistant digital signatures. Replaces ECDSA and Schnorr signatures using Fiat-Shamir with Aborts over module lattices.

ML-DSA-44   pk: 1312B   sig: 2420B
ML-DSA-65   pk: 1952B   sig: 3309B
ML-DSA-87   pk: 2592B   sig: 4627B
FIPS 205
SLH-DSA
Stateless Hash-Based Signatures
Hash Functions Only

The most conservative post-quantum choice. Security relies purely on SHAKE-256 hash properties -- no algebraic structure for quantum algorithms to exploit. Uses WOTS+, FORS, XMSS, and hypertree layers.

SHAKE-128f   pk: 32B   sig: 17KB
SHAKE-192f   pk: 48B   sig: 36KB
SHAKE-256f   pk: 64B   sig: 50KB

Simple API. Serious Crypto.

Drop-in Go packages. No configuration required.

import "github.com/jiayaoqijia/altpq/mlkem"

// Generate a keypair
dk, err := mlkem.GenerateKey768(rand.Reader)
ek := dk.EncapsulationKey()

// Sender: encapsulate a shared secret
sharedKey, ciphertext := ek.Encapsulate()

// Receiver: decapsulate to recover the shared secret
sharedKey2, err := dk.Decapsulate(ciphertext)
// sharedKey == sharedKey2 (32 bytes)
import "github.com/jiayaoqijia/altpq/mldsa"

// Generate a keypair
pk, sk, err := mldsa.GenerateKey65(rand.Reader)

// Sign a message
sig, err := sk.Sign(rand.Reader, message, nil)

// Verify the signature
ok := pk.Verify(message, sig)
// ok == true
import "github.com/jiayaoqijia/altpq/slhdsa"

// Generate a keypair (SHAKE-128f for speed)
sk, pk, err := slhdsa.GenerateKey(slhdsa.SHAKE_128f, rand.Reader)

// Sign a message
sig, err := sk.Sign(rand.Reader, message, nil)

// Verify the signature
ok := pk.Verify(message, sig)
// ok == true
# Install the library
$ go get github.com/jiayaoqijia/altpq

# Run tests
$ go test ./mlkem/ ./mldsa/ -timeout 120s
$ go test ./slhdsa/ -timeout 300s

# Requires Go 1.25+
# Only dependency: golang.org/x/crypto (SHA-3/SHAKE)

When to Use Which

ML-KEM (FIPS 203) ML-DSA (FIPS 204) SLH-DSA (FIPS 205)
Purpose Key exchange Digital signatures Digital signatures
Hardness Lattice (MLWE) Lattice (MLWE + MSIS) Hash functions only
Speed Fast Moderate Slow (signing)
Signature Size n/a 2.4 - 4.6 KB 7.8 - 50 KB
Confidence High High Highest (minimal assumptions)
Best For TLS, encrypted comms Code signing, certificates Long-term signatures, max security

Built for Ethereum's PQC Migration

The Ethereum Foundation has elevated post-quantum security to a top strategic priority, targeting L1 upgrades by 2029. altpq implements the algorithms they're evaluating.

Execution Layer

Dilithium = ML-DSA

Ethereum's execution layer roadmap evaluates Dilithium for transaction signatures. Dilithium is now standardized as ML-DSA (FIPS 204) -- the exact algorithm implemented in altpq's mldsa package.

Execution Layer

SPHINCS+ = SLH-DSA

SPHINCS+ is under evaluation as the conservative fallback. It's now standardized as SLH-DSA (FIPS 205) -- implemented in altpq's slhdsa package with all 6 SHAKE parameter sets.

Account Abstraction

EIP-7702 + PQ Signatures

Account abstraction allows Ethereum accounts to use arbitrary signature schemes. altpq's ML-DSA and SLH-DSA can serve as drop-in PQ signature verifiers for smart contract wallets.

Key Exchange

ML-KEM for Encrypted Channels

Validator communication, L2 bridges, and encrypted messaging channels can adopt ML-KEM (FIPS 203) to replace ECDH-based key agreement with quantum-resistant key encapsulation.

Get Started

go get github.com/jiayaoqijia/altpq

Go 1.25+ · Single dependency · Pure Go · BSD-3-Clause