security//cryptography//public-key cryptography

Public-key cryptography is the family of methods in which each party has two linked keys, a **private key** kept secret and a **public key** that can be given to anyone, so that two strangers can authenticate each other and agree on secrets without having shared anything in advance. It underlies HTTPS certificates, SSH logins, VPN handshakes, software updates and blockchain transactions.


Public-key cryptography is the family of methods in which each party has two linked keys, a private key kept secret and a public key that can be given to anyone, so that two strangers can authenticate each other and agree on secrets without having shared anything in advance. It underlies HTTPS certificates, SSH logins, VPN handshakes, software updates and blockchain transactions.

The link between the keys is a computation that is easy in one direction and infeasible to reverse: the public key is derived from the private key, and recovering the private key from the public one would take longer than the age of the universe with known methods. Two operations come out of that asymmetry. A digital signature is computed with the private key over some data and checked by anyone with the public key, which proves the signer holds the private key and that the data has not changed. A key exchange combines one side's private key with the other's public key so that both arrive at the same shared secret, which then keys fast symmetric encryption.

Identity becomes a public key.

Whoever can produce a valid signature for a public key is, as far as the system knows, its owner. Everything then rests on keeping the private key private and on knowing which public key belongs to whom.

The second problem, binding a public key to a person or a machine, has three common answers: certificates signed by an authority (the web), trust on first use (an SSH client saving a host key), and a coordination service that distributes keys (a mesh VPN).

Elliptic-curve schemes dominate today because their keys are short: a 256-bit curve key gives security comparable to a 3,072-bit RSA key. ECDSA and Ed25519 sign; X25519 exchanges keys.

Where the private key lives decides most of the real security. A key in a file can be copied; a key generated inside a secure enclave can be used but never read out. The blockchain view of the same objects is the key pair.

Large quantum computers would break the current schemes, which is why post-quantum algorithms are being added alongside them.