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

Function next_onion

common/test/run-blindedpath_onion.c:105–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105static u8 *next_onion(const tal_t *ctx, u8 *omsg,
106 const struct privkey *nodekey,
107 const struct pubkey *expected_blinding)
108{
109 struct onionpacket *op;
110 struct pubkey blinding, ephemeral;
111 struct pubkey next_node, next_blinding;
112 struct tlv_onionmsg_payload *om;
113 struct secret ss, onion_ss;
114 const u8 *cursor;
115 size_t max, maxlen;
116 struct route_step *rs;
117
118 assert(fromwire_onion_message(tmpctx, omsg, &blinding, &omsg));
119 assert(pubkey_eq(&blinding, expected_blinding));
120
121 op = parse_onionpacket(tmpctx, omsg, tal_bytelen(omsg), NULL);
122 ephemeral = op->ephemeralkey;
123
124 ecdh_key = nodekey;
125 assert(unblind_onion(&blinding, ecdh, &ephemeral, &ss));
126
127 ecdh(&ephemeral, &onion_ss);
128 rs = process_onionpacket(tmpctx, op, &onion_ss, NULL, 0, false);
129 assert(rs);
130
131 /* The raw payload is prepended with length in the modern onion. */
132 cursor = rs->raw_payload;
133 max = tal_bytelen(rs->raw_payload);
134 maxlen = fromwire_bigsize(&cursor, &max);
135 om = fromwire_tlv_onionmsg_payload(tmpctx, &cursor, &maxlen);
136
137 if (rs->nextcase == ONION_END)
138 return NULL;
139
140 assert(decrypt_enctlv(&blinding, &ss, om->encrypted_data_tlv, &next_node,
141 &next_blinding));
142 return towire_onion_message(ctx, &next_blinding,
143 serialize_onionpacket(tmpctx, rs->next));
144}
145
146int main(int argc, char *argv[])
147{

Callers 1

mainFunction · 0.85

Calls 8

tal_bytelenFunction · 0.85
unblind_onionFunction · 0.85
decrypt_enctlvFunction · 0.85
ecdhFunction · 0.70
fromwire_bigsizeFunction · 0.70
parse_onionpacketFunction · 0.50
process_onionpacketFunction · 0.50
serialize_onionpacketFunction · 0.50

Tested by

no test coverage detected