1. Home
  2. Docs
  3. lightning101
  4. Onion Routing

Onion Routing

Overview

Onion routing is a technique for anonymous routing of payments over the Lightning Network. Routing messages are encapsulated in layers of encryption, analogous to layers of an onion. The encrypted data is transmitted through nodes on the network, each of which “peels” away a single layer, uncovering the data’s next destination. When the final layer of routing information is decrypted, the message arrives at its destination. The sender remains anonymous because each intermediary knows only the location of the immediately preceding and following nodes.

Onion routing means that each note only sees the immediate hope before it and the immediate hop after that. It is called onion routing because the routing information is wrapped in layers. So a node receives an encrypted package from the node one hop before it, and doesn’t know where the final destination is. You unwrap one layer which tells you to go for the next

Details

Path Calculation

When calculating a route for a payment from the sender to a receiver, the route is constructed by the payment sender (source routing) rather than being determined by the routers along the path. The sender builds a set of instructions wrapped in various layers of encryption, analogous to an onion. Each layer of encryption is meant for a single node constructed in the initial routing procedure.

This means that intermediate nodes in the payment path know only the identity of their immediate predecessor and successor in the route. The combination of source routing and onion routing protects the identities of payment senders and receivers so as to enhance user privacy and censorship-resistance.

Limitations

A route produced via source and onion routing is limited to 20 steps.

Resources

Onion Routing, Wikipedia

lightning-onion, GitHub

References

[1] BOLT #4

[2] Bitcoin Book

Was this article helpful to you? No Yes

How can we help?