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

Function sphinx_decompress

common/sphinx.c:926–947  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

924}
925
926struct onionpacket *sphinx_decompress(const tal_t *ctx,
927 const struct sphinx_compressed_onion *src,
928 const struct secret *shared_secret)
929{
930 struct onionpacket *res = tal(ctx, struct onionpacket);
931 size_t srclen = tal_bytelen(src->routinginfo);
932 size_t prefill_size = ROUTING_INFO_SIZE - srclen;
933
934 res->version = src->version;
935 res->ephemeralkey = src->ephemeralkey;
936 res->hmac = src->hmac;
937
938 /* Decompress routinginfo by copying the unmodified prefix, setting
939 * the compressed suffix to 0x00 bytes and then xoring the obfuscation
940 * stream in place. */
941 res->routinginfo = tal_arrz(res, u8, ROUTING_INFO_SIZE);
942 memcpy(res->routinginfo, src->routinginfo, srclen);
943 sphinx_prefill_stream_xor(res->routinginfo + srclen, prefill_size,
944 shared_secret);
945
946 return res;
947}
948
949struct sphinx_compressed_onion *
950sphinx_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