In this commit, we eliminate the final allocation that takes place when we write out messages. Once again this was escaping to the heap, so we make it an attribute on the Machine struct, which allows pure static allocation. ``` goos: darwin goarch: arm64 pkg: github.com/lightningnetwork/lnd/brontide cpu: Apple M4 Max BenchmarkWriteMessage-16 25840 46376 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25646 46672 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25874 46391 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25512 46427 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25760 46309 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25789 46520 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25602 46619 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25766 46464 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25820 46487 ns/op 2 B/op 0 allocs/op BenchmarkWriteMessage-16 25634 46553 ns/op 2 B/op 0 allocs/op PASS ok github.com/lightningnetwork/lnd/brontide 16.907s ```
brontide
The brontide package implements a secure crypto messaging protocol based off of the Noise Protocol Framework. The package exposes the raw state machine that handles the handshake and subsequent message encryption/decryption scheme. Additionally, the package exposes a net.Conn and a net.Listener interface implementation which allows the encrypted transport to be seamlessly integrated into a codebase.
The secure messaging scheme implemented within this package is described in detail in BOLT #8 of the Lightning Network specifications.
This package has intentionally been designed so it can be used as a standalone package for any projects needing secure encrypted+authenticated communications between network enabled programs.
Installation and Updating
$ go get -u github.com/lightningnetwork/lnd/brontide