From fecc7a3dd611f798d0393fbe1b8489f485c87888 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 17 Jun 2021 21:54:46 +0300 Subject: [PATCH] keys: simplify code a bit No functional changes. --- pkg/crypto/keys/private_key.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/pkg/crypto/keys/private_key.go b/pkg/crypto/keys/private_key.go index adb4460c9..f27f92145 100644 --- a/pkg/crypto/keys/private_key.go +++ b/pkg/crypto/keys/private_key.go @@ -34,20 +34,11 @@ func NewSecp256k1PrivateKey() (*PrivateKey, error) { // newPrivateKeyOnCurve creates a new random private key using curve c. func newPrivateKeyOnCurve(c elliptic.Curve) (*PrivateKey, error) { - priv, x, y, err := elliptic.GenerateKey(c, rand.Reader) + pk, err := ecdsa.GenerateKey(c, rand.Reader) if err != nil { return nil, err } - return &PrivateKey{ - ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: c, - X: x, - Y: y, - }, - D: new(big.Int).SetBytes(priv), - }, - }, nil + return &PrivateKey{*pk}, nil } // NewPrivateKeyFromHex returns a Secp256k1 PrivateKey created from the