rust-lightning icon indicating copy to clipboard operation
rust-lightning copied to clipboard

Add an implementation of mutual message exchange

Open TheBlueMatt opened this issue 1 year ago • 4 comments

Based on #2828

This adds a new crate, mutual-message-exchange which allows two parties to maintain a list of keys with which they want to exchange messages and exchange one message at the cost of an extra half-round-trip.

This is anticipated for use in BOLT12, where extra data can be included in a BOLT12 Invoice which allows a mutually-trusting sender to include a message in the onion, while any non-mutually-trusting entities will not learn anything about the recipient (subject to the use of blinded paths).

A full write-up of this protocol is available as bLIP 31.

TheBlueMatt avatar Jan 15 '24 04:01 TheBlueMatt

Walkthrough

A sweeping refactor has taken place, centralizing cryptographic operations into a new crypto module. This reorganization involves updating import paths, consolidating crypto-related functionality, and introducing new implementations for the ChaCha20-Poly1305 algorithm. The changes streamline the codebase, making cryptographic operations more modular and easier to manage.

Changes

File(s) Summary
.../blinded_path/message.rs, .../ln/msgs.rs, .../onion_message/packet.rs Updated import paths for ChaChaPolyReadAdapter to new crypto module.
.../blinded_path/utils.rs, .../onion_message/packet.rs Import path for ChaChaPolyWriteAdapter updated to crypto::streams.
.../chain/channelmonitor.rs, .../ln/monitor_tests.rs, .../ln/chan_utils.rs, .../sign/mod.rs Import path for cryptographic signing updated to crypto::utils::sign.
.../crypto/chacha20.rs, mutual-message-exchange/src/chacha20.rs Modified ChaChaReader struct and test modules to use alloc and core modules.
.../crypto/chacha20poly1305rfc.rs, mutual-message-exchange/src/chacha20poly1305rfc.rs New implementation of ChaCha20-Poly1305 according to RFC standard.
.../crypto/mod.rs Introduced crypto module with submodules for cryptographic operations.
.../crypto/poly1305.rs, mutual-message-exchange/src/poly1305.rs Updated poly1305.rs with reorganized imports and modified raw_result function.
.../crypto/streams.rs Added functionality for encrypted data streams using ChaCha20-Poly1305.
.../lib.rs Added crypto module and conditionally re-exported std::io.
.../ln/inbound_payment.rs, .../routing/router.rs, .../util/scid_utils.rs Reorganized import paths for cryptographic modules.
.../ln/peer_channel_encryptor.rs Updated import paths and modified decryption logic.
.../util/mod.rs Removed cryptographic modules and reordered module declarations.
mutual-message-exchange/src/lib.rs Introduced mutual-authentication protocol with cryptographic functions.

🐇 "In the realm of code, where the data streams flow,
A rabbit hopped through, refactoring in tow.
With a flip and a hop, crypto modules align,
Now the code's more secure, thanks to design." 🎉

(\__/) ||  
(•ㅅ•) ||  
/   づ  

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jan 15 '24 04:01 coderabbitai[bot]

Codecov Report

:x: Patch coverage is 94.44444% with 21 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 89.61%. Comparing base (d49a08a) to head (fbf88f1). :warning: Report is 2544 commits behind head on main.

Files with missing lines Patch % Lines
mutual-message-exchange/src/lib.rs 94.32% 16 Missing and 5 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2829      +/-   ##
==========================================
+ Coverage   89.59%   89.61%   +0.02%     
==========================================
  Files         127      131       +4     
  Lines      103438   104668    +1230     
  Branches   103438   104668    +1230     
==========================================
+ Hits        92672    93795    +1123     
- Misses       8049     8150     +101     
- Partials     2717     2723       +6     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar Jan 15 '24 04:01 codecov-commenter

Needs fuzzing before this lands.

TheBlueMatt avatar Jan 15 '24 05:01 TheBlueMatt

Rebased.

TheBlueMatt avatar Oct 02 '24 20:10 TheBlueMatt

Closing due to lack of downstream project interest. I assume I'll pick this back up eventually.

TheBlueMatt avatar Nov 18 '25 13:11 TheBlueMatt