MCPcopy Create free account
hub / github.com/ElementsProject/lightning / blinded_path_from_encdata_tlvs

Function blinded_path_from_encdata_tlvs

common/onion_message.c:56–92  ·  view source on GitHub ↗

Stage 1: tlv_encrypted_data_tlv[] -> struct blinded_path. * Optional array of node_ids, consulted iff tlv uses scid in one entry. */

Source from the content-addressed store, hash-verified

54/* Stage 1: tlv_encrypted_data_tlv[] -> struct blinded_path.
55 * Optional array of node_ids, consulted iff tlv uses scid in one entry. */
56struct blinded_path *blinded_path_from_encdata_tlvs(const tal_t *ctx,
57 const struct tlv_encrypted_data_tlv **tlvs,
58 const struct pubkey *ids)
59{
60 struct privkey first_blinding, blinding_iter;
61 struct blinded_path *path;
62 size_t nhops = tal_count(ids);
63 const struct pubkey *nodeid;
64
65 path = tal(ctx, struct blinded_path);
66
67 assert(nhops > 0);
68 assert(tal_count(ids) > 0);
69
70 randbytes(&first_blinding, sizeof(first_blinding));
71 if (!pubkey_from_privkey(&first_blinding, &path->first_path_key))
72 abort();
73 sciddir_or_pubkey_from_pubkey(&path->first_node_id, &ids[0]);
74
75 path->path = tal_arr(ctx, struct blinded_path_hop *, nhops);
76
77 blinding_iter = first_blinding;
78 for (size_t i = 0; i < nhops; i++) {
79 nodeid = get_nodeid(tlvs, ids, i);
80
81 path->path[i] = tal(path->path, struct blinded_path_hop);
82 path->path[i]->encrypted_recipient_data
83 = encrypt_tlv_encrypted_data(path->path[i],
84 &blinding_iter,
85 nodeid,
86 tlvs[i],
87 &blinding_iter,
88 &path->path[i]->blinded_node_id);
89 }
90
91 return path;
92}
93
94/* Stage 2: turn struct blinded_path into array of tlv_onionmsg_tlv.
95 * You normally then add fields to the final tlv_onionmsg_tlv. */

Callers 3

outgoing_onion_messageFunction · 0.85
found_best_peerFunction · 0.85

Calls 5

pubkey_from_privkeyFunction · 0.85
abortFunction · 0.85
get_nodeidFunction · 0.85

Tested by

no test coverage detected