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

Function sphinx_compressed_onion_serialize

common/sphinx.c:859–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

857}
858
859u8 *sphinx_compressed_onion_serialize(const tal_t *ctx, const struct sphinx_compressed_onion *onion)
860{
861 size_t routelen = tal_bytelen(onion->routinginfo);
862 size_t len = VERSION_SIZE + PUBKEY_SIZE + routelen + HMAC_SIZE;
863 u8 *dst = tal_arr(ctx, u8, len);
864 u8 der[PUBKEY_CMPR_LEN];
865 int p = 0;
866
867 pubkey_to_der(der, &onion->ephemeralkey);
868
869 write_buffer(dst, &onion->version, VERSION_SIZE, &p);
870 write_buffer(dst, der, PUBKEY_SIZE, &p);
871 write_buffer(dst, onion->routinginfo, routelen, &p);
872 write_buffer(dst, onion->hmac.bytes, sizeof(onion->hmac.bytes), &p);
873
874 assert(p == len);
875 return dst;
876}
877
878struct sphinx_compressed_onion *
879sphinx_compressed_onion_deserialize(const tal_t *ctx, const u8 *src)

Callers 1

do_generateFunction · 0.85

Calls 3

tal_bytelenFunction · 0.85
write_bufferFunction · 0.85
pubkey_to_derFunction · 0.50

Tested by

no test coverage detected