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

Function wrap_onionreply

common/sphinx.c:832–849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

830}
831
832struct onionreply *wrap_onionreply(const tal_t *ctx,
833 const struct secret *shared_secret,
834 const struct onionreply *reply)
835{
836 struct secret key;
837 struct onionreply *result = tal(ctx, struct onionreply);
838
839 /* BOLT #4:
840 *
841 * The erring node then generates a new key, using the key type `ammag`.
842 * This key is then used to generate a pseudo-random stream, which is
843 * in turn applied to the packet using `XOR`.
844 */
845 subkey_from_hmac("ammag", shared_secret, &key);
846 result->contents = tal_dup_talarr(result, u8, reply->contents);
847 xor_cipher_stream(result->contents, &key, tal_bytelen(result->contents));
848 return result;
849}
850
851u8 *unwrap_onionreply(const tal_t *ctx,
852 const struct secret *shared_secrets,

Callers 6

injectonion_failFunction · 0.85
mk_failed_htlcFunction · 0.85
failFunction · 0.85
unwrap_onionreplyFunction · 0.85
run_unit_testsFunction · 0.85

Calls 3

xor_cipher_streamFunction · 0.85
tal_bytelenFunction · 0.85
subkey_from_hmacFunction · 0.70

Tested by 1

run_unit_testsFunction · 0.68