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

Function wrap_onionreply

common/sphinx.c:806–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804}
805
806struct onionreply *wrap_onionreply(const tal_t *ctx,
807 const struct secret *shared_secret,
808 const struct onionreply *reply)
809{
810 struct secret key;
811 struct onionreply *result = tal(ctx, struct onionreply);
812
813 /* BOLT #4:
814 *
815 * The erring node then generates a new key, using the key type `ammag`.
816 * This key is then used to generate a pseudo-random stream, which is
817 * in turn applied to the packet using `XOR`.
818 */
819 subkey_from_hmac("ammag", shared_secret, &key);
820 result->contents = tal_dup_talarr(result, u8, reply->contents);
821 xor_cipher_stream(result->contents, &key, tal_bytelen(result->contents));
822 return result;
823}
824
825u8 *unwrap_onionreply(const tal_t *ctx,
826 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