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

Function generate_header_padding

common/sphinx.c:315–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313}
314
315static void generate_header_padding(void *dst, size_t dstlen,
316 size_t fixed_size,
317 const struct sphinx_path *path,
318 struct hop_params *params)
319{
320 struct secret key;
321 size_t fillerStart, fillerEnd, fillerSize;
322
323 memset(dst, 0, dstlen);
324 for (int i = 0; i < tal_count(path->hops) - 1; i++) {
325 subkey_from_hmac("rho", &params[i].secret, &key);
326
327 /* Sum up how many bytes have been used by previous hops,
328 * that gives us the start in the stream */
329 fillerSize = 0;
330 for (int j = 0; j < i; j++)
331 fillerSize += sphinx_hop_size(&path->hops[j]);
332 fillerStart = fixed_size - fillerSize;
333
334 /* The filler will dangle off of the end by the current
335 * hop-size, we'll make sure to copy it into the correct
336 * position in the next step. */
337 fillerEnd = fixed_size + sphinx_hop_size(&path->hops[i]);
338
339 /* Apply the cipher-stream to the part of the filler that'll
340 * be added by this hop */
341 xor_cipher_stream_off(&key, fillerStart,
342 dst, fillerEnd - fillerStart);
343 }
344}
345
346static void generate_prefill(void *dst, size_t dstlen,
347 size_t fixed_size,

Callers 1

create_onionpacketFunction · 0.85

Calls 3

sphinx_hop_sizeFunction · 0.85
xor_cipher_stream_offFunction · 0.85
subkey_from_hmacFunction · 0.70

Tested by

no test coverage detected