# How End\-to\-End Encryption Works

How end\-to\-end encryption keeps a message unreadable to the app's server, from key pairs and a shared secret to locking, sending and opening the message\.

By Numa

Topic: Computing, AI &amp; Electronics

[Open the interactive Jig](https://ask.jig.com/j/4Qkva5MbW8Db)

## Transcript

### 1. A message only two phones can read

Alice wants to send Bob a message\. With end\-to\-end encryption, her words are scrambled on her phone and only unscrambled on Bob's phone\. Everything in between, even the app's own server, carries a locked box it cannot open\.

Apps such as Signal and WhatsApp work this way, using a design called the Signal Protocol\.

### 2. Every phone makes two keys

When the app is installed, each phone makes a matching pair of keys\. The private key never leaves the phone\. The public key is safe to share, a bit like an open padlock, so copies go to the server's phone book\.

A private key is a random number 256 binary digits long\. Guessing it is like finding one grain of sand among far more sand than Earth has\.

### 3. Mixing a shared secret

Before the first message, the two phones agree on a secret without ever sending it\. Think of paint: each side mixes its own secret colour into a public colour and swaps the mixture\. Adding its own secret again gives both sides the very same final colour\.

Anyone who sees the swapped mixtures cannot un\-mix them\. Real phones use maths that is easy one way and practically impossible to undo\.

### 4. Lock the message

The shared secret makes a fresh message key\. Alice's phone uses it to scramble her words with AES\-256, a cipher: a recipe for mixing data that only the same key can undo\. It also adds a seal that shows if anyone tampers with it\. Press the button to lock the box\.

Trying every possible AES\-256 key would take far longer than the universe has existed\.

### 5. Through the server

The locked box travels over the internet through the app's server\. The server knows who the box is for, but inside it sees only scrambled noise\. A snoop peering at the wire sees the same noise\.

Encryption hides what you say, not that you talked or when\. That information is called metadata\.

### 6. Only Bob's phone can open it

Bob's phone works out the same message key using its own private key, which never left his phone\. The box opens and the words come back exactly as Alice wrote them\. The message key is then deleted\.

### 7. A new key for every message

After each message the phones turn a ratchet: the key steps forward through a one\-way process and the old key is thrown away\. Like a real ratchet, it only turns one way\. So even a stolen key cannot unlock earlier messages\.

Each reply also mixes in fresh secrets, so the conversation becomes safe again even after a leak\.

### 8. Check the safety number

To be sure nobody swapped a padlock in the phone book, Alice and Bob can compare a 60\-digit safety number or scan a QR code when they meet\. If the numbers match, nobody has slipped a fake key in between\. Keep your phone locked too: no code can protect a screen someone else is reading\.

The safety number is shown as 12 groups of 5 digits\.
