Chapter 10. Onion Routing

In this chapter we will describe the Lightning Network’s onion routing mechanism. The invention of onion routing precedes the Lightning Network by 25 years! Onion routing was invented by U.S. Navy researchers as a communications security protocol. Onion routing is most famously used by Tor, the onion-routed internet overlay that allows researchers, activists, intelligence agents, and everyone else to use the internet privately and anonymously.

In this chapter we are focusing on the “Source-based onion routing (SPHINX)” part of the Lightning protocol architecture, highlighted by an outline in the center (routing layer) of Figure 10-1.

Onion routing in the Lightning protocol suite
Figure 10-1. Onion routing in the Lightning protocol suite

Onion routing describes a method of encrypted communication where a message sender builds successive nested layers of encryption that are “peeled” off by each intermediary node, until the innermost layer is delivered to the intended recipient. The name “onion routing” describes this use of layered encryption that is peeled off one layer at a time, like the skin of an onion.

Each of the intermediary nodes can only “peel” one layer and see who is next in the communication path. Onion routing ensures that no one except the sender knows the destination or length of the communication path. Each intermediary only knows the previous and next hop.

The Lightning Network uses ...

Get Mastering the Lightning Network now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.