mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-03 22:34:21 +01:00
sphinx: use struct secret for shared secret.
Generally I prefer structures over u8, since the size is enforced at runtime; and in several places we were doing conversions as the code using Sphinx does treat struct secret as type of the secret. Note that passing an array is the same as passing the address, so changing from 'u8 secret[32]' to 'struct secret secret' means various 'secret' parameters change to '&secret'. Technically, '&secret' also would have worked before, since '&' is a noop on array, but that's always seemed a bit weird. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -105,7 +105,7 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion,
|
||||
struct route_step *step;
|
||||
struct onionpacket packet;
|
||||
enum onion_type why_bad;
|
||||
u8 shared_secret[32];
|
||||
struct secret shared_secret;
|
||||
if (!hex_decode(hexprivkey, strlen(hexprivkey), &seckey, sizeof(seckey)))
|
||||
errx(1, "Invalid private key hex '%s'", hexprivkey);
|
||||
|
||||
@@ -114,10 +114,10 @@ static struct route_step *decode_with_privkey(const tal_t *ctx, const u8 *onion,
|
||||
if (why_bad != 0)
|
||||
errx(1, "Error parsing message: %s", onion_type_name(why_bad));
|
||||
|
||||
if (!onion_shared_secret(shared_secret, &packet, &seckey))
|
||||
if (!onion_shared_secret(&shared_secret, &packet, &seckey))
|
||||
errx(1, "Error creating shared secret.");
|
||||
|
||||
step = process_onionpacket(ctx, &packet, shared_secret, assocdata,
|
||||
step = process_onionpacket(ctx, &packet, &shared_secret, assocdata,
|
||||
tal_bytelen(assocdata));
|
||||
return step;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user