sphinx: Expose the shared secret creation function

This commit is contained in:
Christian Decker
2020-03-02 19:39:16 +01:00
committed by Rusty Russell
parent 49a3321d7e
commit fd37c5b672
3 changed files with 37 additions and 11 deletions

View File

@@ -310,8 +310,23 @@ static void decompress(char *hexprivkey, char *hexonion)
pubkey_from_der(compressed + 1, PUBKEY_SIZE, &ephkey);
decompressed = sphinx_decompress(NULL, compressed, &shared_secret);
printf("Decompressed Onion: %s\n", tal_hex(NULL, decompressed));
tinyonion = sphinx_compressed_onion_deserialize(NULL, compressed);
if (tinyonion == NULL)
errx(1, "Could not deserialize compressed onion");
if (!sphinx_create_shared_secret(&shared_secret,
&tinyonion->ephemeralkey,
&rendezvous_key.secret))
errx(1,
"Could not generate shared secret from ephemeral key %s "
"and private key %s",
pubkey_to_hexstr(NULL, &ephkey), hexprivkey);
onion = sphinx_decompress(NULL, tinyonion, &shared_secret);
if (onion == NULL)
errx(1, "Could not decompress compressed onion");
printf("Decompressed Onion: %s\n", tal_hex(NULL, serialize_onionpacket(NULL, onion)));
}
/* Tal wrappers for opt. */