onion_message: simplify send_onion_message_to
What changed, and why it matters
This commit simplifies how Electrum prepares encrypted data for onion messages. It removes a redundant encryption step and reuses an existing helper function. The change is described by the developer as a no-op cleanup, not a security fix. There is no direct evidence in the commit or supplied references that this addresses a vulnerability.
Treat as a routine refactoring. No immediate security action is indicated by the commit itself. If auditing, verify that the removed encryption step was indeed redundant and that encrypt_hops_recipient_data produces equivalent output for onionmsg_tlv.
Security signals we found
Code touches encryption of onion message recipient data
Removal of an encryption step in a message-sending path
Developer describes change as a no-op simplification, not a security fix
Evidence from the diff
The patch modifies electrum/onion_message.py. In create_route_to_introduction_point, it replaces an inline loop that encrypts encrypted_recipient_data for each hop with a call to the existing encrypt_hops_recipient_data helper. In send_onion_message_to, it removes a call to get_shared_secrets_along_route and encrypt_hops_recipient_data for the blinded path branch, because the hops data was already encrypted earlier and the blinded path’s hop data is already encrypted by the recipient. The commit message explicitly states this is a no-op simplification.
Changed components
electrum/onion_message.pysend_onion_message_tocreate_route_to_introduction_pointInspect captured patch +1 / −13
diff --git a/electrum/onion_message.py b/electrum/onion_message.py
index a2f5360..71634fc 100644
--- a/electrum/onion_message.py
+++ b/electrum/onion_message.py
@@ -240,17 +240,7 @@ def create_route_to_introduction_point(
)
hops_data.append(final_hop_pre_ip)
- # encrypt encrypted_data_tlv here
- for i, hop in enumerate(hops_data):
- encrypted_recipient_data = encrypt_onionmsg_data_tlv(
- shared_secret=hop_shared_secrets[i],
- **hop.blind_fields)
- payload = dict(hop.payload)
- payload['encrypted_recipient_data'] = {
- 'encrypted_recipient_data': encrypted_recipient_data
- }
- hops_data[i] = dataclasses.replace(hop, payload=payload)
-
+ encrypt_hops_recipient_data(tlv_stream_name='onionmsg_tlv', hops_data=hops_data, hop_shared_secrets=hop_shared_secrets)
path_key = ecc.ECPrivkey(session_key).get_public_key_bytes()
return peer, path_key, hops_data, blinded_node_ids
@@ -340,8 +330,6 @@ def send_onion_message_to(
hops_data.append(hop)
payment_path_pubkeys = blinded_node_ids + blinded_path_blinded_ids
- hop_shared_secrets, _ = get_shared_secrets_along_route(payment_path_pubkeys, session_key)
- encrypt_hops_recipient_data('onionmsg_tlv', hops_data, hop_shared_secrets)
packet = new_onion_packet(payment_path_pubkeys, session_key, hops_data, onion_message=True)
packet_b = packet.to_bytes()
Why this scored 29/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.