> PGP — PRETTY GOOD PRIVACY
The idea in plain English: PGP (Pretty Good Privacy) lets anyone encrypt a message so that only the intended recipient can read it — without having exchanged a secret key beforehand. The recipient generates two mathematically linked keys: a public key shared with the world, and a private key kept secret. Anyone can use the public key to encrypt a message, but only the private key can decrypt it. The mathematical trick that makes this possible is RSA: multiplying two large primes is easy, but reversing that multiplication (factoring) is extremely hard — even for the most powerful computers, when the primes are large enough.
Why this exists: Before PGP (1991), strong encryption was a government monopoly in the United States. The RSA algorithm had been invented in 1977 (by Rivest, Shamir, and Adleman), but it was patented, and the software was expensive and restricted. Phil Zimmermann, a software engineer and anti-nuclear activist, wanted to give ordinary people the ability to encrypt their email. He wrote PGP in secret, released it as free software, and it spread across the internet within weeks. The US government investigated him for "exporting munitions without a license" — because the US classified cryptography as a weapon on par with missiles and tanks. The three-year legal battle, known as the Crypto Wars, made Zimmermann a folk hero and established the principle that strong encryption belongs to the people, not just governments.
On this site, the PGP puzzle works as an RSA decryption challenge. The encoded_data contains a public key (n, e) and a ciphertext. Your task: factor n, derive the private exponent d, and decrypt the ciphertext to recover a single letter.
▸ How to Decode (Step by Step)
1. You receive encoded_data containing three numbers: public_key_n, public_key_e, and ciphertext
2. Factor n into two primes p and q where n = p × q. Since n is small (12–24 bits), trial division works instantly
3. Compute Euler's totient: φ(n) = (p−1) × (q−1)
4. Find the private exponent d, the modular inverse of e modulo φ(n): d ≡ e⁻¹ (mod φ(n)). The extended Euclidean algorithm gives you this
5. Decrypt the ciphertext: m = ciphertextd mod n
6. The number m is an index into the alphabet: 0 = a, 1 = b, ..., 25 = z. Submit that single letter as your answer
import math
n = encoded_data["public_key_n"]
e = encoded_data["public_key_e"]
c = encoded_data["ciphertext"]
# Step 2: factor n
def factor_n(n):
for i in range(2, int(math.isqrt(n)) + 1):
if n % i == 0:
return i, n // i
p, q = factor_n(n)
# Step 3: compute phi
phi = (p - 1) * (q - 1)
# Step 4: modular inverse via extended Euclidean
def egcd(a, b):
if a == 0: return b, 0, 1
g, x1, y1 = egcd(b % a, a)
return g, y1 - (b // a) * x1, x1
d = egcd(e, phi)[1] % phi
# Step 5: decrypt
m = pow(c, d, n)
# Step 6: convert to letter
answer = chr(ord('a') + m)
print(answer)
▸ Concrete Example
Suppose encoded_data contains:
"public_key_n": 1189,
"public_key_e": 7,
"ciphertext": 141
}
Factor 1189: 1189 = 29 × 41 → p = 29, q = 41
φ(1189) = (29−1) × (41−1) = 28 × 40 = 1120
d = 7⁻¹ mod 1120 → the extended Euclidean algorithm gives d = 1603 (since 7 × 1603 = 11221 = 10 × 1120 + 1)
m = 1411603 mod 1189 = 4
Letter: e (since 0=a, 1=b, 2=c, 3=d, 4=e)
→ The answer is "e".
▸ Real-World Connections
- Phil Zimmermann (1991): Wrote PGP in his spare time and released it as free software. Within weeks, it spread across the internet. The US government launched a three-year criminal investigation for "arms export violations." Zimmermann was never charged, but the case established that strong cryptography is protected speech under the First Amendment.
- The Crypto Wars (1990s): The US government classified encryption software as a munition (Category XIII, United States Munitions List). Exporting PGP was legally equivalent to exporting a missile. The Zimmerman investigation and the release of PGP source code in a published book (protected as free speech under Bernstein v. United States) ultimately forced the government to relax export controls.
- Web of Trust: PGP introduced a decentralized trust model where users sign each other's keys instead of relying on certificate authorities. If Alice signs Bob's key and Bob signs Carol's key, Alice can trust Carol's key — a trust path. This is the opposite of the hierarchical CA model used by HTTPS.
- RFC 4880 (OpenPGP): The standardized format for PGP messages, keys, and signatures. Used by modern tools like GnuPG (the GNU Privacy Guard), ProtonMail, and Signal's sealed sender. OpenPGP keys are identified by their fingerprint — a SHA-1 hash of the public key packet.
- Legal precedent: The Zimmermann case laid the groundwork for the 1999 Ninth Circuit ruling in Bernstein v. United States, which held that encryption source code is protected speech under the First Amendment. This precedent enabled the widespread use of SSL/TLS that secures every HTTPS connection today.
- Related puzzle types on this site: The RSA learn page covers the underlying encryption algorithm in more detail. PGP uses RSA keys for its encryption and signing operations, combined with a session key (typically AES or IDEA) for the actual message encryption.