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

Function sphinx_decompress

common/sphinx.c:814–835  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

812}
813
814struct onionpacket *sphinx_decompress(const tal_t *ctx,
815 const struct sphinx_compressed_onion *src,
816 const struct secret *shared_secret)
817{
818 struct onionpacket *res = tal(ctx, struct onionpacket);
819 size_t srclen = tal_bytelen(src->routinginfo);
820 size_t prefill_size = ROUTING_INFO_SIZE - srclen;
821
822 res->version = src->version;
823 res->ephemeralkey = src->ephemeralkey;
824 res->hmac = src->hmac;
825
826 /* Decompress routinginfo by copying the unmodified prefix, setting
827 * the compressed suffix to 0x00 bytes and then xoring the obfuscation
828 * stream in place. */
829 res->routinginfo = tal_arrz(res, u8, ROUTING_INFO_SIZE);
830 memcpy(res->routinginfo, src->routinginfo, srclen);
831 sphinx_prefill_stream_xor(res->routinginfo + srclen, prefill_size,
832 shared_secret);
833
834 return res;
835}
836
837struct sphinx_compressed_onion *
838sphinx_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