Skip to content
Post-Quantum Cryptography

Post-Quantum Cryptography

Since: cryptopp-modern 2026.3.0

Post-Quantum Cryptography (PQC) provides cryptographic algorithms designed to be secure against attacks by both classical and quantum computers. cryptopp-modern implements the NIST PQC standards FIPS 203, 204 and 205, the LMS and HSS stateful hash-based signatures of RFC 8554 and SP 800-208, and the X-Wing hybrid KEM from an Internet-Draft.

The examples on these pages show the library calls. They are not complete protocols: a real design also has to authenticate keys, bind context into key derivation and handle errors.

Why Post-Quantum Cryptography?

A sufficiently large quantum computer would change which algorithms are safe:

  • RSA, ECDSA, ECDH, Ed25519, X25519 - All would be broken by Shor’s algorithm
  • AES, SHA-2, SHA-3, BLAKE3 - Not broken; Grover’s algorithm gives a limited speed-up for key and preimage search, which larger keys and outputs absorb

The “Harvest Now, Decrypt Later” Threat: An adversary can record encrypted traffic today and decrypt it once a quantum computer exists. This is a threat to confidentiality, so it bears on key establishment first: data that must stay secret for many years is the case for adopting post-quantum key exchange early. Signatures are affected differently, since a signature only has to resist forgery while it is relied on.

Available Algorithms

Key Encapsulation (Key Exchange)

AlgorithmStandardSecurity BasisRecommended For
ML-KEMFIPS 203Module latticesPost-quantum key exchange to a published standard
X-WingInternet-DraftHybrid (X25519 + ML-KEM-768)Defence in depth where both ends implement the draft

Digital Signatures (Stateless)

AlgorithmStandardSecurity BasisRecommended For
ML-DSAFIPS 204Module latticesGeneral-purpose signatures
SLH-DSAFIPS 205Hash functionsConservative security (no lattice assumptions)

Digital Signatures (Stateful)

AlgorithmStandardSecurity BasisRecommended For
LMS/HSSRFC 8554, SP 800-208Hash functionsBounded signing (firmware, code signing, certificates)

Stateful schemes require explicit state management. Each signature consumes a one-time index that must never be reused. See the LMS/HSS page and the Stateful Signing Integration Guide for details.


Quick Comparison

Key Encapsulation Mechanisms

PropertyML-KEM-768X-WingX25519 (classical)
Public key1184 bytes1216 bytes32 bytes
Private key as held by this library2400 bytes2464 bytes32 bytes
Private key seed64 bytes32 bytesNot applicable
Ciphertext1088 bytes1120 bytes32 bytes (the sender’s public key)
Shared secret32 bytes32 bytes32 bytes
Secure against a quantum attackerYesYesNo
Security if lattices are brokenNoClassical only (X25519)Not applicable

Digital Signatures

PropertyML-DSA-65SLH-DSA-SHA2-128fHSS L=2 H5/W8Ed25519 (classical)
Public key1952 bytes32 bytes60 bytes32 bytes
Private key4032 bytes64 bytes48 bytes32 bytes
Signature3309 bytes17,088 bytes2,644 bytes64 bytes
Secure against a quantum attackerYesYesYesNo
Security basisLatticesHash functionsHash functionsElliptic curves
StatefulNoNoYesNo

cryptest b benchmarks ML-KEM, ML-DSA, X-Wing and two SLH-DSA sets (SLH-DSA-SHA2-128f and SLH-DSA-SHAKE-128f) on your own hardware; it has no LMS/HSS benchmark. As a guide to relative cost, SLH-DSA signing is far slower than ML-DSA signing, and the “s” SLH-DSA sets are slower to sign than the “f” sets.


Choosing the Right Algorithm

For a worked decision tree covering hybrid vs pure post-quantum key exchange and signature selection, see Post-Quantum Cryptography: Choosing an Algorithm.

In summary:

  • Key encapsulation: X-Wing is designed to stay secure if either X25519 or ML-KEM-768 is broken, and suits systems where you control both ends. Use ML-KEM directly where FIPS 203 is required or a post-quantum-only design is acceptable.
  • Stateless signatures: ML-DSA-65 covers the general case. Pick SLH-DSA when you want hash-only security and can accept larger signatures.
  • Stateful signatures: LMS/HSS for bounded signing volumes where you can manage signer state durably. See LMS/HSS and the Stateful Signing Guide.
  • Category 5: ML-KEM-1024, ML-DSA-87 or the SLH-DSA 256 sets.

Security Categories

NIST defines five security categories by comparison with a generic attack on a symmetric primitive:

CategoryComparable toAlgorithms
1Key search on AES-128ML-KEM-512, SLH-DSA 128 sets
2Collision search on SHA-256ML-DSA-44
3Key search on AES-192ML-KEM-768, ML-DSA-65, SLH-DSA 192 sets
5Key search on AES-256ML-KEM-1024, ML-DSA-87, SLH-DSA 256 sets

ML-KEM-768 and ML-DSA-65, both category 3, are common general-purpose choices.


Quick Examples

Hybrid Key Exchange with X-Wing

#include <cryptopp/xwing.h>
#include <cryptopp/osrng.h>
#include <cryptopp/secblock.h>
#include <iostream>

int main() {
    using namespace CryptoPP;

    // Recipient generates key pair
    AutoSeededRandomPool rng;
    XWingDecapsulator recipient(rng);

    // Extract public key to send to sender
    SecByteBlock publicKey(recipient.GetKey().GetPublicKeySize());
    recipient.GetKey().GetPublicKey(publicKey.begin());

    // Sender encapsulates (creates shared secret + ciphertext)
    XWingEncapsulator sender(publicKey.begin(), publicKey.size());
    SecByteBlock ciphertext(sender.CiphertextLength());
    SecByteBlock senderSecret(sender.SharedSecretLength());
    sender.Encapsulate(rng, ciphertext.begin(), senderSecret.begin());

    // Recipient decapsulates to get the same shared secret
    SecByteBlock recipientSecret(recipient.SharedSecretLength());
    recipient.Decapsulate(ciphertext.begin(), recipientSecret.begin());

    bool same = (senderSecret == recipientSecret);
    std::cout << "Shared secrets match: " << (same ? "YES" : "NO") << std::endl;

    return same ? 0 : 1;
}

Derive session keys from the shared secret with a KDF; see Using with a KDF.

Post-Quantum Signatures with ML-DSA

#include <cryptopp/mldsa.h>
#include <cryptopp/osrng.h>
#include <cryptopp/secblock.h>
#include <iostream>
#include <string>

int main() {
    using namespace CryptoPP;

    AutoSeededRandomPool rng;

    // Generate key pair
    MLDSASigner<MLDSA_65> signer(rng);
    MLDSAVerifier<MLDSA_65> verifier(signer);

    // Sign a message
    std::string message = "Important document";
    SecByteBlock signature(signer.SignatureLength());
    size_t sigLen = signer.SignMessage(rng,
        (const byte*)message.data(), message.size(),
        signature.begin());

    // Verify the signature
    bool valid = verifier.VerifyMessage(
        (const byte*)message.data(), message.size(),
        signature.begin(), sigLen);

    std::cout << "Signature valid: " << (valid ? "YES" : "NO") << std::endl;

    return valid ? 0 : 1;
}

Migration Strategy

Hybrid first

A hybrid combines a classical and a post-quantum algorithm so that an attacker has to break both:

  • Key exchange: X-Wing (X25519 + ML-KEM-768)
  • Signatures: two signatures, for example Ed25519 and ML-DSA, with both required to verify

If a weakness is found in the newer post-quantum algorithm, the classical one still protects against today’s attackers.

Post-quantum only

Where a published standard is required, or the classical algorithm is no longer wanted:

  • Key exchange: ML-KEM-768 or ML-KEM-1024
  • Signatures: ML-DSA, SLH-DSA or LMS/HSS

What to move first

Data that must stay confidential for many years is exposed to recorded-traffic attacks today, so its key establishment is the first candidate. Long-lived signing keys, such as firmware roots of trust and certificate authorities, come next because they are slow to replace.


Thread Safety

PQC class instances are not thread-safe. Use one instance per thread:

void signInThread(const byte* privateKey, size_t privateKeyLen) {
    AutoSeededRandomPool rng;
    MLDSASigner<MLDSA_65> signer(privateKey, privateKeyLen);  // One per thread
    // ... sign ...
}

Stateful LMS/HSS signers have additional rules; see the LMS/HSS page.


Algorithm Details

ML-KEM (FIPS 203)

Module-Lattice-Based Key-Encapsulation Mechanism, derived from CRYSTALS-Kyber.

  • Three parameter sets: ML-KEM-512, ML-KEM-768, ML-KEM-1024
  • IND-CCA2 design with implicit rejection
  • ML-KEM-768 for most applications

ML-DSA (FIPS 204)

Module-Lattice-Based Digital Signature Algorithm, derived from CRYSTALS-Dilithium.

  • Three parameter sets: ML-DSA-44, ML-DSA-65, ML-DSA-87
  • Designed to be strongly unforgeable (SUF-CMA); randomised signing
  • ML-DSA-65 for most applications

SLH-DSA (FIPS 205)

Stateless Hash-Based Digital Signature Algorithm, based on SPHINCS+.

  • 12 parameter sets: SHA2 or SHAKE, three security categories, fast or small
  • Security based only on hash function properties
  • SLH-DSA-SHA2-128f for faster signing, SLH-DSA-SHA2-128s for smaller signatures

LMS/HSS (RFC 8554, SP 800-208)

Stateful hash-based signatures.

  • Small signatures for a hash-based scheme, with a fixed number of signatures per key
  • Signer state must never be reused or rolled back

X-Wing

Hybrid key encapsulation combining X25519 and ML-KEM-768.

  • Designed to be secure if either algorithm is secure
  • Specified in an Internet-Draft; not yet an RFC

Standards

AlgorithmSpecificationStatus
ML-KEMFIPS 203Final (13 August 2024)
ML-DSAFIPS 204Final (13 August 2024)
SLH-DSAFIPS 205Final (13 August 2024)
LMS/HSSRFC 8554, NIST SP 800-208Published (2019, 2020)
X-Wingdraft-connolly-cfrg-xwing-kemInternet-Draft

See Also

References

  1. FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard
  2. FIPS 204: Module-Lattice-Based Digital Signature Standard
  3. FIPS 205: Stateless Hash-Based Digital Signature Standard
  4. NIST SP 800-208: Recommendation for Stateful Hash-Based Signature Schemes
  5. RFC 8554: Leighton-Micali Hash-Based Signatures
  6. X-Wing: general-purpose hybrid post-quantum KEM (draft-connolly-cfrg-xwing-kem)