Public Key Concepts

Understand public and private keys through three interactive analogies - padlock, colour mixing and mailbox - plus where asymmetric crypto is used daily.

Advertisement

Public Key Cryptography, Without the Maths

Public key cryptography is the idea that makes the modern internet possible, and it is genuinely counter-intuitive the first time you meet it: two strangers who have never communicated before can establish a secret that an eavesdropper watching every byte between them cannot work out. This tool explains how, using three interactive analogies that you can click through, plus a tour of where the technique is actually used.

It is aimed at people who need the concept rather than the arithmetic — students, help-desk and IT staff, developers who use TLS and SSH daily without ever having been taught what is underneath, and anyone explaining security to a non-technical audience. No maths is required to follow it. If you want the arithmetic afterwards, the tool links onward to a working RSA implementation.

The Core Idea

Traditional (symmetric) encryption uses one key for both locking and unlocking. That works well, but it has a bootstrapping problem: both parties need the same key, and getting it to the other person securely is the very problem you were trying to solve.

Asymmetric cryptography breaks the symmetry. You generate a key pair: a public key you publish to the world, and a private key you never share with anyone. What one key does, only the other can undo. Anyone can encrypt a message to you using your public key, and only your private key can decrypt it — including the person who encrypted it, who cannot read their own message back. Conversely, only you can produce a signature with your private key, and anyone can verify it with your public key.

The pair is mathematically linked, but the link runs one way. Deriving the private key from the public key requires solving a problem — factoring a very large number, or computing a discrete logarithm on an elliptic curve — that is easy to state and, at the sizes used in practice, computationally infeasible. That one-way asymmetry is the entire foundation.

The Three Analogies

The Padlock

Imagine handing out thousands of open padlocks, all of which only your one key can open. Anyone can put a message in a box, snap one of your padlocks shut on it, and send it. Once it clicks closed, not even the sender can reopen it. The open padlocks are your public key; the key in your pocket is your private key. This analogy captures the essential asymmetry: locking and unlocking are different capabilities, and only one of them is a secret.

Colour Mixing

The colour-mixing analogy explains something the padlock cannot: how two parties agree on a shared secret in public. Both start from a common public colour. Each privately picks a secret colour and mixes it with the public one. They exchange the resulting mixtures openly — an eavesdropper sees both mixtures. Each then adds their own private colour to the mixture they received. Both arrive at the same final colour, containing both private colours plus the public base. The eavesdropper, holding only the public colour and the two mixtures, cannot reach it, because separating a mixed colour back into its components is hard while mixing is easy.

That is Diffie–Hellman key exchange, and paint is a fair model of it: mixing is the easy direction, un-mixing is the hard one. In the real protocol the “colours” are numbers and the hard direction is the discrete logarithm problem.

The Mailbox

A public mailbox with a slot anyone can post through, but a locked door only your key opens. It is a good model for the mechanics: your address is public, delivery is open to anyone, retrieval is exclusively yours. It also exposes the honest limitation of all these analogies — a mailbox tells you nothing about who posted a letter. That gap is why digital signatures exist as a separate operation.

Encryption Versus Signing

These are two different uses of the same key pair, and confusing them is the most common misunderstanding in this area.

Encrypting to someoneSigning something
Key used to createRecipient’s public keyYour private key
Key used to undo/verifyRecipient’s private keyYour public key
Who can perform itAnyoneOnly you
What it gives youConfidentialityAuthenticity and integrity

Encryption answers “only the intended recipient can read this”. Signing answers “this came from me and has not been altered”. A signed message is not secret, and an encrypted message does not prove who sent it. Protocols that need both do both.

Where It Is Used Every Day

  • HTTPS / TLS — every padlock icon in a browser. Asymmetric cryptography authenticates the server and establishes a shared session key; the bulk of the traffic is then encrypted symmetrically because that is far faster. This hybrid design is nearly universal.
  • SSH keys — developers and administrators authenticate with a key pair instead of a password. The private key stays on the workstation; the public key sits in authorized_keys on the server.
  • Digital signatures — code signing, signed software updates, and legally recognised electronic document signing.
  • Secure messaging — end-to-end encrypted messengers use the Signal protocol and its Double Ratchet, layered on repeated key exchanges so that compromising one key does not expose past or future messages.
  • Encrypted email — PGP and S/MIME let you encrypt to a recipient’s published key and sign what you send.
  • Cryptocurrency wallets — an address is derived from a public key and ownership is proved by signing with the private key. “Not your keys, not your coins” is a statement about exactly this.

The Part Analogies Leave Out: Trust

Every analogy above assumes you have the right public key. Nothing in the mathematics guarantees that. If an attacker can substitute their public key for the one you think belongs to your bank, they can decrypt everything you send and you will notice nothing.

Solving that is a separate problem, addressed by different systems in different contexts: certificate authorities and the browser trust store for the web, the web of trust for PGP, and trust-on-first-use with fingerprint checking for SSH. When you compare an SSH host-key fingerprint, or a security tool warns that a certificate is issued by an unknown authority, you are watching that layer do its job. The cryptography is rarely what fails — the trust decisions around it are.

Related Tools

Once the concept lands, go and use it: generate an SSH key pair, create PGP keys for encrypted email, or step through the actual arithmetic in the RSA playground. For the symmetric side of the story, the block cipher mode visualizer shows why how you encrypt matters as much as what you encrypt with, and the hash generator demonstrates the one-way functions signatures rely on.

Frequently Asked Questions

What is the difference between a public key and a private key?

The public key is meant to be shared freely; anyone can use it to encrypt a message to you or to verify a signature you made. The private key is never shared and is the only thing that can decrypt those messages or produce those signatures.

Can someone work out my private key from my public key?

Not in practice at the key sizes in use. Doing so requires solving a problem — factoring a large number, or an elliptic curve discrete logarithm — that is computationally infeasible with current technology. The realistic threats are your private key being stolen from disk, backed up carelessly, or protected by a weak passphrase.

Why not encrypt everything asymmetrically?

Speed. Asymmetric operations are orders of magnitude slower than symmetric ones. Real protocols use asymmetric cryptography to authenticate and to agree a symmetric session key, then encrypt the actual data symmetrically.

What is Diffie–Hellman key exchange?

A method for two parties to agree on a shared secret over a channel an eavesdropper can read in full. The colour-mixing analogy models it: mixing is easy, un-mixing is hard, so both sides reach the same final mixture while the observer cannot.

Is signing the same as encrypting?

No. Signing uses your private key and proves authorship and integrity; anyone can verify it and the content stays readable. Encrypting uses the recipient’s public key and hides the content from everyone else. They are independent and often used together.

How do I know a public key really belongs to who it claims to?

That is the trust problem, and it is handled outside the mathematics — certificate authorities for the web, fingerprint verification for SSH, the web of trust for PGP. Verifying key ownership is where real-world attacks concentrate.

What happens if I lose my private key?

Anything encrypted to it becomes unreadable and you can no longer sign as that identity. There is no recovery mechanism by design. Generate a new pair, distribute the new public key, and revoke the old one where a revocation mechanism exists.

Do I need to understand the maths to use this safely?

No. Understanding which key is public, which is private, and which operation each performs is enough to use TLS, SSH and PGP correctly. Use vetted libraries rather than implementing anything yourself.

What Is Public Key Cryptography

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.

How Public Key Cryptography Works

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:

Core Operations

OperationUsesHow It Works
EncryptionPublic keyAnyone can encrypt a message using the recipient's public key. Only the matching private key can decrypt it.
DecryptionPrivate keyOnly the private key holder can decrypt messages encrypted with their public key.
SigningPrivate keyThe sender signs a message using their private key, creating a digital signature.
VerificationPublic keyAnyone can verify the signature using the signer's public key, confirming authenticity and integrity.

Common Algorithms

AlgorithmBased OnKey SizesStatus
RSAInteger factorization2048-4096 bitWidely used; 2048-bit minimum recommended
ECDSAElliptic curve discrete logarithm256-384 bitPreferred for performance; same security with smaller keys
Ed25519Twisted Edwards curve256-bitModern; fast, constant-time, resistant to side channels
X25519Montgomery curve256-bitKey exchange (Diffie-Hellman); used in TLS 1.3 and WireGuard
KyberLattice-basedVariousPost-quantum candidate; NIST standardized as ML-KEM

Common Use Cases

  • Understanding TLS/HTTPS: Learn how web browsers and servers use public key cryptography to establish encrypted connections
  • SSH key management: Understand why SSH key pairs work and how Ed25519 differs from RSA for server authentication
  • Digital signature concepts: Explore how code signing, document signing, and certificate chains rely on asymmetric operations
  • Post-quantum awareness: Understand why current public key algorithms are vulnerable to quantum computers and what replacement algorithms are being standardized
  • Certificate authority trust: Learn how the chain of trust from root CAs to leaf certificates uses public key signing

Best Practices

  1. Use Ed25519 for new deployments — Unless compatibility requires RSA or ECDSA, Ed25519 provides the best combination of security, performance, and implementation safety.
  2. Minimum RSA key size: 2048 bits — NIST and major browsers require at least 2048-bit RSA keys. Plan migration to 3072-bit or 4096-bit for longevity beyond 2030.
  3. Protect private keys with hardware — Store private keys in Hardware Security Modules (HSMs), TPMs, or secure enclaves. Never store unprotected private keys on disk.
  4. Prepare for post-quantum cryptography — NIST finalized ML-KEM (Kyber) and ML-DSA (Dilithium) as post-quantum standards. Begin evaluating hybrid deployments that combine classical and post-quantum algorithms.
  5. Rotate keys on a schedule — Even without compromise, rotate keys periodically. TLS certificates expire (typically 90-398 days), and SSH keys should be rotated at least annually.
This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results. Results are based on the information you enter and do not constitute a security audit, a formal compliance assessment, or legal advice, and they do not establish that any system or organisation meets a given standard. Coverage of a framework may be partial — check what the tool states it assesses. For anything you intend to rely on, consult a qualified assessor.