Skip to content

Commit 2c5d4ab

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 3b56c36 commit 2c5d4ab

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,23 @@ where
579579
// recipient's node_id.
580580
const MIN_PEER_CHANNELS: usize = 3;
581581

582+
// Add a random number (0 to 5) of dummy hops to each non-compact blinded path
583+
// to make it harder to infer the recipient's position.
584+
//
585+
// # Note on compact paths:
586+
//
587+
// Compact paths are optimized for minimal size. Adding dummy hops to them
588+
// would increase their size and negate their primary advantage.
589+
// Therefore, we avoid adding dummy hops to compact paths.
590+
let dummy_hops_count = if compact_paths {
591+
0
592+
} else {
593+
{
594+
let random_byte = entropy_source.get_secure_random_bytes()[0];
595+
random_byte % 6
596+
}
597+
};
598+
582599
let network_graph = network_graph.deref().read_only();
583600
let is_recipient_announced =
584601
network_graph.nodes().contains_key(&NodeId::from_pubkey(&recipient));
@@ -609,9 +626,10 @@ where
609626
let paths = peer_info
610627
.into_iter()
611628
.map(|(peer, _, _)| {
612-
BlindedMessagePath::new(
629+
BlindedMessagePath::new_with_dummy_hops(
613630
&[peer],
614631
recipient,
632+
dummy_hops_count,
615633
local_node_receive_key,
616634
context.clone(),
617635
entropy,

0 commit comments

Comments
 (0)