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

Function wrap_onionreply

common/sphinx.c:738–757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738struct onionreply *wrap_onionreply(const tal_t *ctx,
739 const struct secret *shared_secret,
740 const struct onionreply *reply)
741{
742 struct secret key;
743 struct onionreply *result = tal(ctx, struct onionreply);
744
745 /* BOLT #4:
746 *
747 * The erring node then generates a new key, using the key type `ammag`.
748 * This key is then used to generate a pseudo-random stream, which is
749 * in turn applied to the packet using `XOR`.
750 *
751 * The obfuscation step is repeated by every hop along the return path.
752 */
753 subkey_from_hmac("ammag", shared_secret, &key);
754 result->contents = tal_dup_talarr(result, u8, reply->contents);
755 xor_cipher_stream(result->contents, &key, tal_bytelen(result->contents));
756 return result;
757}
758
759u8 *unwrap_onionreply(const tal_t *ctx,
760 const struct secret *shared_secrets,

Callers 3

unwrap_onionreplyFunction · 0.70
mk_failed_htlcFunction · 0.50
run_unit_testsFunction · 0.50

Calls 3

xor_cipher_streamFunction · 0.85
tal_bytelenFunction · 0.85
subkey_from_hmacFunction · 0.70

Tested by 1

run_unit_testsFunction · 0.40