Public-Key Cryptography

Asymmetric Encryption

James Ellis, a British engineer, was working on something he called non-secret encryption. His idea is clever yet simple: lock and unlock are inverses. Use that as a one-way function, the same idea the key-exchange material turns on.
Easy to lock, but hard to unlock. Anyone at all can push a padlock shut, including someone who has never seen that padlock before and owns no key to it. Getting it open again without the key is the hard half. That gap between the two directions is the whole idea.
A brass padlock, closed, with its key in the lock.
Anyone can snap a padlock shut; only the person with the key can open it. Photo: Shillings1005, CC BY-SA 4.0, via Wikimedia Commons.
Ellis's idea is an example of asymmetric encryption, also called public-key cryptography: encryption which uses a public key and a private key. One for encryption and one for decryption.
Someone can encrypt a message with the public key, but only the recipient, holding their private key, can decrypt it.
• the public key is used for encryption
• the private key is used for decryption
The sender does not need the receiver's private key to encrypt a message, but the receiver's private key is required to decrypt it.
The public key is called public because it is meant to be handed out. Its owner publishes it, gives copies to strangers, prints it on a website. The private key is never sent anywhere at all.

The other direction

When this course says public key encryption, it means the direction above: a public key for encryption and a private key for decryption. The reverse is also used, for digital signatures rather than for keeping secrets: the private key to encrypt, and the public key to decrypt.
That direction is not secrecy. Everybody has the public key, so everybody can undo the encryption and read the message. What the operation proves instead is where the message came from, because only one person holds the private key that could have produced something the public key undoes.
That idea is developed later in this unit, under digital signatures. For now it is enough to know that the direction exists and that it does a completely different job.
Encrypt withWho can decrypt itWhat that gives you
The recipient's public keyOnly the recipient, using their private keySecrecy
The sender's own private keyAnybody, using the sender's published public keyEvidence of who sent it, and no secrecy at all

RSA

The most famous example of asymmetric encryption is RSA, named after its inventors Rivest, Shamir and Adleman. The mathematics behind RSA is beyond the scope of this course, and nothing here asks you to compute anything with it.
A note on the history. Ellis wrote his report in 1970, for a British government agency, and it stayed classified until 1997. The first public description of the idea came from Whitfield Diffie and Martin Hellman in 1976, in the same paper that introduced their key exchange. Rivest, Shamir and Adleman announced RSA in 1977, the first practical public-key encryption method to be published.

The lockbox

Alice has a private key and a lockbox, and the lockbox is her public key. She wishes to receive an encrypted message from Bob. Here is the whole exchange, in order.
• Alice sends Bob the lockbox. It is open, and it is not a secret; she does not mind at all who sees it on the way.
• Bob puts his message inside the lockbox and locks it. Locking is the one-way function, and it is the easy half.
• Bob sends the locked box back.
• Alice opens it with her private key and reads the message.
Notice what Bob never receives, and what never travels in either direction: Alice's private key. It stays with her for the entire exchange. There was nothing to negotiate and nothing to agree on beforehand.
Sending Alice a message with her lockbox, in four rows, with Alice on the left and Bob on the right. Alice's private key is drawn on her side in every row. 1. Alice sends the open lockbox. Anyone may see it. The lockbox is the public key. 2. Bob puts his message inside and locks it. Locking is the easy half. 3. Bob sends the locked box back. It travels locked. 4. Alice opens it with her private key. Message read. The private key never travels in either direction.

One private key, however many correspondents

If Alice is a bank, she can duplicate the lockbox and send copies to everyone she wishes to receive encrypted messages from. She only has to manage one private key.
Set that against what key exchange costs her. There, every correspondent means a fresh round of back-and-forth to agree a key, and a distinct key to store at the end of it; a bank would need thousands of both, and thousands of messages sent purely to set them up. Here she generates one keypair, publishes one half of it, keeps the other, and a new correspondent costs her nothing at all. Nobody has to agree on anything.