← Bitcoin Encyclopedia

Onion Routing

🌿 Intermediate

💡 The Plain-English Definition

Onion routing is the privacy mechanism the Lightning Network uses to route payments through intermediate nodes: each node in the chain sees only its immediate neighbours, not the full path, the sender, or the final recipient — like peeling an onion layer by layer, each layer revealing only the next step.

Onion Routing
A diagram from the original 2004 Tor design paper, showing how each relay only unwraps one layer of an encrypted packet — the literal 'onion' in onion routing.Photo: Roger Dingledine, Nick Mathewson, Paul Syverson, 2004, CC BY 3.0, via Wikimedia Commons

🤔 But Why Though?

When you send a Lightning payment that travels through several intermediate nodes, you don’t want every node along the way to know where the payment started and where it’s headed. That information could tie your financial activity to your identity, enable surveillance of your payments, or let intermediate nodes selectively block payments from or to certain parties.

Onion routing wraps the payment instructions in layers of encryption, one for each node on the route. The sender, who knows the full path, builds the encrypted package. The first node peels off its outer layer, learns only the next hop, and forwards the rest. The second node peels its layer, learns only its next hop. And so on, all the way to the recipient. Each node sees just two things: who handed it the payment, and who to hand it to next. Nobody in the middle knows the full path, the sender, or the recipient.

The name comes from that layered structure — like peeling an onion, each layer reveals only the next, never the centre. The specific scheme Lightning uses is called SPHINX, an onion-encryption protocol built for payment routing. This is separate from Tor (which routes internet traffic through encrypted relays to hide IP addresses): the two work at different layers, and using both together gives you complementary protection.

🌍 The Real-World Analogy

Think of a chain of sealed envelopes. The sender puts the final message in an envelope addressed to the last recipient, seals that inside another envelope addressed to the second-to-last, seals that inside another addressed to the third-to-last, and so on. Each postal worker opens only the outermost envelope, sees only “pass this to the next address,” and passes the rest along. Nobody in the chain sees the final destination or the original sender — only the next link.

⚡ So What?

Onion routing is why Lightning payments don’t reveal your identity to every node that handles them. Intermediate routing nodes earn their fees without knowing whose payment they’re forwarding. That’s a big improvement over sending on-chain, where every transaction is public and permanent. It isn’t perfect — timing correlation, amounts visible to intermediate nodes, and channel-graph analysis mean Lightning isn’t anonymous — but onion routing makes it substantially more private than the Bitcoin base layer.

📩 The Daily Bit · free

Get one plain-English Bitcoin email each morning.

The Daily Bit — free, two minutes, unsubscribe anytime.

The Bitcoin EncyclopediaPrefer a book? The Bitcoin Encyclopedia