Public-Key Cryptography
Split the key in two — a public lock anyone can close and a private key only you can open — using one-way functions with a hidden trapdoor.
Public-Key Cryptography
For all of history, encryption meant a single shared secret: the same key locked and unlocked, so the two parties had to meet or trust a courier first. Public-key cryptography — also called asymmetric cryptography — shattered that assumption. Each person holds a key pair:
- a public key, published to the world, that anyone can use to encrypt to you or verify your signature;
- a private key, kept secret, that only you can use to decrypt or sign.
The metaphor is an open padlock. You hand out copies of an unlocked padlock (your public key); anyone can snap one shut around a message and send it back. Only you hold the physical key that opens it. Closing a padlock takes no secret; opening it does.
Trapdoor one-way functions
The whole edifice stands on a special kind of function: a trapdoor one-way function.
- One-way — easy to compute forward, infeasible to invert. Like smashing a plate: trivial to do, hopeless to reverse from the pieces.
- Trapdoor — unless you hold a secret, in which case inversion becomes easy again.
The public key describes the one-way function; the private key is the trapdoor. Two concrete trapdoors power the real world, both living in Modular Arithmetic:
- Factoring — multiplying primes p \cdot q is easy; factoring n back apart is hard. This is RSA's trapdoor.
- Discrete logarithm — computing g^a \bmod p is easy; recovering a is hard. This powers Diffie–Hellman and elliptic-curve schemes.
What the two keys buy you
Asymmetry gives two distinct powers, depending on which key acts first:
- Encrypt with the public key → decrypt with the private key. Anyone can send you a secret; only you can read it. This is confidentiality.
- Sign with the private key → verify with the public key. Only you can produce the value; anyone can check it. This is a Digital Signature, giving authenticity and integrity.
In practice asymmetric crypto is slow, so it rarely encrypts bulk data directly. Instead it does the hard part — agreeing on or delivering a short symmetric key (often via Diffie–Hellman) — and a fast symmetric cipher handles the rest. Public-key crypto is the handshake; symmetric crypto is the conversation.