| 890 | } |
| 891 | |
| 892 | struct 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 | |
| 915 | struct sphinx_compressed_onion * |
| 916 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
no test coverage detected