From 785740493e99ef5a175d5edde99659b83fdccac9 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 15 Feb 2019 18:13:34 -0800 Subject: [PATCH] brontide/noise: use statically allocated prologue --- brontide/noise.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/brontide/noise.go b/brontide/noise.go index 9a87f424..681b234d 100644 --- a/brontide/noise.go +++ b/brontide/noise.go @@ -47,6 +47,10 @@ var ( // the cipher session exceeds the maximum allowed message payload. ErrMaxMessageLengthExceeded = errors.New("the generated payload exceeds " + "the max allowed message length of (2^16)-1") + + // lightningPrologue is the noise prologue that is used to initialize + // the brontide noise handshake. + lightningPrologue = []byte("lightning") ) // TODO(roasbeef): free buffer pool? @@ -377,8 +381,9 @@ type Machine struct { func NewBrontideMachine(initiator bool, localPub *btcec.PrivateKey, remotePub *btcec.PublicKey, options ...func(*Machine)) *Machine { - handshake := newHandshakeState(initiator, []byte("lightning"), localPub, - remotePub) + handshake := newHandshakeState( + initiator, lightningPrologue, localPub, remotePub, + ) m := &Machine{handshakeState: handshake}