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

Function sphinx_decompress

common/sphinx.c:892–913  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

890}
891
892struct onionpacket *sphinx_decompress(const tal_t *ctx,
893 const struct sphinx_compressed_onion *src,
894 const struct secret *shared_secret)
895{
896 struct onionpacket *res = tal(ctx, struct onionpacket);
897 size_t srclen = tal_bytelen(src->routinginfo);
898 size_t prefill_size = ROUTING_INFO_SIZE - srclen;
899
900 res->version = src->version;
901 res->ephemeralkey = src->ephemeralkey;
902 res->hmac = src->hmac;
903
904 /* Decompress routinginfo by copying the unmodified prefix, setting
905 * the compressed suffix to 0x00 bytes and then xoring the obfuscation
906 * stream in place. */
907 res->routinginfo = tal_arrz(res, u8, ROUTING_INFO_SIZE);
908 memcpy(res->routinginfo, src->routinginfo, srclen);
909 sphinx_prefill_stream_xor(res->routinginfo + srclen, prefill_size,
910 shared_secret);
911
912 return res;
913}
914
915struct sphinx_compressed_onion *
916sphinx_compress(const tal_t *ctx, const struct onionpacket *packet,

Callers 1

decompressFunction · 0.85

Calls 2

tal_bytelenFunction · 0.85

Tested by

no test coverage detected