Commit Graph
83 Commits
Author SHA1 Message Date
Eng Zer Jun b796b747ed brontide: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-13 17:01:35 +08:00
yyforyongyu 0735522194 multi: fix make fmt 2022-08-23 22:10:24 +08:00
Tommy Volk 9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Oliver Gugger 7dfe4018ce multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger dfdc2bff8b multi: run gosimports 2022-02-10 11:02:01 +01:00
Olaoluwa Osuntokun 8c6dbc9ffa brontide: when decrypting re-use the allocated ciphertext buf
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.
2021-08-27 16:57:12 -07:00
Olaoluwa Osuntokun 02509025d5 brontide: add new benchmark to measure allocs for header+body decrypt 2021-08-27 16:57:09 -07:00
Oliver Gugger 02267565fe multi: unify code blocks in READMEs 2021-01-22 09:14:11 +01:00
yyforyongyu e06768e4eb brontide: fix typo 2020-12-04 23:07:53 +08:00
Johan T. Halseth 8ca5342b37 brontide test: fix go 1.15 vet check 2020-09-24 11:20:48 +02:00
yyforyongyu fb67b58d3f brontide+tor:add timeout value for network connections 2020-09-16 11:50:03 +08:00
Oliver Gugger 535a22c590 server+brontide: use ECDH interface for brontide handshake 2020-05-20 09:06:56 +02:00
Andras Banki-Horvath 556e3525ea misc: fix error formatting in multiple files 2020-04-24 19:15:08 +02:00
yyforyongyu 4be1a4d0ec multi: fix typos 2020-03-27 16:59:18 +08:00
nsa 7c316b9194 brontide: add SetCurveToNil function 2020-01-30 16:45:59 -05:00
Lars Lehtonen 4d4da3c07c brontide: fix goroutine in test 2019-09-13 16:50:53 +00:00
Conner Fromknecht 6bc32871fd brontide/conn: expose WriteMessage and Flush on brontide.Conn
This commit exposes the WriteMessage and Flush interfaces of the
underlying brontide.Machine, such that callers can have greater
flexibility in when blocking network operations take place.
2019-04-22 16:04:53 -07:00
Conner Fromknecht 12ec999252 brontide/noise_test: defer wait group decrement
If any of the checks in the goroutine fail, the test will deadlock since
the waitgroup is never released.
2019-04-22 16:04:37 -07:00
Conner Fromknecht e3728da478 brontide/noise_test: add TestFlush 2019-04-22 16:04:24 -07:00
Conner Fromknecht 333caac09c brontide/noise_test: add timeoutWriter 2019-04-22 16:04:08 -07:00
Conner Fromknecht 73cf352daa brontide/conn: migrate to WriteMessage + Flush
This commit modifies WriteMessage to only perform encryption on the
passed plaintext, and buffer the ciphertext within the connection
object. We then modify internal uses of WriteMessage to follow with a
call to Flush, which actually writes the message to the wire.
Additionally, since WriteMessage does not actually perform the write
itself, the io.Writer argument is removed from the function signature
and all call sites.
2019-04-22 16:03:56 -07:00
Conner Fromknecht ed8fe4bc82 brontide/noise: add Flush method
This commit adds a Flush method to the brontide.Machine, which can write
out a buffered message to an io.Writer. This is a preliminary change
which will allow the encryption of the plaintext to be done in a
distinct method from actually writing the bytes to the wire.
2019-04-22 16:03:39 -07:00
Conner Fromknecht 8ac8d95b54 brontide/conn: expose ReadNextHeader+ReadNextBody 2019-02-21 20:11:19 -08:00
Conner Fromknecht 93ce4a7575 brontide/noise: compose ReadMessage from ReadHeader+ReadBody 2019-02-21 20:11:05 -08:00
Conner Fromknecht 2900d8aff8 brontide/noise: take read buffers from pool, return w/ finalizer 2019-02-15 19:33:23 -08:00
Conner Fromknecht ca4226d429 brontide/listener: handle SetReadDeadline errors 2019-02-15 18:14:02 -08:00
Conner Fromknecht 41940c6c9e brontide/conn: handle read timeout errors 2019-02-15 18:13:52 -08:00
Conner Fromknecht 04febab85c brontide/noise: use static default ephemeral keygen closure 2019-02-15 18:13:43 -08:00
Conner Fromknecht 785740493e brontide/noise: use statically allocated prologue 2019-02-15 18:13:34 -08:00
Conner Fromknecht 1ded697e8d multi: sort import paths with gofmt 2018-08-02 18:20:49 -07:00
Olaoluwa Osuntokun 6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Wilmer Paulino da273fdaa9 brontide: identify remote address of failed connection 2018-06-27 20:43:52 -07:00
practicalswift 663c396235 multi: fix a-vs-an typos 2018-04-17 19:02:04 -07:00
Olaoluwa Osuntokun 406fdbbf64 brontide: increase timeout to 5s 2018-04-05 15:54:47 -07:00
Olaoluwa Osuntokun d82f67cc1d brontide: decrease handshake timeout to 1s 2018-04-02 15:56:47 -07:00
Conner Fromknecht c22b46d462 brontide/noise_test: test parallel handshakes 2018-04-02 12:51:44 -07:00
Conner Fromknecht 782a8088eb brontide/listener: allow parallel handshakes 2018-04-01 15:49:31 -07:00
Olaoluwa Osuntokun 0c16ab6b32 brontide: reduce memory allocs by using static buf for next header+msg
In this commit, we reduce the total number of allocations that a
brontide session will incur over its lifetime. Profiling on one of my
nodes showed that we were generating a lot of garbage due to
re-creating a 65KB buffer to read the next message each time the
ReadMessage method was called.

To reduce the total number of memory allocations, we’ll now simply
re-use a buffer for both the cipher text header, and the cipher text
itself.
2018-02-24 19:30:45 -08:00
practicalswift a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
MeshCollider 945be73bca brontide: Make dialer parameter in brontide.Dial non-optional 2018-02-05 17:37:46 -08:00
MeshCollider 4affab7bd7 multi: Addressing Tor support review comments 2018-02-05 17:37:46 -08:00
nsa 8c482f2be7 multi: Added a NetInterface to clean up config.go
This commit adds a new interface named NetInterface and two
implementations of it: RegularNet & TorProxyNet. These two structs
are used in config.go in an attempt to clean up the code and
abstract away the dialer and DNS functions.
2018-02-05 17:37:46 -08:00
nsaandMeshCollider e2142c778f multi: Added Tor support
This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun 94b10c6c06 Merge pull request #593 from AdamISZ/noise_tests
Add tests for key rotation from BOLT8 test vectors
2018-01-31 12:38:58 -08:00
Adam Gibson a6c0ba0c35 Add tests for key rotation from BOLT8 test vectors
This adds a test of encryption/decryption of 1002 copies
of a message "hello" so as to test the test vectors in the
final section of BOLT 8 ("transport-message test").
It also corrects some typos in the preceding section of the
same function (TestBolt0008TestVectors).
2018-01-28 06:38:21 +01:00
Adam Gibson cd7f40422f Fix trivial comment errors in noise.go 2018-01-11 16:49:38 +02:00
Matt Drollette adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Olaoluwa Osuntokun b3000b621b brontide: within tests, listen on localhost rather than all interfaces 2017-11-01 15:30:57 -07:00
Olaoluwa Osuntokun eb84d34b8d brontide: don't run tests that use establishTestConnection in parallel 2017-11-01 15:12:13 -07:00
Olaoluwa Osuntokun 6a42e9057d brontide: ensure connections are closed after test completion 2017-11-01 13:55:49 -07:00