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:
Rusty Russell
2020-01-23 16:24:10 +10:30
parent 1099f6a5e1
commit 262e4c840f
6 changed files with 31 additions and 30 deletions

View File

@@ -107,12 +107,12 @@ struct onionpacket *create_onionpacket(
/**
* onion_shared_secret - calculate ECDH shared secret between nodes.
*
* @secret: the shared secret (32 bytes long)
* @secret: the shared secret
* @pubkey: the public key of the other node
* @privkey: the private key of this node (32 bytes long)
*/
bool onion_shared_secret(
u8 *secret,
struct secret *secret,
const struct onionpacket *packet,
const struct privkey *privkey);
@@ -130,7 +130,7 @@ bool onion_shared_secret(
struct route_step *process_onionpacket(
const tal_t * ctx,
const struct onionpacket *packet,
const u8 *shared_secret,
const struct secret *shared_secret,
const u8 *assocdata,
const size_t assocdatalen
);