Public Keys, Private Keys and Certificates
Back in the TLS lesson, the shop's website proved its identity with a certificate. But how can a server prove who it is to millions of strangers without sharing a secret with each one first? The answer is a pair of mathematically linked keys.
The rule
Share the public key with everyone; guard the private key with your life.
Asymmetric (public-key) cryptography gives each owner a key pair:
- The public key can be given to anyone.
- The private key stays only with its owner and is never shared.
They work as a team in two directions:
- Encrypt for someone — anyone encrypts with the owner's public key; only the owner's private key can decrypt it. Like a letterbox: anyone can post, only the keyholder opens it.
- Sign as someone — the owner signs with their private key; anyone checks the signature with the public key. Like a wax seal only you can make but everyone can recognise.
The other kind, symmetric encryption, uses one shared key for both locking and unlocking. It is fast, so real systems use public keys to agree a shared key safely (key exchange), then switch to symmetric encryption for the bulk of the data. That is exactly what the TLS handshake does.
A public key alone does not say whose it is. A certificate binds a public key to a name, like hollowoakbooks.example, and is signed by a certificate authority (CA). Browsers trust a set of CAs, and CAs check who they issue to. This whole system of CAs, certificates and trust is called PKI (public key infrastructure).
The shortcut
Ask "Is this about secrecy or proof?" Secrecy: encrypt with the recipient's public key. Proof: sign with your own private key.
Key pair
The web server generates a key pair and keeps the private key on the server only.
If the private key leaks, anyone could pose as the shop. It must be replaced and the old certificate revoked. Never email private keys or save them in shared folders.
Drills
Answer fast — trust the rule.
A supplier wants to send Priya a secret file. Which key should they encrypt it with?
Which key does the shop's server use to sign, proving it is really the shop?
What does a certificate do?
The web server's private key is accidentally posted online. What should happen?
Why does TLS switch to a symmetric key after the handshake?
Remember
- Share the public key with everyone; guard the private key.
- Secrecy: encrypt with the recipient's public key. Proof: sign with your private key.
- Certificates bind keys to names through PKI. Trap: leaking or sharing a private key.
