Skip to content

Commit 203b56e

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 b8d62fc commit 203b56e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,15 @@ where
565565
// recipient's node_id.
566566
const MIN_PEER_CHANNELS: usize = 3;
567567

568+
// Number of dummy hops added to each non-compact blinded path
569+
// to obscure the recipient’s position.
570+
//
571+
// Compact paths are optimized for minimal size. Adding dummy hops
572+
// would bloat them and defeat that purpose, so we skip them.
573+
const DUMMY_HOPS_COUNT: usize = 3;
574+
575+
let dummy_hops_count = if compact_paths { 0 } else { DUMMY_HOPS_COUNT };
576+
568577
let network_graph = network_graph.deref().read_only();
569578
let is_recipient_announced =
570579
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -599,9 +608,10 @@ where
599608
let paths = peer_info
600609
.into_iter()
601610
.map(|(peer, _, _)| {
602-
BlindedMessagePath::new(
611+
BlindedMessagePath::new_with_dummy_hops(
603612
&[peer],
604613
recipient,
614+
dummy_hops_count,
605615
local_node_receive_key,
606616
context.clone(),
607617
entropy,
@@ -615,9 +625,10 @@ where
615625
Ok(paths) if !paths.is_empty() => Ok(paths),
616626
_ => {
617627
if is_recipient_announced {
618-
BlindedMessagePath::new(
628+
BlindedMessagePath::new_with_dummy_hops(
619629
&[],
620630
recipient,
631+
dummy_hops_count,
621632
local_node_receive_key,
622633
context,
623634
&**entropy_source,

0 commit comments

Comments
 (0)