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.

MisconceptionReality
PKC is inherently more secureSecurity depends on key length and the work to break it; AES-256 is far stronger than RSA-512
PKC replaced symmetric encryptionPKC is 100–1,000× slower; hybrid systems use PKC to agree an AES session key
Key management is trivialPublic keys still need authentication: PKI and certificate authorities

Secrecy, authentication and both

GoalSender computesReceiver computesGives
SecrecyY = EKUb(X)X = DKRb(Y)Confidentiality only (anyone can encrypt to B)
AuthenticationY = EKRa(X)X = DKUa(Y)Origin and non-repudiation; no secrecy
BothZ = 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

  1. Key-pair generation is easy.
  2. Encryption with KUb is easy.
  3. Decryption with KRb is easy.
  4. Deriving KRb from KUb is infeasible.
  5. Recovering M from KUb and C is infeasible.
  6. (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)

  1. Keys: secret superincreasing a′, modulus m > Σa′i, multiplier w with gcd(w, m) = 1. Public ai = w·a′i mod m.
  2. Encrypt: S = Σxiai.
  3. 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.

SchemeHard problemStatus
RSAInteger factorisationSecure at ≥ 2,048 bits
Merkle–Hellman, Chor–RivestSubset sumBroken
McElieceDecoding random linear codesUnbroken; post-quantum candidate
ElGamal, Diffie–HellmanDiscrete logarithm in Zp*Secure at ≥ 2,048 bits
ECCElliptic-curve discrete logarithmSecure with much smaller keys