| 924 | } |
| 925 | |
| 926 | struct 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 | |
| 949 | struct sphinx_compressed_onion * |
| 950 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
no test coverage detected