Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 480
Introduce Padding for Payment and Message Blinded Tlvs#3177
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4d726fc
Rename Padding -> BlindedPathPadding
shaavan f32e21e
Remove `Readable` for `BlindedPathPadding`
shaavan ff7a6b0
Update Padding struct to contain padding length.
shaavan 5ce2b5e
Introduce `BlindedPathWithPadding` struct
shaavan 8ad34ef
Introduce Padding for BlindedMessage Paths.
shaavan 5d6881f
Introduce Padding for BlindedPaymentPaths
shaavan f8ffc1a
Introduce test for Padding
shaavan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -21,8 +21,9 @@ use super::offers::{OffersMessage, OffersMessageHandler}; | ||
| use super::packet::{OnionMessageContents, Packet}; | ||
| use crate::blinded_path::message::{ | ||
| AsyncPaymentsContext, BlindedMessagePath, DNSResolverContext, MessageContext, | ||
| MessageForwardNode, OffersContext, | ||
| MessageForwardNode, OffersContext, MESSAGE_PADDING_ROUND_OFF, | ||
| }; | ||
| use crate::blinded_path::utils::is_padded; | ||
| use crate::blinded_path::EmptyNodeIdLookUp; | ||
| use crate::events::{Event, EventsProvider}; | ||
| use crate::ln::msgs::{self, BaseMessageHandler, DecodeError, OnionMessageHandler}; | ||
| @@ -596,6 +597,65 @@ fn too_big_packet_error() { | ||
| assert_eq!(err, SendError::TooBigPacket); | ||
| } | ||
| #[test] | ||
| fn test_blinded_path_padding_for_full_length_path() { | ||
| // Check that for a full blinded path, all encrypted payload are padded to rounded-off length. | ||
| let nodes = create_nodes(4); | ||
| let test_msg = TestCustomMessage::Pong; | ||
| let secp_ctx = Secp256k1::new(); | ||
| let intermediate_nodes = [ | ||
| MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: None }, | ||
| MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: None }, | ||
shaavan marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ]; | ||
| // Update the context to create a larger final receive TLVs, ensuring that | ||
| // the hop sizes vary before padding. | ||
| let context = MessageContext::Custom(vec![0u8; 42]); | ||
| let blinded_path = BlindedMessagePath::new( | ||
| &intermediate_nodes, | ||
| nodes[3].node_id, | ||
| context, | ||
| &*nodes[3].entropy_source, | ||
| &secp_ctx, | ||
| ) | ||
| .unwrap(); | ||
| assert!(is_padded(&blinded_path.blinded_hops(), MESSAGE_PADDING_ROUND_OFF)); | ||
| let destination = Destination::BlindedPath(blinded_path); | ||
| let instructions = MessageSendInstructions::WithoutReplyPath { destination }; | ||
| nodes[0].messenger.send_onion_message(test_msg, instructions).unwrap(); | ||
| nodes[3].custom_message_handler.expect_message(TestCustomMessage::Pong); | ||
| pass_along_path(&nodes); | ||
| } | ||
| #[test] | ||
| fn test_blinded_path_no_padding_for_compact_path() { | ||
| // Check that for a compact blinded path, no padding is applied. | ||
| let nodes = create_nodes(4); | ||
| let secp_ctx = Secp256k1::new(); | ||
| // Include some short_channel_id, so that MessageRouter uses this to create compact blinded paths. | ||
| let intermediate_nodes = [ | ||
| MessageForwardNode { node_id: nodes[1].node_id, short_channel_id: Some(24) }, | ||
| MessageForwardNode { node_id: nodes[2].node_id, short_channel_id: Some(25) }, | ||
| ]; | ||
| // Update the context to create a larger final receive TLVs, ensuring that | ||
| // the hop sizes vary before padding. | ||
| let context = MessageContext::Custom(vec![0u8; 42]); | ||
| let blinded_path = BlindedMessagePath::new( | ||
| &intermediate_nodes, | ||
| nodes[3].node_id, | ||
| context, | ||
| &*nodes[3].entropy_source, | ||
| &secp_ctx, | ||
| ) | ||
| .unwrap(); | ||
| assert!(!is_padded(&blinded_path.blinded_hops(), MESSAGE_PADDING_ROUND_OFF)); | ||
| } | ||
| #[test] | ||
| fn we_are_intro_node() { | ||
| // If we are sending straight to a blinded path and we are the introduction node, we need to | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.