From 2b32a36d90514f408320b3269dc9fe3f674c52bf Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 20 Sep 2019 23:37:38 -0700 Subject: [PATCH] incorporates code review comments from @raulk; changes KeyPairFromKey to KeyPairFromStdKey and improves godoc. --- crypto/key_not_openssl.go | 4 ++-- crypto/key_openssl.go | 4 ++-- crypto/key_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crypto/key_not_openssl.go b/crypto/key_not_openssl.go index 9b85aef..ae8b01f 100644 --- a/crypto/key_not_openssl.go +++ b/crypto/key_not_openssl.go @@ -11,8 +11,8 @@ import ( "golang.org/x/crypto/ed25519" ) -// KeyPairFromKey generates a new private and public key from an input private key -func KeyPairFromKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { +// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys +func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { if priv == nil { return nil, nil, ErrNilPrivateKey } diff --git a/crypto/key_openssl.go b/crypto/key_openssl.go index 3eae98b..4545492 100644 --- a/crypto/key_openssl.go +++ b/crypto/key_openssl.go @@ -13,8 +13,8 @@ import ( "golang.org/x/crypto/ed25519" ) -// KeyPairFromKey generates a new private and public key from an input private key -func KeyPairFromKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { +// KeyPairFromStdKey wraps standard library (and secp256k1) private keys in libp2p/go-libp2p-core/crypto keys +func KeyPairFromStdKey(priv crypto.PrivateKey) (PrivKey, PubKey, error) { if priv == nil { return nil, nil, ErrNilPrivateKey } diff --git a/crypto/key_test.go b/crypto/key_test.go index 470d067..aff2bad 100644 --- a/crypto/key_test.go +++ b/crypto/key_test.go @@ -90,7 +90,7 @@ func TestKeyPairFromKey(t *testing.T) { }, } { t.Run(fmt.Sprintf("%v", i), func(t *testing.T) { - priv, pub, err := KeyPairFromKey(tt.in) + priv, pub, err := KeyPairFromStdKey(tt.in) if err != nil { t.Fatal(err) }