Learn › Blockchain & Access Control › Module 2 · Public-key cryptography
Public-key principles, trapdoors and the Merkle–Hellman knapsack
Origins of public-key cryptography, three misconceptions, secrecy and signature modes, the six Diffie–Hellman requirements, trapdoor one-way functions, subset sum, superincreasing knapsacks and a full Merkle–Hellman example.
Origins and three misconceptions
Diffie and Hellman, “New Directions in Cryptography” (1976), introduced public-key cryptography to solve two symmetric-key problems: key distribution without a prior secret channel and digital signatures.
| Misconception | Reality |
|---|---|
| PKC is inherently more secure | Security depends on key length and the work to break it; AES-256 is far stronger than RSA-512 |
| PKC replaced symmetric encryption | PKC is 100–1,000× slower; hybrid systems use PKC to agree an AES session key |
| Key management is trivial | Public keys still need authentication: PKI and certificate authorities |
Secrecy, authentication and both
| Goal | Sender computes | Receiver computes | Gives |
|---|---|---|---|
| Secrecy | Y = EKUb(X) | X = DKRb(Y) | Confidentiality only (anyone can encrypt to B) |
| Authentication | Y = EKRa(X) | X = DKUa(Y) | Origin and non-repudiation; no secrecy |
| Both | Z = EKUb[EKRa(X)] | X = DKUa[DKRb(Z)] | Both, at four public-key operations |
In practice one signs a hash of the document (hash-then-sign), not the whole document. Applications: encryption, signatures, key exchange. RSA does all three; Diffie–Hellman only key exchange; DSA only signatures.
Requirements and trapdoor one-way functions
- Key-pair generation is easy.
- Encryption with KUb is easy.
- Decryption with KRb is easy.
- Deriving KRb from KUb is infeasible.
- Recovering M from KUb and C is infeasible.
- (Useful) either key can be applied first.
“Easy” = polynomial in the input bit-length; “infeasible” = super-polynomial. A one-way function is easy to compute and infeasible to invert for everyone. A trapdoor one-way function fk becomes easy to invert for whoever knows the trapdoor k.
Subset sum and superincreasing sequences
Given weights a1…an and target S, find x ∈ {0,1}n with Σaixi = S. The general problem is NP-complete. Toy: (455, 341, 284, 132, 82, 56), S = 821 ⇒ 455 + 284 + 82, x = (1,0,1,0,1,0).
A sequence is superincreasing if each term exceeds the sum of all earlier ones. Then a greedy pass from the largest term solves it in O(n): take ai if S ≥ ai and subtract.
Worked example
a′ = (171, 197, 459, 1191, 2410), S = 3798: take 2410 (1388 left), take 1191 (197), skip 459, take 197 (0), skip 171 ⇒ x = (0, 1, 0, 1, 1).
Merkle–Hellman knapsack (1978)
- Keys: secret superincreasing a′, modulus m > Σa′i, multiplier w with gcd(w, m) = 1. Public ai = w·a′i mod m.
- Encrypt: S = Σxiai.
- Decrypt: S′ = w−1S mod m = Σxia′i (exact, because m exceeds the sum), then solve greedily.
Worked example
a′ = (2, 5, 9, 21, 45, 103, 215, 450, 946) (sum 1796), m = 2003, w = 1289, w−1 = 317.
Public key a = (575, 436, 1586, 1030, 1921, 569, 721, 1183, 1570).
x = (1,0,1,1,0,0,1,1,1) ⇒ S = 575 + 1586 + 1030 + 721 + 1183 + 1570 = 6665.
S′ = 317 × 6665 mod 2003 = 1643; greedy over a′ takes 946, 450, 215, 21, 9, 2 ⇒ x recovered.
Cryptanalysis and the PKC landscape
Shamir broke the basic Merkle–Hellman scheme in polynomial time (1982); lattice-reduction (LLL) attacks later broke most knapsack variants, because the modular disguise leaks structure.
| Scheme | Hard problem | Status |
|---|---|---|
| RSA | Integer factorisation | Secure at ≥ 2,048 bits |
| Merkle–Hellman, Chor–Rivest | Subset sum | Broken |
| McEliece | Decoding random linear codes | Unbroken; post-quantum candidate |
| ElGamal, Diffie–Hellman | Discrete logarithm in Zp* | Secure at ≥ 2,048 bits |
| ECC | Elliptic-curve discrete logarithm | Secure with much smaller keys |