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

Function generate_prefill

common/sphinx.c:318–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318static void generate_prefill(void *dst, size_t dstlen,
319 size_t fixed_size,
320 const struct sphinx_path *path,
321 struct hop_params *params)
322{
323 struct secret key;
324 size_t fillerStart, fillerSize;
325
326 memset(dst, 0, dstlen);
327 for (int i = 0; i < tal_count(path->hops); i++) {
328 subkey_from_hmac("rho", &params[i].secret, &key);
329
330 /* Sum up how many bytes have been used by previous hops,
331 * that gives us the start in the stream */
332 fillerSize = 0;
333 for (int j = 0; j < i; j++)
334 fillerSize += sphinx_hop_size(&path->hops[j]);
335 fillerStart = fixed_size - fillerSize - dstlen;
336
337 /* Apply the cipher-stream to the part of the filler that'll
338 * be added by this hop */
339 xor_cipher_stream_off(&key, fillerStart, dst, dstlen);
340 }
341}
342
343static void compute_blinding_factor(const struct pubkey *key,
344 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