|
@ -13,11 +13,11 @@ |
|
|
#include <ccan/short_types/short_types.h> |
|
|
#include <ccan/short_types/short_types.h> |
|
|
#include <errno.h> |
|
|
#include <errno.h> |
|
|
#include <fcntl.h> |
|
|
#include <fcntl.h> |
|
|
#include <openssl/rand.h> |
|
|
|
|
|
#include <secp256k1.h> |
|
|
#include <secp256k1.h> |
|
|
#include <sys/stat.h> |
|
|
#include <sys/stat.h> |
|
|
#include <sys/types.h> |
|
|
#include <sys/types.h> |
|
|
#include <unistd.h> |
|
|
#include <unistd.h> |
|
|
|
|
|
#include <sodium/randombytes.h> |
|
|
|
|
|
|
|
|
struct secret { |
|
|
struct secret { |
|
|
/* Secret ID of our node; public is dstate->id. */ |
|
|
/* Secret ID of our node; public is dstate->id. */ |
|
@ -147,8 +147,7 @@ static void new_keypair(struct lightningd_state *dstate, |
|
|
struct privkey *privkey, struct pubkey *pubkey) |
|
|
struct privkey *privkey, struct pubkey *pubkey) |
|
|
{ |
|
|
{ |
|
|
do { |
|
|
do { |
|
|
if (RAND_bytes(privkey->secret, sizeof(privkey->secret)) != 1) |
|
|
randombytes_buf(privkey->secret, sizeof(privkey->secret)); |
|
|
fatal("Could not get random bytes for privkey"); |
|
|
|
|
|
} while (!pubkey_from_privkey(dstate->secpctx, privkey, pubkey)); |
|
|
} while (!pubkey_from_privkey(dstate->secpctx, privkey, pubkey)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -158,10 +157,7 @@ void peer_secrets_init(struct peer *peer) |
|
|
|
|
|
|
|
|
new_keypair(peer->dstate, &peer->secrets->commit, &peer->local.commitkey); |
|
|
new_keypair(peer->dstate, &peer->secrets->commit, &peer->local.commitkey); |
|
|
new_keypair(peer->dstate, &peer->secrets->final, &peer->local.finalkey); |
|
|
new_keypair(peer->dstate, &peer->secrets->final, &peer->local.finalkey); |
|
|
if (RAND_bytes(peer->secrets->revocation_seed.u.u8, |
|
|
randombytes_buf(peer->secrets->revocation_seed.u.u8, sizeof(peer->secrets->revocation_seed.u.u8)); |
|
|
sizeof(peer->secrets->revocation_seed.u.u8)) != 1) |
|
|
|
|
|
fatal("Could not get random bytes for revocation seed"); |
|
|
|
|
|
|
|
|
|
|
|
shachain_init(&peer->their_preimages); |
|
|
shachain_init(&peer->their_preimages); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|