brontide/noise: use static default ephemeral keygen closure

This commit is contained in:
Conner Fromknecht 2019-02-15 18:13:43 -08:00
parent 785740493e
commit 04febab85c
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

View File

@ -51,6 +51,12 @@ var (
// lightningPrologue is the noise prologue that is used to initialize
// the brontide noise handshake.
lightningPrologue = []byte("lightning")
// ephemeralGen is the default ephemeral key generator, used to derive a
// unique ephemeral key for each brontide handshake.
ephemeralGen = func() (*btcec.PrivateKey, error) {
return btcec.NewPrivateKey(btcec.S256())
}
)
// TODO(roasbeef): free buffer pool?
@ -385,12 +391,9 @@ func NewBrontideMachine(initiator bool, localPub *btcec.PrivateKey,
initiator, lightningPrologue, localPub, remotePub,
)
m := &Machine{handshakeState: handshake}
// With the initial base machine created, we'll assign our default
// version of the ephemeral key generator.
m.ephemeralGen = func() (*btcec.PrivateKey, error) {
return btcec.NewPrivateKey(btcec.S256())
m := &Machine{
handshakeState: handshake,
ephemeralGen: ephemeralGen,
}
// With the default options established, we'll now process all the