Three ways to keep a secret

RSA and ECC rely on a hard math problem. Post-quantum cryptography swaps in harder ones. Quantum key cryptography drops the math entirely and lets physics guard the secret.

RSA and ECC1977, 1985 · factoring, elliptic curves PQC2024 · lattices, hash functions QKC1984 to today · quantum states, single photons

Foundations

What cryptography is for, the hard problems it rests on, and why quantum computers change the picture.

Cryptography is the quiet layer under almost every digital system: it protects data in transit and at rest, proves who you are talking to, and makes tampering detectable.

GoalQuestion it answersTypical tools
ConfidentialityCan only the intended party read it?AES-GCM, ChaCha20-Poly1305, key exchange
IntegrityWas it changed on the way?MACs (HMAC), AEAD tags, hashes
AuthenticationWho sent it, who am I talking to?Digital signatures, certificates, MACs
Non-repudiationCan the signer later deny it?Digital signatures with trusted timestamps

Where it lives in real infrastructure

SystemCryptography insideQuantum-vulnerable part
HTTPS / TLSECDHE key exchange, certificate signatures, AES-GCMKey exchange, signatures
SSH, VPN (IPsec, WireGuard)Diffie–Hellman, host and user keys, symmetric tunnelsKey exchange, authentication keys
PKI and code signingCA hierarchies, RSA/ECDSA signatures on certificates and softwareAll signatures
Payments, smart cards, eSIMSymmetric keys in secure elements, RSA/ECC for provisioningProvisioning and card authentication
Disk and database encryptionAES with keys wrapped by other keysOnly if key wrapping uses RSA/ECC
DNSSEC, email (S/MIME, PGP)Signatures, public-key encryptionSignatures and encryption

From classical to modern

  1. Antiquity – 1800s: substitution and transposition ciphers (Caesar, Vigenère). Security came from keeping the method secret.
  2. 1883: Kerckhoffs' principle — a system must stay secure even if everything except the key is public.
  3. 1920s–1940s: rotor machines such as Enigma; their breaking showed that weak key handling and operator habits defeat strong machines.
  4. 1949: Shannon's information theory of secrecy: the one-time pad is perfectly secure, but needs a key as long as the message.
  5. 1976–1977: Diffie–Hellman key exchange and RSA create public-key cryptography; DES becomes the first public encryption standard.
  6. 1984–1985: BB84 quantum key distribution; elliptic-curve cryptography proposed by Koblitz and Miller.
  7. 1994–1996: Shor's and Grover's quantum algorithms show that quantum computers would break RSA/ECC and weaken brute-force resistance.
  8. 2001: AES replaces DES. 2015: SHA-3 standardized.
  9. 2016–2024: NIST's public PQC competition; FIPS 203, 204 and 205 published in August 2024.

Symmetric and asymmetric models

SymmetricAsymmetric (public-key)
KeysOne shared secret keyA public and private key pair
SpeedVery fast, hardware-accelerated (gigabytes per second)Much slower; used on small values
Main jobEncrypt and authenticate bulk dataEstablish keys, sign, authenticate
Key distributionHard: the key must be shared secretly firstEasy: the public key can be published
Keys needed for N usersN(N−1)/2 pairwise keysN key pairs
ExamplesAES, ChaCha20, HMAC, SHA-2/3RSA, ECDH, ECDSA, ML-KEM, ML-DSA
Quantum impactGrover halves effective strength — use 256-bit keysShor breaks RSA/ECC — replace with PQC

Real workflows combine them. Asymmetric cryptography sets up or authenticates a short secret; symmetric cryptography carries the data:

1. Key exchangeECDH / ML-KEM
shared secret
2. Derive keysHKDF
session keys
3. Encrypt dataAES-GCM

Constructing a key exchange

Diffie–Hellman lets two systems agree on a secret over a public network. Both agree on a prime p and generator g; each picks a private number, publishes g^private mod p, and raises the other side's value to its own private number. Both arrive at g^(ab) mod p. An eavesdropper sees p, g, A, B — recovering a or b is the discrete logarithm problem.

Simulate a key exchange between two systems

Change the private keys. The shared secret is then fed to a key-derivation function (here real SHA-256, as inside HKDF) to produce a 128-bit session key.

Unauthenticated DH is open to man-in-the-middle. Mallory can run one exchange with Alice and another with Bob. That is why TLS signs the exchange with the server's certificate key. Real DH uses 2048-bit+ groups or elliptic curves (X25519) — and both fall to Shor's algorithm, which is why ML-KEM is replacing them.

Hard mathematical problems

Public-key cryptography needs one-way functions with a trapdoor: easy to compute, hard to invert, easy again with a secret.

ProblemUsed byBest classical attackQuantum status
Integer factorizationRSAGeneral number field sieve, sub-exponentialShor: polynomial
Discrete logarithm mod pDiffie–Hellman, DSANumber field sieve, sub-exponentialShor: polynomial
Elliptic-curve discrete logECDH, ECDSA, EdDSAPollard's rho, fully exponential (√ of group size)Shor: polynomial
Module-LWE, Module-SISML-KEM, ML-DSALattice reduction (BKZ), exponentialNo known speedup beyond small factors
Syndrome decodingClassic McEliece, HQCInformation-set decoding, exponentialOnly Grover-type speedup
Hash preimage / collisionSLH-DSA, LMS, XMSSGeneric searchGrover: square-root speedup only

What RSA and ECC actually assume

  • RSA assumption: computing e-th roots modulo n is hard. Factoring n breaks it; whether breaking it requires factoring is not proven.
  • Diffie–Hellman assumptions: computing gab from ga, gb (CDH) — and even distinguishing it from random (DDH) — is hard. Both reduce to, but may be easier than, the discrete log.
  • Parameter assumptions: primes are random and large, curves are well-chosen, randomness is good. Most real breaks violate these rather than the math.

Complexity theory in cryptographic security

ClassMeaningRelevance
PSolvable in polynomial time on a classical computerWhat defenders do: encrypt, sign, verify
NPSolutions verifiable in polynomial timeFactoring and discrete log are in NP, but are not believed NP-complete
BQPSolvable in polynomial time on a quantum computerContains factoring and discrete log (Shor) — the root of the quantum threat
  • No security is proven absolutely. We do not even know whether one-way functions exist (it would imply P ≠ NP). Security means "no efficient attack is known after years of public scrutiny".
  • Reductions: a scheme is "provably secure" if breaking it would solve a well-studied hard problem. The proof is only as good as the problem and the model.
  • Average case matters: cryptography needs problems that are hard for random instances, not just the worst case. Lattice problems are special: Ajtai and Regev linked average-case LWE to worst-case lattice problems.
  • Security level: "128-bit security" means the best known attack takes about 2¹²⁸ operations.

How attack cost scales with key size

Approximate work (log₂ operations) to break RSA with the classical number field sieve, compared with a rough cubic gate count for Shor's algorithm. Drag to pick a key size.

Classical cost grows sub-exponentially, so doubling the key adds a lot of security. Shor's cost grows only polynomially, so bigger RSA keys buy almost nothing once a large quantum computer exists. Figures are order-of-magnitude estimates.

Simulate a factoring attack on RSA-like keys

Enter a public modulus n and exponent e. The attacker factors n with Pollard's rho, rebuilds the private key, and decrypts. Try n = 3233 (61 × 53), then larger values like 1000000016000000063.

Cryptographic failures and their lessons

IncidentWhat went wrongLesson
Debian OpenSSL (2008)A code cleanup removed entropy; only ~32,768 possible keys were generated for two yearsRandomness is a single point of failure
Sony PS3 (2010)ECDSA signatures reused the same nonce, revealing the console's private signing keyNonces must never repeat; prefer deterministic or hedged signing
Heartbleed (2014)A missing bounds check in OpenSSL leaked server memory, including private keysImplementation bugs bypass strong math
Logjam, FREAK (2015)Servers could be downgraded to weak "export-grade" DH and RSARemove weak options; resist downgrades
ROCA (2017)A smart-card library generated RSA primes with structure, making millions of keys factorableKey generation needs review as much as algorithms
SHAttered (2017)First practical SHA-1 collision, after warnings since 2005Migrate when weaknesses appear, not when attacks are cheap
Dual_EC_DRBG (2013)A standardized random generator was believed to contain a backdoorDemand transparent parameter choices
SIKE (2022)A PQC finalist broken in about an hour on a laptop by a new mathematical attackNew assumptions need years of scrutiny; keep hybrid and crypto-agile

The pattern repeats: algorithms rarely fail first. Randomness, implementation, configuration and slow migration do. PQC migration will be judged by the same lessons.