Ephemeral rendezvous client generates key using seckp256k1 curve

This commit is contained in:
Dmitry 2018-09-24 08:47:24 +03:00 committed by Dmitry Shulyak
parent 8aef7c4f15
commit aab84e53dc
5 changed files with 21 additions and 6 deletions

4
Gopkg.lock generated
View File

@ -767,7 +767,7 @@
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:b9b4aaa95bb880c345f400d7de8d5023731f71a9dfd4ff62ec77a74acfda529e" digest = "1:b88d64c27ed467659fa0ee1806bc790b88c37bcbff0b8fcd1b97d6a3ee7f9703"
name = "github.com/status-im/rendezvous" name = "github.com/status-im/rendezvous"
packages = [ packages = [
".", ".",
@ -775,7 +775,7 @@
"server", "server",
] ]
pruneopts = "NUT" pruneopts = "NUT"
revision = "7fe5bc0fd1c58bb7f7bec64656d8b821bec8338f" revision = "55370cdfd9f288059b03c04e23784bb8829a894c"
[[projects]] [[projects]]
digest = "1:572c783a763db6383aca3179976eb80e4c900f52eba56cba8bb2e3cea7ce720e" digest = "1:572c783a763db6383aca3179976eb80e4c900f52eba56cba8bb2e3cea7ce720e"

View File

@ -21,7 +21,7 @@ func TestProxyToRendezvous(t *testing.T) {
stop = make(chan struct{}) stop = make(chan struct{})
wg sync.WaitGroup wg sync.WaitGroup
) )
client, err := rendezvous.NewTemporary() client, err := rendezvous.NewEphemeral()
require.NoError(t, err) require.NoError(t, err)
reg.Add(topic, id) reg.Add(topic, id)
wg.Add(1) wg.Add(1)

View File

@ -75,7 +75,7 @@ func (r *Rendezvous) Running() bool {
func (r *Rendezvous) Start() error { func (r *Rendezvous) Start() error {
r.mu.Lock() r.mu.Lock()
defer r.mu.Unlock() defer r.mu.Unlock()
client, err := rendezvous.NewTemporary() client, err := rendezvous.NewEphemeral()
if err != nil { if err != nil {
return err return err
} }

View File

@ -59,3 +59,18 @@ func TestRendezvousDiscovery(t *testing.T) {
close(stop) close(stop)
close(period) 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())
}
}

View File

@ -21,8 +21,8 @@ import (
var logger = log.New("package", "rendezvous/client") var logger = log.New("package", "rendezvous/client")
func NewTemporary() (c Client, err error) { func NewEphemeral() (c Client, err error) {
priv, _, err := crypto.GenerateKeyPairWithReader(crypto.RSA, 2048, rand.Reader) priv, _, err := crypto.GenerateKeyPairWithReader(crypto.Secp256k1, 0, rand.Reader) // bits are ignored with edwards or secp251k1
if err != nil { if err != nil {
return Client{}, err return Client{}, err
} }