Skip to main content
Be Bitwise

The Public Key Revolution

Asymmetric Encryption · Networking & Cryptography track

6 min read

In this module

The Key Distribution Problem

Symmetric encryption has a chicken-and-egg problem at its core: to communicate securely, both parties need the same secret key. How do you share the key securely without a secure channel? And if you had one, you wouldn't need encryption in the first place.

For centuries, no decent answer existed. Keys travelled in person or by trusted couriers, the same way diplomatic dispatches always had. The internet, where you need secure conversations with millions of strangers you've never met, looked structurally impossible to secure with symmetric encryption alone.

Public key cryptography (asymmetric encryption) cracked this open in the 1970s. It's one of the most consequential inventions in the history of computing — full stop.

Two Keys, One System

In asymmetric encryption, each party has a key pair:

  • A public key that can be shared with everyone
  • A private key that is kept absolutely secret

The two keys are linked mathematically: data encrypted with the public key only opens under the matching private key, and the other way round too.

Key Concept

Public key cryptography uses a key pair: encrypt with the public key, decrypt with the private key. Anyone can encrypt a message to you using your public key, but only you can decrypt it using your private key. This eliminates the need to share secret keys in advance.

The Trapdoor Function

Asymmetric encryption rests on trapdoor functions: mathematical operations that go one way easily, but resist being run backwards without a special piece of knowledge (the "trapdoor").

Examples:

  • Multiplication vs. factoring: Multiplying two large primes (easy) versus factoring their product (hard). This is what RSA uses.
  • Exponentiation vs. discrete logarithm: Computing g^x mod p (easy) versus finding x given g, g^x, and p (hard). This is what Diffie-Hellman uses.
  • Elliptic curve scalar multiplication: Computing kP on an elliptic curve (easy) versus finding k given P and kP (hard). This is what ECC uses.

The private key is the trapdoor — the secret that makes the reverse operation feasible.

Hybrid Encryption

Asymmetric encryption is slow. Roughly a thousand times slower than symmetric. Encrypting a large file with RSA would be a small eternity. The pragmatic answer is hybrid encryption:

  1. Generate a random symmetric key (called a session key)
  2. Encrypt the actual data with the symmetric key (AES - fast)
  3. Encrypt the symmetric key with the recipient's public key (RSA - slow but the key is tiny)
  4. Send both the encrypted data and the encrypted session key

The recipient unwraps the session key with their private key, then decrypts the bulk data with that session key. You get the key-distribution chops of asymmetric crypto and the speed of symmetric crypto in one package.

Elliptic-curve keys can't encrypt a session key directly like this. With ECC, the sender instead runs a key agreement (ECDH) between a fresh throwaway key pair and the recipient's public key, and both sides derive the session key from the shared result. That scheme is called ECIES, and it does the same job as step 3.

Here's the sender's side for a 1 GB file, using AES-256-GCM for the data and RSA-2048 to wrap the key. The slow algorithm only ever touches 32 bytes, so its cost hardly matters. As rough figures for a modern laptop core, one RSA-2048 private-key operation takes around a millisecond, while AES-GCM with hardware support gets through several gigabytes a second.

TLS (HTTPS) follows the same idea with a twist. Modern TLS 1.3 never encrypts a session key with RSA at all: the handshake uses ephemeral Diffie-Hellman (ECDHE) to agree on a shared key, and then every byte of your traffic flows under symmetric encryption.

Digital Signatures: The Other Direction

Flip the roles around: sign with your private key, and anyone holding your public key can verify. That gives no secrecy at all, but it proves you produced the message, because only you possess the private key.

That's a digital signature. You'll often hear it described as "encrypting with the private key". That's a loose intuition from textbook RSA, where the maths happens to look that way, but it doesn't hold in general: ECDSA and EdDSA signatures aren't encryption of anything, and real RSA signatures use a padding scheme (RSA-PSS) of their own. The shape of every scheme is the same, though:

  1. Hash the message to get a fixed-size digest
  2. Run the signing algorithm on the digest with your private key
  3. Attach the signature to the message

To verify:

  1. Hash the message
  2. Run the verification algorithm on the digest, the signature and the sender's public key
  3. It answers yes or no: the signature is valid only if it was made over this exact digest by the matching private key

Digital signatures deliver authentication (the message came from the claimed sender) and integrity (nobody has tampered with it). They underpin code signing, certificate authorities, and secure software distribution — pretty much every "how do you trust this binary?" question on the internet.

A Revolution in Trust

Before public key cryptography, secure communication required pre-existing trust. You had to have met the other party, or share a mutually trusted intermediary. The internet, built for strangers, had no mechanism for that. Public key cryptography cracked it open: total strangers can now strike up an authenticated, encrypted channel in seconds, with no prior relationship required.

The Foundation of Digital Trust

Every time you verify a software update, validate a website's identity, sign a document electronically, or use a cryptocurrency, this machinery is doing the work. The rest of this module digs into the specific algorithms: RSA, Diffie-Hellman key exchange, and elliptic curve cryptography. Each takes a different mathematical route to the same destination — a pair of linked keys, one public and one private, where knowing one tells you nothing useful about the other.