feat(mix): use LIONESS for Sphinx payload encryption#1
Closed
chaitanyaprem wants to merge 2 commits into
Closed
Conversation
…2p#2349) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates Sphinx payload (Delta) encryption from AES-CTR to a LIONESS wide-block construction to make payload tampering (including beyond the leading-k bytes) detectable via the existing leading-zeros integrity tag check.
Changes:
- Add a new
libp2p_mix/lionessmodule implementing LIONESS (ChaCha20 + keyed Blake2b-256 + SHAKE128-derived round keys). - Switch Sphinx payload encryption/decryption (including SURB/reply handling) to LIONESS while keeping header processing on AES-CTR.
- Add dedicated LIONESS test vectors/behavior tests and extend Sphinx tests with a regression test for “tamper past k bytes” detection; update callers for
useSURBnow returning aResult.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
libp2p_mix/sphinx.nim |
Replaces Delta AES-CTR layering with LIONESS layers; updates SURB/reply encryption/decryption flow accordingly. |
libp2p_mix/mix_protocol.nim |
Handles useSURB failures via Result propagation/logging. |
libp2p_mix/lioness.nim |
New LIONESS cipher implementation + helpers (including hasLeadingZeros). |
tests/test_sphinx.nim |
Adds a regression test for Delta tampering past the prefix; updates SURB tests for useSURB: Result. |
tests/test_lioness.nim |
New sub-primitive vectors + LIONESS reference vectors and behavioral tests. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 task
Collaborator
Author
|
Closing this PR as the new spec and the approach seems to be that we use existing cryptographic primitives sphinx already uses and also use boringssl instead of bearssl and nimcrypto for complete mix usage to keep a single dependency. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ref PR vacp2p/nim-libp2p#2349