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

Function sphinx_prefill

common/sphinx.c:501–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499}
500
501static void sphinx_prefill(u8 *routinginfo, const struct sphinx_path *sp,
502 size_t prefill_size, struct hop_params *params,
503 size_t fixed_size)
504{
505 int num_hops = tal_count(sp->hops);
506 size_t fillerSize = sphinx_path_payloads_size(sp) -
507 sphinx_hop_size(&sp->hops[num_hops - 1]);
508 size_t last_hop_size = sphinx_hop_size(&sp->hops[num_hops - 1]);
509 int prefill_offset =
510 fixed_size - fillerSize - last_hop_size - prefill_size;
511 struct secret shared_secret;
512
513 /* Generate the prefill stream, which cancels out the layers of
514 * encryption that will be applied while wrapping the onion. This
515 * leaves the middle, unused, section with all 0x00 bytes after
516 * encrypting. */
517 generate_prefill(routinginfo + prefill_offset, prefill_size,
518 fixed_size, sp, params);
519
520 /* Now fill in the obfuscation stream, which can be regenerated by the
521 * node processing this onion. */
522 sphinx_create_shared_secret(&shared_secret, sp->rendezvous_id, sp->session_key);
523 sphinx_prefill_stream_xor(routinginfo + prefill_offset, prefill_size, &shared_secret);
524}
525
526struct onionpacket *create_onionpacket(
527 const tal_t *ctx,

Callers 1

create_onionpacketFunction · 0.85

Calls 5

sphinx_hop_sizeFunction · 0.85
generate_prefillFunction · 0.85

Tested by

no test coverage detected