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

Function sphinx_compressed_onion_serialize

common/sphinx.c:937–954  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

935}
936
937u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion)
938{
939 size_t routelen = tal_bytelen(onion->routinginfo);
940 size_t len = VERSION_SIZE + PUBKEY_SIZE + routelen + HMAC_SIZE;
941 u8 *dst = tal_arr(ctx, u8, len);
942 u8 der[PUBKEY_CMPR_LEN];
943 int p = 0;
944
945 pubkey_to_der(der, &onion->ephemeralkey);
946
947 write_buffer(dst, &onion->version, VERSION_SIZE, &p);
948 write_buffer(dst, der, PUBKEY_SIZE, &p);
949 write_buffer(dst, onion->routinginfo, routelen, &p);
950 write_buffer(dst, onion->hmac.bytes, sizeof(onion->hmac.bytes), &p);
951
952 assert(p == len);
953 return dst;
954}
955
956struct sphinx_compressed_onion *
957sphinx_compressed_onion_deserialize(const tal_t *ctx, const u8 *src)

Callers 1

do_generateFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
pubkey_to_derFunction · 0.85
write_bufferFunction · 0.85

Tested by

no test coverage detected