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

Function generate_prefill

common/sphinx.c:346–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346static void generate_prefill(void *dst, size_t dstlen,
347 size_t fixed_size,
348 const struct sphinx_path *path,
349 struct hop_params *params)
350{
351 struct secret key;
352 size_t fillerStart, fillerSize;
353
354 memset(dst, 0, dstlen);
355 for (int i = 0; i < tal_count(path->hops); i++) {
356 subkey_from_hmac("rho", &params[i].secret, &key);
357
358 /* Sum up how many bytes have been used by previous hops,
359 * that gives us the start in the stream */
360 fillerSize = 0;
361 for (int j = 0; j < i; j++)
362 fillerSize += sphinx_hop_size(&path->hops[j]);
363 fillerStart = fixed_size - fillerSize - dstlen;
364
365 /* Apply the cipher-stream to the part of the filler that'll
366 * be added by this hop */
367 xor_cipher_stream_off(&key, fillerStart, dst, dstlen);
368 }
369}
370
371static void compute_blinding_factor(const struct pubkey *key,
372 const struct secret *sharedsecret,

Callers 1

sphinx_prefillFunction · 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