Dark Web

Onion Routing Explained Simply

Onion routing is one of those ideas that sounds complicated until someone shows you the picture — and then it seems obvious. You wrap a message in layers, hand it to a chain of strangers, and let each stranger remove exactly one layer. Nobody in the chain ever sees the whole message. That is the whole idea, and everything else is detail.

By Abdul Hannan · Published 14 November 2026 · Updated 14 November 2026

The envelope analogy

Imagine you want to send a letter to a friend, but you do not want anyone who handles it to know both that it came from you and that it is going to your friend. So you put your letter in an envelope addressed to a stranger, and inside that envelope you put another envelope addressed to a second stranger, and inside that one a third envelope addressed to your friend.

The first stranger opens the outer envelope, finds the second one, and posts it on. They know the letter came from you, but they cannot see the inner envelopes, so they have no idea where it is going. The second stranger opens the middle envelope and posts the last one on. They know neither sender nor destination — they only know the first stranger and the third. The third stranger opens the last envelope and delivers your letter. They know it is going to your friend, but they never saw you.

That is onion routing. The envelopes are layers of encryption, the strangers are relays, and the address on each envelope is only visible to the relay it is meant for.

From envelopes to encryption

In the real system, the "envelopes" are encryption, and the process is more precise than paper. Before anything is sent, your computer negotiates a separate secret key with each relay in the chain. Then it wraps your message once for the last relay, wraps the result again for the middle relay, and wraps it a third time for the first relay. The message that leaves your computer wears three layers, and each relay can remove only its own.

The negotiation itself is careful: your computer reaches the second relay through the first relay, and the third relay through the first two, so the later relays never learn your address directly. The Tor Project's specification describes this as building a multi-hop circuit, and it is the reason each relay ends up knowing only its immediate neighbours.

Step by step: one message, three relays

  1. You pick three relays. Your software chooses a guard relay, a middle relay and an exit relay at random from the public directory of available relays.
  2. You agree a key with each one. Working through the chain, you establish a separate encryption key with each relay. No relay learns the keys of the others.
  3. You wrap the message three times. The innermost layer can only be opened by the exit relay, the middle layer only by the middle relay, and the outer layer only by the guard relay.
  4. The guard relay peels the outer layer. It sees your address and the middle relay, but the message is still wrapped twice, so it learns nothing about the content or the destination.
  5. The middle relay peels the middle layer. It sees only the guard relay and the exit relay. It knows neither who you are nor where the message is going.
  6. The exit relay peels the last layer. It sees the destination and delivers the message — but it never saw your address, so it has no idea who sent it.
  7. The reply comes back the same way. The answer travels back through the same three relays, gaining a layer at each step, until it reaches you.

What each relay knows

Relay Sees your address Sees the destination Sees the message
Guard relay Yes No No — two layers remain
Middle relay No No No — one layer remains
Exit relay No Yes Only if the site connection is unencrypted

Notice what makes the design strong: there is no single point of failure. A guard relay that is run by an attacker learns your address but not your destination. An exit relay run by an attacker learns destinations but not who visited them. Only an attacker who controls both ends of the same circuit learns both — and with thousands of relays and random selection, that is a deliberate bet against probability rather than a guarantee.

Why three relays, not one or ten?

Three is a compromise, and the Tor Project's early research papers say so. One relay would know everything — that is just a proxy, and it fails the whole point. Two relays split the knowledge, but the middle relay would know both the guard and the exit, and the guard would know the exit's identity. Three is the smallest number where the middle relay knows neither end, and where no single relay can see the full path.

More relays would spread the knowledge further, but each extra hop adds delay, and Tor is already slower than a direct connection. Three hops is the balance the designers chose between anonymity and usability — enough separation to matter, few enough hops to stay usable for everyday browsing.

Onion routing vs a VPN vs a proxy

It helps to see what onion routing is not. A proxy forwards your traffic through one server: that server knows both your address and your destination, so it is a single point of trust. A VPN encrypts your traffic to one provider's server: your provider cannot see what you do, but the VPN provider can, so you have simply moved your trust from one company to another.

Onion routing does something neither of those does: it splits trust across three independent parties, so no one of them has the full picture. That is its advantage — and the source of its costs, which are speed, complexity, and the exit relay problem described below.

The exit problem, honestly stated

Onion routing protects the journey, but the last relay still has to hand your message to the ordinary internet. If the website you visit does not use HTTPS, the exit relay can read what passes through it. Tor does not encrypt the final hop to the website — it cannot, because the website is outside Tor and speaks ordinary web protocol.

This is why the "always use HTTPS" rule matters more on Tor than anywhere else, and why Tor Browser warns you about unencrypted sites. The encryption layers of onion routing protect you from the relays; HTTPS protects you from the exit relay.

Onion services fix the exit problem. When both sides are inside Tor — you and a .onion site — there is no exit relay at all. Both sides build circuits into the network and meet at a rendezvous point inside Tor, so the traffic never touches the public internet. Our guide to how Tor works explains the rendezvous in full.

A short history

Onion routing was developed in the mid-1990s at the United States Naval Research Laboratory by Paul Syverson, Michael Reed and David Goldschlag, to protect intelligence communications online. The original problem was practical: government agents in the field needed to communicate without revealing who they were or where their messages were going.

The idea was released openly, and in the early 2000s Roger Dingledine and Nick Mathewson built Tor, the second-generation onion router, improving on the original design with better handling of reliability, congestion and forward secrecy. The Tor Project was founded as a non-profit in 2006 to maintain it. The design and its early thinking are documented in the Tor Project's own research papers, including the 2005 paper "Challenges in deploying low-latency anonymity".

What onion routing cannot do

  • It cannot hide that you use Tor. Your internet provider sees the connection to the guard relay. Onion routing hides what you do, not that you are doing it.
  • It cannot protect your behaviour. Logging in, downloading files, and running scripts can identify you no matter how the connection was routed.
  • It cannot defeat a global observer. An attacker who can watch traffic entering and leaving the network can match timing and volume to link users to destinations. This is a known, documented limitation of every low-latency anonymity network.
  • It cannot make a bad website safe. A malicious site can still serve malware, phish your credentials, or scam you — the routing does not vet the destination.

None of these limits makes onion routing useless. They make it an honest tool: it solves one specific problem — separating who you are from where you are going — and solves it well, while everything else remains your responsibility.

Sources

Last checked: 14 November 2026.

Frequently asked questions

What is onion routing?

Onion routing is a technique for sending a message through several relays, wrapped in layers of encryption like the layers of an onion. Each relay peels off one layer and passes the message on, so no single relay knows both who sent it and where it is going.

Why is it called onion routing?

Because the message is wrapped in layers, like an onion. Each relay removes one layer. The name was coined by the researchers who developed the technique at the United States Naval Research Laboratory in the mid-1990s.

Is onion routing the same as Tor?

Not quite. Onion routing is the technique; Tor is the network and software that implements it. Tor is the best-known onion routing system, but the idea itself predates Tor by several years.

What does each relay learn in onion routing?

The first relay learns your address but not your destination. The middle relay learns neither. The last relay learns the destination but not who you are. Only by controlling the first and last relays of the same circuit could someone learn both ends.

Does onion routing encrypt my message?

Yes, several times over. Your message is wrapped in one layer of encryption per relay, and each relay removes only its own layer. But once the message leaves the network, it is only as protected as the connection to the final website — which is why HTTPS still matters.