sphinx: Migrate sphinx compression to new interface

It also removes the duplicate compression code and serialization code.
This commit is contained in:
Christian Decker
2020-03-03 18:32:06 +01:00
committed by Rusty Russell
parent 6dd14a2039
commit ef86ee0bae
3 changed files with 13 additions and 40 deletions

View File

@@ -32,7 +32,9 @@ static void do_generate(int argc, char **argv,
struct secret session_key;
struct secret *shared_secrets;
struct sphinx_path *sp;
struct sphinx_compressed_onion *comp;
u8 *serialized;
struct onionpacket *packet;
const u8* tmp_assocdata =tal_dup_arr(ctx, u8, assocdata,
ASSOC_DATA_SIZE, 0);
memset(&session_key, 'A', sizeof(struct secret));
@@ -93,13 +95,17 @@ static void do_generate(int argc, char **argv,
}
}
struct onionpacket *res = create_onionpacket(ctx, sp, &shared_secrets);
packet = create_onionpacket(ctx, sp, &shared_secrets);
if (rvnode_id != NULL)
printf("Rendezvous onion: %s\n",
tal_hex(ctx, serialize_compressed_onion(ctx, sp, res)));
if (rvnode_id != NULL) {
comp = sphinx_compress(ctx, packet, sp);
serialized = sphinx_compressed_onion_serialize(ctx, comp);
printf("Rendezvous onion: %s\n", tal_hex(ctx, serialized));
} else {
assert(sphinx_compress(ctx, packet, sp) == NULL);
}
u8 *serialized = serialize_onionpacket(ctx, res);
serialized = serialize_onionpacket(ctx, packet);
if (!serialized)
errx(1, "Error serializing message.");
printf("%s\n", tal_hex(ctx, serialized));