| 812 | } |
| 813 | |
| 814 | struct 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 | |
| 837 | struct sphinx_compressed_onion * |
| 838 | sphinx_compress(const tal_t *ctx, const struct onionpacket *packet, |
no test coverage detected