Skip to content

Commit 9ae8e25

Browse files
committed
Update Default Blinded Path constructor to use Dummy Hops
Applies dummy hops by default when constructing blinded paths via `DefaultMessageRouter`, enhancing privacy by obscuring the true path length. Uses a predefined `DUMMY_HOPS_COUNT` to apply dummy hops consistently without requiring explicit user input.
1 parent 9e654bf commit 9ae8e25

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,19 @@ where
572572
// recipient's node_id.
573573
const MIN_PEER_CHANNELS: usize = 3;
574574

575+
// Add a random number (0 to 5) of dummy hops to each non-compact blinded path
576+
// to make it harder to infer the recipient's position.
577+
//
578+
// # Note on compact paths:
579+
//
580+
// Compact paths are optimized for minimal size. Adding dummy hops to them
581+
// would increase their size and negate their primary advantage.
582+
// Therefore, we avoid adding dummy hops to compact paths.
583+
let dummy_hops_count = compact_paths.then_some(0).unwrap_or_else(|| {
584+
let random_byte = entropy_source.get_secure_random_bytes()[0];
585+
random_byte % 6
586+
});
587+
575588
let network_graph = network_graph.deref().read_only();
576589
let is_recipient_announced =
577590
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -602,8 +615,9 @@ where
602615
let paths = peer_info
603616
.into_iter()
604617
.map(|(peer, _, _)| {
605-
BlindedMessagePath::new(
618+
BlindedMessagePath::new_with_dummy_hops(
606619
&[peer],
620+
dummy_hops_count,
607621
recipient,
608622
context.clone(),
609623
entropy,

0 commit comments

Comments
 (0)