Skip to content

docs: add a new category of docs -> databases to explain sphinx replay #9616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/databases/sphinxreplay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Understanding Sphinx Replay Protection

Sphinx is a protocol enabling anonymous and untraceable messaging in networks, commonly used in Lightning's onion routing. To prevent replay attacks, a Sphinx replay database stores message hashes along with metadata (e.g., timestamp, sender ID).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you wrap the lines at 80 characters please?


## How It Works
1. **Message Check**: When a message is received, its hash is compared against stored entries.
2. **Replay Prevention**: If the message exists, it is discarded; otherwise, it is added to the database.
3. **Network Integrity**: This ensures that previously sent messages cannot be resent maliciously.

## Onion Routing in Lightning
Sphinx follows source-based onion routing, where messages are encrypted in nested layers. Each node peels one layer, revealing only the next hop, ensuring sender anonymity and path secrecy.

Lightning’s **Sphinx Mix Format** differs from Tor, offering enhanced security tailored to payments.

For deeper insights, refer to [Chapter 10 of the Lightning Network Book](https://github.com/lnbook/lnbook/blob/develop/10_onion_routing.asciidoc).