Tor hides your IP address from the sites you visit by sending your traffic through three volunteer-run relays, wrapped in three layers of encryption.
Each relay can remove only its own layer, so none of them sees both where the traffic came from and where it is going.
Why a normal connection gives you away
When you load a website, your device connects straight to the site's server. Every packet carries your IP address as its return address, because the server needs to know where to send the reply. That address points to your home network or your mobile carrier, and often to a rough location.
Several parties see that connection. The website logs your IP address. Your internet provider sees which servers you connect to, even when HTTPS hides the pages themselves. Anyone else on the path, such as whoever runs a café's Wi-Fi, sees the same. HTTPS encrypts what you send. It doesn't hide who you are talking to.
Tor, short for The Onion Router, deals with that second problem: it separates who you are from where you are going.
Layers of encryption, like an onion
Before Tor sends anything, the Tor client on your machine picks three relays: an entry relay (Tor calls it the guard), a middle relay and an exit relay. It builds a path through them, called a circuit, one hop at a time, and agrees a separate secret key with each relay as it goes. The key agreement is based on Diffie-Hellman, so the keys themselves never cross the network.
Then it wraps your request, starting from the inside:
- Encrypt the request and the website's address with the exit relay's key.
- Encrypt that bundle with the middle relay's key.
- Encrypt the result with the guard's key.
That bundle is the onion. Each relay holds exactly one of the keys, so it can peel exactly one layer. Under its layer it finds a single instruction, where to send the rest, and a bundle it can't read. Tor also moves data in fixed-size chunks called cells, so every piece looks alike to a relay.
Wondering how this was made? How we make these