Skip to content
BENIBIX Learn

Public-Key Cryptography

Development🔐 SecurityDefences

Also known as Asymmetric Encryption, Asymmetric Cryptography, Key Pair, Public and Private Keys

Two keys that work as a pair. One is shared, and one is kept secret.

Think of it like

Think of it like a mailbox. Anyone can drop a letter in, but only you have the key.

Example

Emma puts her public key on a server. When she logs in, the server sends a test that only her private key can answer.

Why it matters

It lets two strangers talk safely without first meeting to share a secret. The secure web depends on it.

Definition

Public-key cryptography uses a pair of keys that work together. The public key can be shared with anyone. The private key is kept secret by its owner. Data locked with the public key can only be opened with the private key. It also works the other way round, which is how digital signatures prove who sent something. HTTPS, SSH and passkeys are all built on it.

Example code

console
$ ls ~/.ssh
id_ed25519  id_ed25519.pub
Two halves of one key pair. The .pub file is shared, and the other one stays secret.
The top row: anyone can lock a note for Emma. Only her private key opens it.

Common mistake

Sending someone your private key so they can check your work. Only the public key is ever shared.

Key takeaways

  1. 1
    Two keys. One public, one private.
  2. 2
    Lock and unlock. What one locks, only the other opens.
  3. 3
    Share only the public one. The private key never leaves you.