onion_message: don't use general secret, use per-message secret.

We had a scheme where lightningd itself would put a per-node secret in
the blinded path, then we'd tell the caller when it was used.  Then it
simply checks the alias to determine if the correct path was used.

But this doesn't work when we start to offer multiple blinded paths.
So go for a far simpler scheme, where the secret is generated (and
stored) by the caller, and hand it back to them.

We keep the split "with secret" or "without secret" API, since I'm
sure callers who don't care about the secret won't check that it
doesn't exist!  And without that, someone can use a blinded path for a
different message and get a response which may reveal the node.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2022-11-09 12:00:10 +10:30
committed by Christian Decker
parent 4cfd972407
commit 5becfa6ee1
11 changed files with 51 additions and 74 deletions

View File

@@ -118,8 +118,7 @@ msgdata,connectd_ping_reply,totlen,u16,
# We tell lightningd we got an onionmsg
msgtype,connectd_got_onionmsg_to_us,2145
msgdata,connectd_got_onionmsg_to_us,node_alias,pubkey,
msgdata,connectd_got_onionmsg_to_us,self_id,?secret,
msgdata,connectd_got_onionmsg_to_us,path_secret,?secret,
msgdata,connectd_got_onionmsg_to_us,reply,?blinded_path,
msgdata,connectd_got_onionmsg_to_us,rawmsg_len,u16,
msgdata,connectd_got_onionmsg_to_us,rawmsg,u8,rawmsg_len
1 #include <bitcoin/block.h>
118 msgdata,connectd_custommsg_in,id,node_id, msgdata,connectd_custommsg_in,msg_len,u16,
119 msgdata,connectd_custommsg_in,msg_len,u16, msgdata,connectd_custommsg_in,msg,u8,msg_len
120 msgdata,connectd_custommsg_in,msg,u8,msg_len # A custom message that the lightningd tells us to send to the peer.
121 # A custom message that the lightningd tells us to send to the peer. msgtype,connectd_custommsg_out,2011
msgtype,connectd_custommsg_out,2011
122 msgdata,connectd_custommsg_out,id,node_id,
123 msgdata,connectd_custommsg_out,msg_len,u16,
124 msgdata,connectd_custommsg_out,msg,u8,msg_len

View File

@@ -75,7 +75,7 @@ void handle_onion_message(struct daemon *daemon,
towire_tlvstream_raw(&omsg, final_om->fields);
daemon_conn_send(daemon->master,
take(towire_connectd_got_onionmsg_to_us(NULL,
&final_alias, final_path_id,
final_path_id,
final_om->reply_path,
omsg)));
} else {