Understand public and private key cryptography through interactive visual analogies. Learn the padlock, color mixing, and mailbox concepts - no math required.
Public key cryptography (also called asymmetric cryptography) is a cryptographic system that uses mathematically linked key pairs: a public key that can be freely shared and a private key that must be kept secret. Unlike symmetric encryption where both parties share a single secret key, public key cryptography solves the key distribution problem — two parties can communicate securely without ever having exchanged a secret in advance.
Public key cryptography is the foundation of digital signatures, TLS/HTTPS, SSH, PGP email encryption, cryptocurrency, and certificate-based authentication. Invented independently by Diffie-Hellman (1976) and Rivest-Shamir-Adleman (RSA, 1977), it remains one of the most important innovations in the history of computer science.
A key pair is generated using a mathematical trapdoor function — an operation that is easy to compute in one direction but computationally infeasible to reverse:
| Operation | Uses | How It Works |
|---|---|---|
| Encryption | Public key | Anyone can encrypt a message using the recipient's public key. Only the matching private key can decrypt it. |
| Decryption | Private key | Only the private key holder can decrypt messages encrypted with their public key. |
| Signing | Private key | The sender signs a message using their private key, creating a digital signature. |
| Verification | Public key | Anyone can verify the signature using the signer's public key, confirming authenticity and integrity. |
| Algorithm | Based On | Key Sizes | Status |
|---|---|---|---|
| RSA | Integer factorization | 2048-4096 bit | Widely used; 2048-bit minimum recommended |
| ECDSA | Elliptic curve discrete logarithm | 256-384 bit | Preferred for performance; same security with smaller keys |
| Ed25519 | Twisted Edwards curve | 256-bit | Modern; fast, constant-time, resistant to side channels |
| X25519 | Montgomery curve | 256-bit | Key exchange (Diffie-Hellman); used in TLS 1.3 and WireGuard |
| Kyber | Lattice-based | Various | Post-quantum candidate; NIST standardized as ML-KEM |