Skip to content

feat(mix): use LIONESS for Sphinx payload encryption#1

Closed
chaitanyaprem wants to merge 2 commits into
masterfrom
mix-payload-lioness
Closed

feat(mix): use LIONESS for Sphinx payload encryption#1
chaitanyaprem wants to merge 2 commits into
masterfrom
mix-payload-lioness

Conversation

@chaitanyaprem
Copy link
Copy Markdown
Collaborator

…2p#2349)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chaitanyaprem chaitanyaprem changed the title feat(mix): use LIONESS for Sphinx payload encryption ( feat(mix): use LIONESS for Sphinx payload encryption Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/lioness module 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 useSURB now returning a Result.

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.

Comment thread libp2p_mix/lioness.nim Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@chaitanyaprem
Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants