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

Function sphinx_compressed_onion_serialize

common/sphinx.c:971–988  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

969}
970
971u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion)
972{
973 size_t routelen = tal_bytelen(onion->routinginfo);
974 size_t len = VERSION_SIZE + PUBKEY_SIZE + routelen + HMAC_SIZE;
975 u8 *dst = tal_arr(ctx, u8, len);
976 u8 der[PUBKEY_CMPR_LEN];
977 int p = 0;
978
979 pubkey_to_der(der, &onion->ephemeralkey);
980
981 write_buffer(dst, &onion->version, VERSION_SIZE, &p);
982 write_buffer(dst, der, PUBKEY_SIZE, &p);
983 write_buffer(dst, onion->routinginfo, routelen, &p);
984 write_buffer(dst, onion->hmac.bytes, sizeof(onion->hmac.bytes), &p);
985
986 assert(p == len);
987 return dst;
988}
989
990struct sphinx_compressed_onion *
991sphinx_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