RandomKeygen
13 min read
GUIDEENCRYPTION

ML-KEM vs. ML-DSA vs. SLH-DSA vs. X-Wing: Choosing the Right Post-Quantum Algorithm

A side-by-side engineering comparison of NIST FIPS 203, FIPS 204, FIPS 205, and IETF hybrid X-Wing—covering exact byte budgets, lattice vs. hash-only assumptions, and where each algorithm fits in production.

Quick decision table: which PQC algorithm to pick

Post-quantum cryptography splits cleanly into two jobs—key establishment (KEM) and digital signatures—just like classical ECDH and ECDSA. The four standards developers actually deploy map directly to four concrete use cases:

If you need to…PickWhyTry Locally
Establish keys for web apps, HPKE, or file encryptionX-Wing (ML-KEM-768 + X25519)Defense-in-depth hybrid; 32-byte seed; secure if either ECC or lattice holds.X-Wing Generator →
Meet NSA CNSA 2.0 key establishment mandatesML-KEM-1024 (FIPS 203)Category 5 (~AES-256) pure PQ KEM with RFC 9935 / OpenSSL 3.5+ PEM support.ML-KEM Generator →
Sign TLS certs, APIs, packages, or CNSA 2.0 artifactsML-DSA-87 / ML-DSA-65 (FIPS 204)Fast signing & verification with manageable 3.3–4.6 KB signatures.ML-DSA Generator →
Anchor 20-year Root CAs or firmware with zero lattice riskSLH-DSA (FIPS 205)Pure hash-based math (SHA-2 / SHAKE256), stateless, tiny 32–64 B public keys.SLH-DSA Generator →

Complete key, ciphertext & signature size matrix

Use this reference table when sizing database columns, ASN.1 certificates, HTTP headers, and wire frames:

AlgorithmRoleMath BasisPublic KeyPrivate KeyCiphertext / SigQuantum Safe?
X25519 (Classical ECDH)Key ExchangeElliptic Curve32 B32 B32 B (ephemeral)No
Ed25519 (Classical Sig)SignatureElliptic Curve32 B32 B seed64 B sigNo
RSA-4096 (Classical)KEM / SigFactoring512 B~2.3 KB512 BNo
ML-KEM-768 (FIPS 203)KEMModule Lattice1,184 B64 B seed (2,400 B exp)1,088 B ctYes (L3)
ML-KEM-1024 (CNSA 2.0)KEMModule Lattice1,568 B64 B seed (3,168 B exp)1,568 B ctYes (L5)
X-Wing (ML-KEM-768+X25519)Hybrid KEMLattice + ECC1,216 B32 B seed1,120 B ctYes (Hybrid)
ML-KEM-1024 + P-384Hybrid KEMLattice + ECC1,665 B32 B seed1,665 B ctYes (CNSA Bridge)
ML-DSA-65 (FIPS 204)SignatureModule Lattice1,952 B32 B seed (4,032 B exp)3,309 B sigYes (L3)
ML-DSA-87 (CNSA 2.0)SignatureModule Lattice2,592 B32 B seed (4,896 B exp)4,627 B sigYes (L5)
SLH-DSA-SHA2-128s (FIPS 205)SignatureHash-Only (SHA-2)32 B64 B7,856 B sigYes (L1)
SLH-DSA-SHA2-256s (FIPS 205)SignatureHash-Only (SHA-2)64 B128 B29,792 B sigYes (L5)
SLH-DSA-SHA2-256f (FIPS 205)SignatureHash-Only (SHA-2)64 B128 B49,856 B sigYes (L5)

Key exchange: Pure ML-KEM vs. Hybrid X-Wing

ML-KEM (FIPS 203) is fast and standardized, and ML-KEM-1024 is the mandatory CNSA 2.0 choice. So why does X-Wing (ML-KEM-768 + X25519) exist?

  • Hedging against unexpected cryptanalysis: Elliptic curves have been battle-tested for decades against classical attacks, while structured lattices are newer. X-Wing combines both shared secrets with SHA3-256 so an attacker must break both X25519 and ML-KEM-768 to recover the session key.
  • Negligible overhead: Adding X25519 to ML-KEM-768 adds only 32 bytes to the public key (1,184 B → 1,216 B) and 32 bytes to the ciphertext (1,088 B → 1,120 B), while shrinking the private seed to just 32 bytes.
  • CNSA Bridge option: For regulated environments transitioning from CNSA 1.0 to CNSA 2.0, ML-KEM-1024 + P-384 combines NIST P-384 with ML-KEM-1024 in one exchange (available on our X-Wing & Hybrid KEM Generator).

Signatures: Lattice ML-DSA vs. Hash-only SLH-DSA

Both ML-DSA (FIPS 204) and SLH-DSA (FIPS 205) are stateless post-quantum digital signature schemes—you can sign millions of messages safely without tracking a monotonic counter (unlike stateful LMS/XMSS, where reusing a state index catastrophically leaks the private key).

  • Pick ML-DSA when size and speed matter: ML-DSA-87 signs and verifies in fractions of a millisecond with 4.6 KB signatures—roughly 6–10× smaller than SLH-DSA-256. It is the default for TLS certificates, signed APIs, and CNSA 2.0.
  • Pick SLH-DSA when cryptographic conservatism matters most: SLH-DSA's security reduces strictly to the collision/preimage resistance of SHA-2 or SHAKE256—no lattices, no new algebra. Its public keys are only 32–64 bytes (great for hardware ROM / root anchors), trading off much larger 7.8–49.9 KB signatures.
Fast (-f) vs. Small (-s) in SLH-DSA: Every SLH-DSA security tier ships in two profiles: -f (fast signing, larger signatures—good for CI/CD signing) and -s (smaller signatures, slower signing—good for offline Root CAs and infrequently signed firmware images).

Protocol wire budgets (TLS, JWTs, Cookies, DNSSEC, DB columns)

  • Browser Cookies (4,096-byte cap): An ML-DSA-87 signature alone is 4,627 bytes raw (~6.1 KB Base64URL), meaning an asymmetric ML-DSA JWT will not fit in a single browser cookie. Use opaque random session tokens (OAuth Token Generator) or symmetric HS384/HS512 cookies (JWT Secret Generator) instead.
  • HTTP Headers (typically 8–16 KB limit): Passing ML-DSA-87 tokens in Authorization headers can push reverse proxies (Nginx/Envoy/ALB) near default 8 KB header buffers—test header limits before rolling out asymmetric PQC tokens.
  • TLS 1.3 Certificate Chains: A 3-cert ML-DSA-87 chain adds ~20+ KB to the handshake compared to ~2 KB for ECDSA. Keep chains shallow (leaf + intermediate) and ensure TCP/QUIC initial congestion windows handle the larger flight cleanly.
  • Database Schemas: Audit any column typed VARCHAR(255) or VARCHAR(1024) storing public keys, PEMs, or detached signatures—use TEXT or BYTEA/BLOB for cryptographic agility.

Reference envelope encryption pattern (X-Wing + AES-256-GCM)

Remember: KEMs never encrypt your files or JSON directly—they establish a fresh 256-bit symmetric key that feeds AES-256-GCM:

TypeScript · Hybrid PQC Envelope Encryption
// Modern post-quantum envelope encryption: X-Wing KEM + AES-256-GCM
import { ml_kem768_x25519 } from '@noble/post-quantum/hybrid.js'

async function sealPayload(plaintext: Uint8Array, recipientPublicKey: Uint8Array) {
  // 1. Hybrid KEM derives a fresh 256-bit shared secret (secure if X25519 OR ML-KEM-768 holds)
  const { cipherText: kemCipherText, sharedSecret } = ml_kem768_x25519.encapsulate(recipientPublicKey)

  // 2. Import the 32-byte shared secret directly as an AES-256-GCM key
  const aesKey = await crypto.subtle.importKey('raw', sharedSecret, 'AES-GCM', false, ['encrypt'])
  const nonce = crypto.getRandomValues(new Uint8Array(12))

  // 3. Encrypt bulk data with quantum-safe AES-256-GCM
  const encrypted = new Uint8Array(
    await crypto.subtle.encrypt({ name: 'AES-GCM', iv: nonce }, aesKey, plaintext)
  )

  return { kemCipherText, nonce, encrypted }
}

Frequently asked questions

Can I put an ML-DSA-87 JWT inside an HTTP cookie?

No—an ML-DSA-87 signature is 4,627 bytes raw (~6.1 KB Base64URL), exceeding the ~4 KB per-cookie browser limit. Use server-side opaque session IDs or symmetric HMAC-SHA384/SHA512 (which are already quantum-safe and compact) for cookies.

Is SLH-DSA part of NSA CNSA 2.0?

CNSA 2.0 currently specifies ML-DSA-87 for general signatures and stateful LMS / XMSS for firmware/software signing. NIST standardized SLH-DSA (FIPS 205) as the stateless hash-based alternative for commercial, archival, and long-lived PKI use cases where stateful counter management is risky.