mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
8c6dbc9ffa
In this commit, we implement a simple optimization that dramatically reduces the number of allocations we need to make when we decrypt a new message. Before this commit, we would pass in a `nil` value to the `Decrypt` method which meant that it would always allocate a new buffers. Rather than force this behavior, in this commit, we pass in the ciphertext buffer (with a length of zero), such that the decryption operation will simply copy the plaintext bytes over the cipher text in place. This works as the cipher text is always larger than the plaintext, since the plaintext doesn't have a MAC attached. The amount the perf increase, amount of allocations, and amount of bytes allocated are pretty nice: ``` benchmark old ns/op new ns/op delta BenchmarkReadHeaderAndBody-8 88652 75896 -14.39% benchmark old allocs new allocs delta BenchmarkReadHeaderAndBody-8 6 4 -33.33% benchmark old bytes new bytes delta BenchmarkReadHeaderAndBody-8 65664 128 -99.81% ``` Here old is without this change, and new with it. |
||
---|---|---|
.. | ||
bench_test.go | ||
conn.go | ||
listener.go | ||
noise_test.go | ||
noise.go | ||
README.md |
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