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

Function decrypt_enctlv

common/blindedpath.c:202–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202bool decrypt_enctlv(const struct pubkey *blinding,
203 const struct secret *ss,
204 const u8 *enctlv,
205 struct pubkey *next_node,
206 struct pubkey *next_blinding)
207{
208 struct tlv_encrypted_data_tlv *encmsg;
209
210 encmsg = decrypt_encmsg(tmpctx, blinding, ss, enctlv);
211 if (!encmsg)
212 return false;
213
214 /* BOLT-onion-message #4:
215 *
216 * The reader:
217 * - if it is not the final node according to the onion encryption:
218 *...
219 * - if the `enctlv` ... does not contain
220 * `next_node_id`:
221 * - MUST drop the message.
222 */
223 if (!encmsg->next_node_id)
224 return false;
225
226 /* BOLT-onion-message #4:
227 * The reader:
228 * - if it is not the final node according to the onion encryption:
229 *...
230 * - if the `enctlv` contains `path_id`:
231 * - MUST drop the message.
232 */
233 if (encmsg->path_id)
234 return false;
235
236 /* BOLT-onion-message #4:
237 * The reader:
238 * - if it is not the final node according to the onion encryption:
239 *...
240 * - if `blinding` is specified in the `enctlv`:
241 * - MUST pass that as `blinding` in the `onion_message`
242 * - otherwise:
243 * - MUST pass `blinding` derived as in
244 * [Route Blinding][route-blinding] (i.e.
245 * `E(i+1) = H(E(i) || ss(i)) * E(i)`).
246 */
247 *next_node = *encmsg->next_node_id;
248 if (encmsg->next_blinding_override)
249 *next_blinding = *encmsg->next_blinding_override;
250 else {
251 /* E(i-1) = H(E(i) || ss(i)) * E(i) */
252 struct sha256 h;
253 blinding_hash_e_and_ss(blinding, ss, &h);
254 blinding_next_pubkey(blinding, &h, next_blinding);
255 }
256 return true;
257}
258
259bool decrypt_final_enctlv(const tal_t *ctx,

Callers 4

handle_onion_messageFunction · 0.85
next_onionFunction · 0.85
test_decryptFunction · 0.85
mainFunction · 0.85

Calls 3

decrypt_encmsgFunction · 0.85
blinding_hash_e_and_ssFunction · 0.70
blinding_next_pubkeyFunction · 0.70

Tested by 3

next_onionFunction · 0.68
test_decryptFunction · 0.68
mainFunction · 0.68