From aab84e53dc3d8f944d3b2be499bba136f079c729 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Mon, 24 Sep 2018 08:47:24 +0300 Subject: [PATCH] Ephemeral rendezvous client generates key using seckp256k1 curve --- Gopkg.lock | 4 ++-- discovery/proxy_test.go | 2 +- discovery/rendezvous.go | 2 +- discovery/rendezvous_test.go | 15 +++++++++++++++ vendor/github.com/status-im/rendezvous/client.go | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 47c2355ed..ad68b6ce8 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -767,7 +767,7 @@ [[projects]] branch = "master" - digest = "1:b9b4aaa95bb880c345f400d7de8d5023731f71a9dfd4ff62ec77a74acfda529e" + digest = "1:b88d64c27ed467659fa0ee1806bc790b88c37bcbff0b8fcd1b97d6a3ee7f9703" name = "github.com/status-im/rendezvous" packages = [ ".", @@ -775,7 +775,7 @@ "server", ] pruneopts = "NUT" - revision = "7fe5bc0fd1c58bb7f7bec64656d8b821bec8338f" + revision = "55370cdfd9f288059b03c04e23784bb8829a894c" [[projects]] digest = "1:572c783a763db6383aca3179976eb80e4c900f52eba56cba8bb2e3cea7ce720e" diff --git a/discovery/proxy_test.go b/discovery/proxy_test.go index 48d47d070..2b7ee2c92 100644 --- a/discovery/proxy_test.go +++ b/discovery/proxy_test.go @@ -21,7 +21,7 @@ func TestProxyToRendezvous(t *testing.T) { stop = make(chan struct{}) wg sync.WaitGroup ) - client, err := rendezvous.NewTemporary() + client, err := rendezvous.NewEphemeral() require.NoError(t, err) reg.Add(topic, id) wg.Add(1) diff --git a/discovery/rendezvous.go b/discovery/rendezvous.go index 5e90c2858..4b10ec85b 100644 --- a/discovery/rendezvous.go +++ b/discovery/rendezvous.go @@ -75,7 +75,7 @@ func (r *Rendezvous) Running() bool { func (r *Rendezvous) Start() error { r.mu.Lock() defer r.mu.Unlock() - client, err := rendezvous.NewTemporary() + client, err := rendezvous.NewEphemeral() if err != nil { return err } diff --git a/discovery/rendezvous_test.go b/discovery/rendezvous_test.go index 4c97592be..77b5369e5 100644 --- a/discovery/rendezvous_test.go +++ b/discovery/rendezvous_test.go @@ -59,3 +59,18 @@ func TestRendezvousDiscovery(t *testing.T) { close(stop) close(period) } + +func BenchmarkRendezvousStart(b *testing.B) { + identity, err := crypto.GenerateKey() + require.NoError(b, err) + addr, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/7777") + require.NoError(b, err) + node := discover.NewNode(discover.PubkeyID(&identity.PublicKey), net.IP{10, 10, 10, 10}, 10, 20) + + b.ResetTimer() + for n := 0; n < b.N; n++ { + c, err := NewRendezvous([]ma.Multiaddr{addr}, identity, node) + require.NoError(b, err) + require.NoError(b, c.Start()) + } +} diff --git a/vendor/github.com/status-im/rendezvous/client.go b/vendor/github.com/status-im/rendezvous/client.go index aaba4d8e9..a4bffe380 100644 --- a/vendor/github.com/status-im/rendezvous/client.go +++ b/vendor/github.com/status-im/rendezvous/client.go @@ -21,8 +21,8 @@ import ( var logger = log.New("package", "rendezvous/client") -func NewTemporary() (c Client, err error) { - priv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader) +func NewEphemeral() (c Client, err error) { + priv, _, err := crypto.GenerateKeyPairWithReader(crypto.Secp256k1, 0, rand.Reader) // bits are ignored with edwards or secp251k1 if err != nil { return Client{}, err }