struct secret: use everywhere.

We alternated between using a sha256 and using a privkey, but there are
numerous places where we have a random 32 bytes which are neither.

This fixes many of them (plus, struct privkey is now defined in terms of
struct secret).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-05-06 11:49:44 +09:30
parent 42601c29d7
commit b99c5620ef
39 changed files with 250 additions and 215 deletions

View File

@@ -878,7 +878,6 @@ static void their_htlc_added(struct peer *peer, struct htlc *htlc,
struct peer *only_dest)
{
struct invoice *invoice;
struct privkey pk;
struct onionpacket *packet;
struct route_step *step = NULL;
@@ -909,15 +908,13 @@ static void their_htlc_added(struct peer *peer, struct htlc *htlc,
return;
}
//FIXME: dirty trick to retrieve unexported state
memcpy(&pk, peer->dstate->secret, sizeof(pk));
packet = parse_onionpacket(peer,
htlc->routing, tal_count(htlc->routing));
if (packet) {
u8 shared_secret[32];
if (onion_shared_secret(shared_secret, packet, &pk))
if (onion_shared_secret(shared_secret, packet,
peer->dstate->privkey))
step = process_onionpacket(packet, packet,
shared_secret,
htlc->rhash.u.u8,