global: rename blinding to path_key everywhere.

Get with the modern nomenclature: the pubkey inside a blinded path is called
the `path_key` now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2024-10-15 09:54:26 +10:30
parent 9f593a8184
commit 45533584e2
23 changed files with 114 additions and 118 deletions

View File

@ -1496,7 +1496,7 @@ static void marshall_htlc_info(const tal_t *ctx,
memcpy(a.onion_routing_packet,
htlc->routing,
sizeof(a.onion_routing_packet));
a.blinding = htlc->blinding;
a.path_key = htlc->path_key;
a.fail_immediate = htlc->fail_immediate;
tal_arr_expand(added, a);
} else if (htlc->state == RCVD_REMOVE_COMMIT) {
@ -4410,10 +4410,10 @@ static void resend_commitment(struct peer *peer, struct changed_htlc *last)
if (h->state == SENT_ADD_COMMIT) {
struct tlv_update_add_htlc_tlvs *tlvs;
if (h->blinding) {
if (h->path_key) {
tlvs = tlv_update_add_htlc_tlvs_new(tmpctx);
tlvs->blinded_path = tal_dup(tlvs, struct pubkey,
h->blinding);
h->path_key);
} else
tlvs = NULL;
msg = towire_update_add_htlc(NULL, &peer->channel_id,
@ -5346,7 +5346,7 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
const u8 *failwiremsg;
const char *failstr;
struct amount_sat htlc_fee;
struct pubkey *blinding;
struct pubkey *path_key;
struct tlv_update_add_htlc_tlvs *tlvs;
if (!peer->channel_ready[LOCAL] || !peer->channel_ready[REMOTE])
@ -5355,18 +5355,18 @@ static void handle_offer_htlc(struct peer *peer, const u8 *inmsg)
if (!fromwire_channeld_offer_htlc(tmpctx, inmsg, &amount,
&cltv_expiry, &payment_hash,
onion_routing_packet, &blinding))
onion_routing_packet, &path_key))
master_badmsg(WIRE_CHANNELD_OFFER_HTLC, inmsg);
if (blinding) {
if (path_key) {
tlvs = tlv_update_add_htlc_tlvs_new(tmpctx);
tlvs->blinded_path = tal_dup(tlvs, struct pubkey, blinding);
tlvs->blinded_path = tal_dup(tlvs, struct pubkey, path_key);
} else
tlvs = NULL;
e = channel_add_htlc(peer->channel, LOCAL, peer->htlc_id,
amount, cltv_expiry, &payment_hash,
onion_routing_packet, take(blinding), NULL,
onion_routing_packet, take(path_key), NULL,
&htlc_fee, true);
status_debug("Adding HTLC %"PRIu64" amount=%s cltv=%u gave %s",
peer->htlc_id,

View File

@ -27,7 +27,7 @@ struct htlc {
const u8 *routing;
/* Blinding (optional). */
struct pubkey *blinding;
struct pubkey *path_key;
/* Should we immediately fail this htlc? */
bool fail_immediate;

View File

@ -95,7 +95,7 @@ msgdata,channeld_offer_htlc,amount_msat,amount_msat,
msgdata,channeld_offer_htlc,cltv_expiry,u32,
msgdata,channeld_offer_htlc,payment_hash,sha256,
msgdata,channeld_offer_htlc,onion_routing_packet,u8,1366
msgdata,channeld_offer_htlc,blinding,?pubkey,
msgdata,channeld_offer_htlc,path_key,?pubkey,
# Reply; synchronous since IDs have to increment.
msgtype,channeld_offer_htlc_reply,1104

Can't render this file because it has a wrong number of fields in line 16.

View File

@ -580,7 +580,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 routing[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
struct htlc **htlcp,
bool enforce_aggregate_limits,
struct amount_sat *htlc_fee,
@ -605,7 +605,7 @@ static enum channel_add_err add_htlc(struct channel *channel,
htlc->fail_immediate = false;
htlc->rhash = *payment_hash;
htlc->blinding = tal_dup_or_null(htlc, struct pubkey, blinding);
htlc->path_key = tal_dup_or_null(htlc, struct pubkey, path_key);
htlc->failed = NULL;
htlc->r = NULL;
htlc->routing = tal_dup_arr(htlc, u8, routing, TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE), 0);
@ -898,7 +898,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 routing[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
struct htlc **htlcp,
struct amount_sat *htlc_fee,
bool err_immediate_failures)
@ -918,7 +918,7 @@ enum channel_add_err channel_add_htlc(struct channel *channel,
status_broken("Peer sent out-of-order HTLC ids (is that you, old c-lightning node?)");
return add_htlc(channel, state, id, amount, cltv_expiry,
payment_hash, routing, blinding,
payment_hash, routing, path_key,
htlcp, true, htlc_fee, err_immediate_failures);
}
@ -1616,7 +1616,7 @@ bool channel_force_htlcs(struct channel *channel,
htlcs[i]->cltv_expiry,
&htlcs[i]->payment_hash,
htlcs[i]->onion_routing_packet,
htlcs[i]->blinding,
htlcs[i]->path_key,
&htlc, false, NULL, false);
if (e != CHANNEL_ERR_ADD_OK) {
status_broken("%s HTLC %"PRIu64" failed error %u",

View File

@ -45,7 +45,7 @@ struct existing_htlc *new_existing_htlc(const tal_t *ctx,
const struct sha256 *payment_hash,
u32 cltv_expiry,
const u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
const struct preimage *preimage TAKES,
const struct failed_htlc *failed TAKES)
{
@ -58,7 +58,7 @@ struct existing_htlc *new_existing_htlc(const tal_t *ctx,
existing->payment_hash = *payment_hash;
memcpy(existing->onion_routing_packet, onion_routing_packet,
sizeof(existing->onion_routing_packet));
existing->blinding = tal_dup_or_null(existing, struct pubkey, blinding);
existing->path_key = tal_dup_or_null(existing, struct pubkey, path_key);
existing->payment_preimage
= tal_dup_or_null(existing, struct preimage, preimage);
if (failed)
@ -79,9 +79,9 @@ void towire_added_htlc(u8 **pptr, const struct added_htlc *added)
towire_u32(pptr, added->cltv_expiry);
towire(pptr, added->onion_routing_packet,
sizeof(added->onion_routing_packet));
if (added->blinding) {
if (added->path_key) {
towire_bool(pptr, true);
towire_pubkey(pptr, added->blinding);
towire_pubkey(pptr, added->path_key);
} else
towire_bool(pptr, false);
towire_bool(pptr, added->fail_immediate);
@ -106,9 +106,9 @@ void towire_existing_htlc(u8 **pptr, const struct existing_htlc *existing)
towire_failed_htlc(pptr, existing->failed);
} else
towire_bool(pptr, false);
if (existing->blinding) {
if (existing->path_key) {
towire_bool(pptr, true);
towire_pubkey(pptr, existing->blinding);
towire_pubkey(pptr, existing->path_key);
} else
towire_bool(pptr, false);
}
@ -181,10 +181,10 @@ void fromwire_added_htlc(const u8 **cursor, size_t *max,
fromwire(cursor, max, added->onion_routing_packet,
sizeof(added->onion_routing_packet));
if (fromwire_bool(cursor, max)) {
added->blinding = tal(added, struct pubkey);
fromwire_pubkey(cursor, max, added->blinding);
added->path_key = tal(added, struct pubkey);
fromwire_pubkey(cursor, max, added->path_key);
} else
added->blinding = NULL;
added->path_key = NULL;
added->fail_immediate = fromwire_bool(cursor, max);
}
@ -210,10 +210,10 @@ struct existing_htlc *fromwire_existing_htlc(const tal_t *ctx,
else
existing->failed = NULL;
if (fromwire_bool(cursor, max)) {
existing->blinding = tal(existing, struct pubkey);
fromwire_pubkey(cursor, max, existing->blinding);
existing->path_key = tal(existing, struct pubkey);
fromwire_pubkey(cursor, max, existing->path_key);
} else
existing->blinding = NULL;
existing->path_key = NULL;
return existing;
}

View File

@ -16,7 +16,7 @@ struct added_htlc {
u32 cltv_expiry;
u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)];
bool fail_immediate;
struct pubkey *blinding;
struct pubkey *path_key;
};
/* This is how lightningd tells us about HTLCs which already exist at startup */
@ -27,8 +27,8 @@ struct existing_htlc {
struct sha256 payment_hash;
u32 cltv_expiry;
u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)];
/* If this is non-NULL, this is blinding to send with (outgoing) HTLC */
struct pubkey *blinding;
/* If this is non-NULL, this is path_key to send with (outgoing) HTLC */
struct pubkey *path_key;
/* If fulfilled, this is non-NULL */
struct preimage *payment_preimage;
/* If failed, this is set */
@ -75,7 +75,7 @@ struct existing_htlc *new_existing_htlc(const tal_t *ctx,
const struct sha256 *payment_hash,
u32 cltv_expiry,
const u8 onion_routing_packet[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
const struct preimage *preimage TAKES,
const struct failed_htlc *failed TAKES);

View File

@ -168,7 +168,7 @@ static bool handle_blinded_terminal(struct onion_payload *p,
struct onion_payload *onion_decode(const tal_t *ctx,
const struct route_step *rs,
const struct pubkey *blinding,
const struct pubkey *path_key,
const u64 *accepted_extra_tlvs,
struct amount_msat amount_in,
u32 cltv_expiry,
@ -222,18 +222,18 @@ struct onion_payload *onion_decode(const tal_t *ctx,
* - MUST return an error if `current_path_key` is not present.
* - MUST use that `current_path_key` as the `path_key` for decryption.
*/
if (blinding) {
if (path_key) {
if (p->tlv->current_path_key) {
*failtlvtype = TLV_PAYLOAD_CURRENT_PATH_KEY;
goto field_bad;
}
p->blinding = tal_dup(p, struct pubkey, blinding);
p->path_key = tal_dup(p, struct pubkey, path_key);
} else {
if (!p->tlv->current_path_key) {
*failtlvtype = TLV_PAYLOAD_CURRENT_PATH_KEY;
goto field_bad;
}
p->blinding = tal_dup(p, struct pubkey,
p->path_key = tal_dup(p, struct pubkey,
p->tlv->current_path_key);
}
@ -244,7 +244,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
* not decrypt using the `path_key` as described in
* [Route Blinding](#route-blinding).
*/
ecdh(p->blinding, &p->blinding_ss);
ecdh(p->path_key, &p->blinding_ss);
enc = decrypt_encrypted_data(tmpctx, &p->blinding_ss,
p->tlv->encrypted_recipient_data);
if (!enc) {
@ -335,7 +335,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
* incoming `update_add_htlc` or `current_path_key`
* is present.
*/
if (blinding || p->tlv->current_path_key) {
if (path_key || p->tlv->current_path_key) {
*failtlvtype = TLV_PAYLOAD_ENCRYPTED_RECIPIENT_DATA;
goto field_bad;
}
@ -401,7 +401,7 @@ struct onion_payload *onion_decode(const tal_t *ctx,
else
p->payment_metadata = NULL;
p->blinding = NULL;
p->path_key = NULL;
return p;

View File

@ -10,7 +10,7 @@
* @ctx: context to allocate onion_contents off.
* @rs: the route_step, whose raw_payload is of at least length
* onion_payload_length().
* @blinding: the optional incoming blinding point.
* @path_key: the optional incoming path_key point.
* @accepted_extra_tlvs: Allow these types to be in the TLV without failing
* @amount_in: Incoming HTLC amount
* @cltv_expiry: Incoming HTLC cltv_expiry
@ -21,7 +21,7 @@
*/
struct onion_payload *onion_decode(const tal_t *ctx,
const struct route_step *rs,
const struct pubkey *blinding,
const struct pubkey *path_key,
const u64 *accepted_extra_tlvs,
struct amount_msat amount_in,
u32 cltv_expiry,

View File

@ -28,8 +28,8 @@ struct onion_payload {
struct secret *payment_secret;
u8 *payment_metadata;
/* If blinding is set, blinding_ss is the shared secret.*/
struct pubkey *blinding;
/* If path_key is set, blinding_ss is the shared secret.*/
struct pubkey *path_key;
struct secret blinding_ss;
/* The raw TLVs contained in the payload. */

View File

@ -221,7 +221,7 @@ wrap:
/* Now populate the onion message to return */
omsg = tal(ctx, struct onion_message);
omsg->first_blinding = combined_path->first_path_key;
omsg->first_path_key = combined_path->first_path_key;
omsg->hops = onionmsg_tlvs_to_hops(omsg, combined_path,
cast_const2(const struct tlv_onionmsg_tlv **, otlvs));
return omsg;

View File

@ -106,7 +106,7 @@ struct blinded_path *incoming_message_blinded_path(const tal_t *ctx,
/* A ready-to-be-encrypted-and-sent onion message. */
struct onion_message {
struct pubkey first_blinding;
struct pubkey first_path_key;
struct sphinx_hop **hops;
};

View File

@ -12,7 +12,6 @@
#include <wire/peer_wire.h>
static bool decrypt_final_onionmsg(const tal_t *ctx,
const struct pubkey *blinding,
const struct secret *ss,
const u8 *enctlv,
const struct pubkey *my_id,
@ -86,7 +85,7 @@ static bool decrypt_forwarding_onionmsg(const struct pubkey *path_key,
/* Returns false on failure */
const char *onion_message_parse(const tal_t *ctx,
const u8 *onion_message_packet,
const struct pubkey *blinding,
const struct pubkey *path_key,
const struct pubkey *me,
u8 **next_onion_msg,
struct sciddir_or_pubkey *next_node,
@ -114,7 +113,7 @@ const char *onion_message_parse(const tal_t *ctx,
}
ephemeral = op->ephemeralkey;
if (!unblind_onion(blinding, ecdh, &ephemeral, &ss)) {
if (!unblind_onion(path_key, ecdh, &ephemeral, &ss)) {
return tal_fmt(ctx, "onion_message_parse: can't unblind onionpacket");
}
@ -151,7 +150,7 @@ const char *onion_message_parse(const tal_t *ctx,
if (!om->encrypted_recipient_data) {
*final_alias = *me;
*final_path_id = NULL;
} else if (!decrypt_final_onionmsg(ctx, blinding, &ss,
} else if (!decrypt_final_onionmsg(ctx, &ss,
om->encrypted_recipient_data, me,
final_alias,
final_path_id)) {
@ -160,7 +159,7 @@ const char *onion_message_parse(const tal_t *ctx,
" %s", tal_hex(tmpctx, om->encrypted_recipient_data));
}
} else {
struct pubkey next_blinding;
struct pubkey next_path_key;
*final_om = NULL;
@ -174,14 +173,14 @@ const char *onion_message_parse(const tal_t *ctx,
}
/* This fails as expected if no enctlv. */
if (!decrypt_forwarding_onionmsg(blinding, &ss, om->encrypted_recipient_data, next_node,
&next_blinding)) {
if (!decrypt_forwarding_onionmsg(path_key, &ss, om->encrypted_recipient_data, next_node,
&next_path_key)) {
return tal_fmt(ctx,
"onion_message_parse: invalid encrypted_recipient_data %s",
tal_hex(tmpctx, om->encrypted_recipient_data));
}
*next_onion_msg = towire_onion_message(ctx,
&next_blinding,
&next_path_key,
serialize_onionpacket(tmpctx, rs->next));
}

View File

@ -12,7 +12,7 @@ struct pubkey;
* onion_message_parse: core routine to check onion_message
* @ctx: context to allocate @next_onion_msg or @final_om/@path_id off
* @onion_message_packet: Sphinx-encrypted onion
* @blinding: Blinding we were given for @onion_message_packet
* @path_key: Path_Key we were given for @onion_message_packet
* @me: my pubkey
* @next_onion_msg (out): set if we should forward, otherwise NULL.
* @next_node (out): set to node id or scid to fwd to, iff *@next_onion_msg.
@ -24,7 +24,7 @@ struct pubkey;
*/
const char *onion_message_parse(const tal_t *ctx,
const u8 *onion_message_packet,
const struct pubkey *blinding,
const struct pubkey *path_key,
const struct pubkey *me,
u8 **next_onion_msg,
struct sciddir_or_pubkey *next_node,

View File

@ -147,11 +147,11 @@ msgtype,connectd_send_onionmsg,2041
msgdata,connectd_send_onionmsg,id,node_id,
msgdata,connectd_send_onionmsg,onion_len,u16,
msgdata,connectd_send_onionmsg,onion,u8,onion_len
msgdata,connectd_send_onionmsg,blinding,pubkey,
msgdata,connectd_send_onionmsg,path_key,pubkey,
# Lightningd tells us to digest an onion message.
msgtype,connectd_inject_onionmsg,2042
msgdata,connectd_inject_onionmsg,blinding,pubkey,
msgdata,connectd_inject_onionmsg,path_key,pubkey,
msgdata,connectd_inject_onionmsg,onion_len,u16,
msgdata,connectd_inject_onionmsg,onion,u8,onion_len

1 #include <bitcoin/block.h>
147 msgdata,connectd_custommsg_out,msg_len,u16,
148 msgdata,connectd_custommsg_out,msg,u8,msg_len
149 # master -> connectd: we're shutting down, no new connections.
150 msgtype,connectd_start_shutdown,2031
151 # connect - >master: acknowledged.
152 msgtype,connectd_start_shutdown_reply,2131
153 # master -> connect: stop sending gossip.
154 msgtype,connectd_dev_suppress_gossip,2032
155 # master -> connect: waste all your fds.
156 msgtype,connectd_dev_exhaust_fds,2036
157 # master -> connect: set artificial maximum reply_channel_range size.

View File

@ -21,24 +21,24 @@ void onionmsg_req(struct daemon *daemon, const u8 *msg)
{
struct node_id id;
u8 *onionmsg;
struct pubkey blinding;
struct pubkey path_key;
struct peer *peer;
if (!fromwire_connectd_send_onionmsg(msg, msg, &id, &onionmsg, &blinding))
if (!fromwire_connectd_send_onionmsg(msg, msg, &id, &onionmsg, &path_key))
master_badmsg(WIRE_CONNECTD_SEND_ONIONMSG, msg);
/* Even though lightningd checks for valid ids, there's a race
* where it might vanish before we read this command. */
peer = peer_htable_get(daemon->peers, &id);
if (peer) {
u8 *omsg = towire_onion_message(NULL, &blinding, onionmsg);
u8 *omsg = towire_onion_message(NULL, &path_key, onionmsg);
inject_peer_msg(peer, take(omsg));
}
}
static const char *handle_onion(const tal_t *ctx,
struct daemon *daemon,
const struct pubkey *blinding,
const struct pubkey *path_key,
const u8 *onion)
{
u8 *next_onion_msg;
@ -48,7 +48,7 @@ static const char *handle_onion(const tal_t *ctx,
struct secret *final_path_id;
const char *err;
err = onion_message_parse(tmpctx, onion, blinding,
err = onion_message_parse(tmpctx, onion, path_key,
&daemon->mykey,
&next_onion_msg, &next_node,
&final_om, &final_alias, &final_path_id);
@ -113,7 +113,7 @@ static const char *handle_onion(const tal_t *ctx,
void handle_onion_message(struct daemon *daemon,
struct peer *peer, const u8 *msg)
{
struct pubkey blinding;
struct pubkey path_key;
u8 *onion;
u64 msec;
struct timemono now = time_mono();
@ -144,26 +144,26 @@ void handle_onion_message(struct daemon *daemon,
}
peer->onionmsg_incoming_tokens -= ONION_MSG_MSEC;
if (!fromwire_onion_message(msg, msg, &blinding, &onion)) {
if (!fromwire_onion_message(msg, msg, &path_key, &onion)) {
inject_peer_msg(peer,
take(towire_warningfmt(NULL, NULL,
"Bad onion_message")));
return;
}
handle_onion(tmpctx, daemon, &blinding, onion);
handle_onion(tmpctx, daemon, &path_key, onion);
}
void inject_onionmsg_req(struct daemon *daemon, const u8 *msg)
{
u8 *onionmsg;
struct pubkey blinding;
struct pubkey path_key;
const char *err;
if (!fromwire_connectd_inject_onionmsg(msg, msg, &blinding, &onionmsg))
if (!fromwire_connectd_inject_onionmsg(msg, msg, &path_key, &onionmsg))
master_badmsg(WIRE_CONNECTD_INJECT_ONIONMSG, msg);
err = handle_onion(tmpctx, daemon, &blinding, onionmsg);
err = handle_onion(tmpctx, daemon, &path_key, onionmsg);
daemon_conn_send(daemon->master,
take(towire_connectd_inject_onionmsg_reply(NULL, err ? err : "")));
}

View File

@ -128,7 +128,7 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
struct amount_msat msat, u32 cltv_expiry,
const struct sha256 *payment_hash,
const struct secret *shared_secret TAKES,
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
const u8 *onion_routing_packet,
bool fail_immediate)
{
@ -143,10 +143,7 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
hin->status = NULL;
hin->fail_immediate = fail_immediate;
hin->shared_secret = tal_dup_or_null(hin, struct secret, shared_secret);
if (blinding)
hin->blinding = tal_dup(hin, struct pubkey, blinding);
else
hin->blinding = NULL;
hin->path_key = tal_dup_or_null(hin, struct pubkey, path_key);
memcpy(hin->onion_routing_packet, onion_routing_packet,
sizeof(hin->onion_routing_packet));
@ -267,7 +264,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 *onion_routing_packet,
const struct pubkey *blinding,
const struct pubkey *path_key,
bool am_origin,
struct amount_msat final_msat,
u64 partid,
@ -293,7 +290,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
hout->preimage = NULL;
hout->timeout = NULL;
hout->blinding = tal_dup_or_null(hout, struct pubkey, blinding);
hout->path_key = tal_dup_or_null(hout, struct pubkey, path_key);
hout->am_origin = am_origin;
if (am_origin) {
hout->partid = partid;

View File

@ -47,7 +47,7 @@ struct htlc_in {
struct timeabs received_time;
/* If it was blinded. */
struct pubkey *blinding;
struct pubkey *path_key;
/* true if we supplied the preimage */
bool *we_filled;
/* true if we immediately fail the htlc (too much dust) */
@ -101,8 +101,8 @@ struct htlc_out {
/* Where it's from, if not going to us. */
struct htlc_in *in;
/* Blinding to send alongside, if any. */
struct pubkey *blinding;
/* Path_Key to send alongside, if any. */
struct pubkey *path_key;
/* Timer we use in case they don't add an HTLC in a timely manner. */
struct oneshot *timeout;
@ -156,7 +156,7 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
struct amount_msat msat, u32 cltv_expiry,
const struct sha256 *payment_hash,
const struct secret *shared_secret TAKES,
const struct pubkey *blinding TAKES,
const struct pubkey *path_key TAKES,
const u8 *onion_routing_packet,
bool fail_immediate);
@ -167,7 +167,7 @@ struct htlc_out *new_htlc_out(const tal_t *ctx,
u32 cltv_expiry,
const struct sha256 *payment_hash,
const u8 *onion_routing_packet,
const struct pubkey *blinding,
const struct pubkey *path_key,
bool am_origin,
struct amount_msat final_msat,
u64 partid,

View File

@ -723,7 +723,7 @@ static const u8 *send_onion(const tal_t *ctx, struct lightningd *ld,
const struct route_hop *first_hop,
const struct amount_msat final_amount,
const struct sha256 *payment_hash,
const struct pubkey *blinding,
const struct pubkey *path_key,
u64 partid,
u64 groupid,
struct channel *channel,
@ -738,7 +738,7 @@ static const u8 *send_onion(const tal_t *ctx, struct lightningd *ld,
return send_htlc_out(ctx, channel, first_hop->amount,
base_expiry + first_hop->delay,
final_amount, payment_hash,
blinding, partid, groupid, onion, NULL, hout);
path_key, partid, groupid, onion, NULL, hout);
}
static struct command_result *check_invoice_request_usage(struct command *cmd,

View File

@ -144,11 +144,11 @@ static void channel_stats_incr_out_offered(struct channel *c,
*/
static bool blind_error_return(const struct htlc_in *hin)
{
if (hin->blinding)
if (hin->path_key)
return true;
if (hin->payload
&& hin->payload->blinding
&& hin->payload->path_key
&& !hin->payload->final)
return true;
@ -186,7 +186,7 @@ static struct failed_htlc *mk_failed_htlc(const tal_t *ctx,
/* Also, at head of the blinded path, return "normal" invalid
* onion blinding. */
if (hin->payload && hin->payload->blinding) {
if (hin->payload && hin->payload->path_key) {
struct sha256 sha;
sha256(&sha, hin->onion_routing_packet,
sizeof(hin->onion_routing_packet));
@ -655,7 +655,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
struct amount_msat amount, u32 cltv,
struct amount_msat final_msat,
const struct sha256 *payment_hash,
const struct pubkey *blinding,
const struct pubkey *path_key,
u64 partid,
u64 groupid,
const u8 *onion_routing_packet,
@ -690,7 +690,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
/* Make peer's daemon own it, catch if it dies. */
*houtp = new_htlc_out(out->owner, out, amount, cltv,
payment_hash, onion_routing_packet,
blinding, in == NULL,
path_key, in == NULL,
final_msat,
partid, groupid, in);
tal_add_destructor(*houtp, destroy_hout_subd_died);
@ -704,7 +704,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
}
msg = towire_channeld_offer_htlc(out, amount, cltv, payment_hash,
onion_routing_packet, blinding);
onion_routing_packet, path_key);
subd_req(out->peer->ld, out->owner, take(msg), -1, 0, rcvd_htlc_reply,
*houtp);
@ -757,7 +757,7 @@ static void forward_htlc(struct htlc_in *hin,
const struct short_channel_id *forward_scid,
const struct channel_id *forward_to,
const u8 next_onion[TOTAL_PACKET_SIZE(ROUTING_INFO_SIZE)],
const struct pubkey *next_blinding)
const struct pubkey *next_path_key)
{
const u8 *failmsg;
struct lightningd *ld = hin->key.channel->peer->ld;
@ -872,7 +872,7 @@ static void forward_htlc(struct htlc_in *hin,
failmsg = send_htlc_out(tmpctx, next, amt_to_forward,
outgoing_cltv_value, AMOUNT_MSAT(0),
&hin->payment_hash,
next_blinding, 0 /* partid */, 0 /* groupid */,
next_path_key, 0 /* partid */, 0 /* groupid */,
next_onion, hin, &hout);
if (!failmsg)
return;
@ -895,7 +895,7 @@ struct htlc_accepted_hook_payload {
struct htlc_in *hin;
struct channel *channel;
struct lightningd *ld;
struct pubkey *next_blinding;
struct pubkey *next_path_key;
/* NULL if we couldn't find it */
struct channel_id *fwd_channel_id;
u8 *next_onion;
@ -986,7 +986,7 @@ static bool htlc_accepted_hook_deserialize(struct htlc_accepted_hook_payload *re
rs->raw_payload = prepend_length(rs, take(payload));
request->payload = onion_decode(request,
rs,
hin->blinding,
hin->path_key,
ld->accept_extra_tlv_types,
hin->msat,
hin->cltv_expiry,
@ -1163,7 +1163,7 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
request->payload->forward_channel,
request->fwd_channel_id,
serialize_onionpacket(tmpctx, rs->next),
request->next_blinding);
request->next_path_key);
} else
handle_localpay(hin,
request->payload->amt_to_forward,
@ -1175,18 +1175,18 @@ htlc_accepted_hook_final(struct htlc_accepted_hook_payload *request STEALS)
tal_free(request);
}
/* Apply tweak to ephemeral key if blinding is non-NULL, then do ECDH */
/* Apply tweak to ephemeral key if path_key is non-NULL, then do ECDH */
static bool ecdh_maybe_blinding(const struct pubkey *ephemeral_key,
const struct pubkey *blinding,
const struct pubkey *path_key,
struct secret *ss)
{
struct pubkey point = *ephemeral_key;
if (blinding) {
if (path_key) {
struct secret hmac;
struct secret blinding_ss;
ecdh(blinding, &blinding_ss);
ecdh(path_key, &blinding_ss);
/* b(i) = HMAC256("blinded_node_id", ss(i)) * k(i) */
subkey_from_hmac("blinded_node_id", &blinding_ss, &hmac);
@ -1403,7 +1403,7 @@ static bool peer_accepted_htlc(const tal_t *ctx,
hook_payload->route_step = tal_steal(hook_payload, rs);
hook_payload->payload = onion_decode(hook_payload,
rs,
hin->blinding,
hin->path_key,
ld->accept_extra_tlv_types,
hin->msat,
hin->cltv_expiry,
@ -1415,16 +1415,16 @@ static bool peer_accepted_htlc(const tal_t *ctx,
hook_payload->next_onion = serialize_onionpacket(hook_payload, rs->next);
/* We could have blinding from hin or from inside onion. */
if (hook_payload->payload && hook_payload->payload->blinding) {
if (hook_payload->payload && hook_payload->payload->path_key) {
struct sha256 sha;
blinding_hash_e_and_ss(hook_payload->payload->blinding,
blinding_hash_e_and_ss(hook_payload->payload->path_key,
&hook_payload->payload->blinding_ss,
&sha);
hook_payload->next_blinding = tal(hook_payload, struct pubkey);
blinding_next_path_key(hook_payload->payload->blinding, &sha,
hook_payload->next_blinding);
hook_payload->next_path_key = tal(hook_payload, struct pubkey);
blinding_next_path_key(hook_payload->payload->path_key, &sha,
hook_payload->next_path_key);
} else
hook_payload->next_blinding = NULL;
hook_payload->next_path_key = NULL;
/* The scid is merely used to indicate the next peer, it is not
* a requirement (nor, ideally, observable anyway). We can change
@ -1443,7 +1443,7 @@ static bool peer_accepted_htlc(const tal_t *ctx,
fail:
/* In a blinded path, *all* failures are "invalid_onion_blinding" */
if (hin->blinding) {
if (hin->path_key) {
*failmsg = tal_free(*failmsg);
*badonion = WIRE_INVALID_ONION_BLINDING;
}
@ -2157,7 +2157,7 @@ static bool channel_added_their_htlc(struct channel *channel,
&failcode);
if (op) {
if (!ecdh_maybe_blinding(&op->ephemeralkey,
added->blinding,
added->path_key,
&shared_secret)) {
log_debug(channel->log, "htlc %"PRIu64
": can't tweak pubkey", added->id);
@ -2170,7 +2170,7 @@ static bool channel_added_their_htlc(struct channel *channel,
hin = new_htlc_in(channel, channel, added->id, added->amount,
added->cltv_expiry, &added->payment_hash,
op ? &shared_secret : NULL,
added->blinding,
added->path_key,
added->onion_routing_packet,
added->fail_immediate);
@ -2607,7 +2607,7 @@ const struct existing_htlc **peer_htlcs(const tal_t *ctx,
hin->msat, &hin->payment_hash,
hin->cltv_expiry,
hin->onion_routing_packet,
hin->blinding,
hin->path_key,
hin->preimage,
f);
tal_arr_expand(&htlcs, existing);
@ -2639,7 +2639,7 @@ const struct existing_htlc **peer_htlcs(const tal_t *ctx,
hout->msat, &hout->payment_hash,
hout->cltv_expiry,
hout->onion_routing_packet,
hout->blinding,
hout->path_key,
hout->preimage,
f);
tal_arr_expand(&htlcs, existing);

View File

@ -32,7 +32,7 @@ const u8 *send_htlc_out(const tal_t *ctx,
struct amount_msat amount, u32 cltv,
struct amount_msat final_msat,
const struct sha256 *payment_hash,
const struct pubkey *blinding,
const struct pubkey *path_key,
u64 partid,
u64 groupid,
const u8 *onion_routing_packet,

View File

@ -106,7 +106,7 @@ inject_onionmessage_(struct command *cmd,
req = jsonrpc_request_start(cmd->plugin, cmd, "injectonionmessage",
cb, errcb, arg);
json_add_pubkey(req->js, "path_key", &omsg->first_blinding);
json_add_pubkey(req->js, "path_key", &omsg->first_path_key);
json_array_start(req->js, "hops");
for (size_t i = 0; i < tal_count(omsg->hops); i++) {
json_object_start(req->js, NULL);

View File

@ -5,27 +5,27 @@
#include <wire/peer_wire.h>
struct onion_message {
struct pubkey blinding;
struct pubkey path_key;
u8 *onionmsg;
};
static void *encode(const tal_t *ctx, const struct onion_message *s)
{
return towire_onion_message(ctx, &s->blinding, s->onionmsg);
return towire_onion_message(ctx, &s->path_key, s->onionmsg);
}
static struct onion_message *decode(const tal_t *ctx, const void *p)
{
struct onion_message *s = tal(ctx, struct onion_message);
if (fromwire_onion_message(s, p, &s->blinding, &s->onionmsg))
if (fromwire_onion_message(s, p, &s->path_key, &s->onionmsg))
return s;
return tal_free(s);
}
static bool equal(const struct onion_message *x, const struct onion_message *y)
{
if (memcmp(&x->blinding, &y->blinding, sizeof(x->blinding)) != 0)
if (memcmp(&x->path_key, &y->path_key, sizeof(x->path_key)) != 0)
return false;
return tal_arr_eq(x->onionmsg, y->onionmsg);
}

View File

@ -2991,8 +2991,8 @@ static bool wallet_stmt2htlc_in(struct channel *channel,
in->cltv_expiry = db_col_int(stmt, "cltv_expiry");
in->hstate = db_col_int(stmt, "hstate");
in->status = NULL;
/* FIXME: save blinding in db !*/
in->blinding = NULL;
/* FIXME: save path_key in db !*/
in->path_key = NULL;
in->payload = NULL;
db_col_sha256(stmt, "payment_hash", &in->payment_hash);
@ -3064,8 +3064,8 @@ static bool wallet_stmt2htlc_out(struct wallet *wallet,
out->cltv_expiry = db_col_int(stmt, "cltv_expiry");
out->hstate = db_col_int(stmt, "hstate");
db_col_sha256(stmt, "payment_hash", &out->payment_hash);
/* FIXME: save blinding in db !*/
out->blinding = NULL;
/* FIXME: save path_key in db !*/
out->path_key = NULL;
out->preimage = db_col_optional(out, stmt, "payment_key", preimage);