How public-key cryptography works
Each person or device has a key pair. The two keys are linked by math, but in one direction only: NIST says “given the public key, it is computationally infeasible to derive the private key.”1 That is what makes it safe to publish the public key.
To send someone a secret, you use their public key. Only their private key can undo it, so it doesn’t matter who else saw the public key. As NIST notes, this lets two parties communicate securely without first sharing a secret key.1 With symmetric cryptography alone, they would have to agree on that key some other way in advance.
The private key is “uniquely associated with the owner and is not made public.”2 Whoever holds it can read what was encrypted to it and sign in the owner’s name, so where it is kept matters more than anything else.
What it is used for
- Agreeing on a key. Two sides use their key pairs to arrive at a shared secret over an open network. This is how TLS, VPNs and messaging apps start every session. X25519 and ML-KEM work this way.
- Encrypting to someone. Email encryption standards such as PGP and S/MIME encrypt each message with a fresh key and lock that key with the recipient’s public key.
- Digital signatures. The owner signs with the private key and anyone can check the signature with the public key, which proves who sent something and that it wasn’t changed.2 Passkeys and software updates rely on this.
Public-key vs symmetric cryptography
| Compared | Public-key (asymmetric) | Symmetric |
|---|---|---|
| Keys | A public key and a private key | One shared secret key |
| Sharing the key | The public key can be published | Must be kept secret by everyone who has it |
| Speed | Slower | Fast |
| Typical job | Agreeing on keys and signing | Encrypting the data itself |
| Examples | RSA, X25519, ML-KEM, ML-DSA | AES-256 |
In practice the two work together, which is called hybrid encryption: a public-key step sets up a fresh symmetric key, and that key encrypts the message or the connection.
Public-key cryptography and quantum computers
The public-key methods in wide use today, RSA and elliptic curves such as X25519, rest on math problems that a large quantum computer running Shor’s algorithm could solve. NIST has published replacements built on different math, ML-KEM for key establishment in FIPS 203 and ML-DSA for signatures in FIPS 204, and its draft transition plan proposes deprecating the weaker RSA and elliptic-curve sizes after 2030 and disallowing both after 2035.3
Until the new methods have a long track record, many systems use both at once, a classical and a post-quantum key exchange combined, so the connection stays safe as long as either one holds.
Related terms
Sources
- NIST Computer Security Resource Center, Glossary: public key cryptography, definitions from NIST SP 800-56B Rev. 2; see also asymmetric cryptography, definition from NIST SP 800-77 Rev. 1.
- NIST Computer Security Resource Center, Glossary: private key, definition from FIPS 186-5.
- NIST, IR 8547 (initial public draft): Transition to Post-Quantum Cryptography Standards.
Questions about public-key cryptography
Is public-key cryptography the same as asymmetric encryption?
Yes. Public-key cryptography and asymmetric cryptography are two names for the same thing, because the two keys in the pair are different.
Can you decrypt with a public key?
Not data that was encrypted to you. That needs the private key. With signatures it runs the other way: the private key signs and the public key checks the signature.
Is it safe to share my public key?
Yes, that is what it is for. Working out the private key from the public key is not feasible with today’s computers.
Is RSA public-key cryptography?
Yes. RSA is a public-key system that is still widely used, along with elliptic-curve methods such as X25519. Both are expected to be replaced by post-quantum methods such as ML-KEM.
What happens if my private key is stolen?
Whoever has it can decrypt what was encrypted to you and sign as you. The key pair has to be replaced and the old public key withdrawn.