mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 13:47:19 +00:00
keys: simplify code a bit
No functional changes.
This commit is contained in:
parent
eace588e48
commit
fecc7a3dd6
1 changed files with 2 additions and 11 deletions
|
@ -34,20 +34,11 @@ func NewSecp256k1PrivateKey() (*PrivateKey, error) {
|
||||||
|
|
||||||
// newPrivateKeyOnCurve creates a new random private key using curve c.
|
// newPrivateKeyOnCurve creates a new random private key using curve c.
|
||||||
func newPrivateKeyOnCurve(c elliptic.Curve) (*PrivateKey, error) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &PrivateKey{
|
return &PrivateKey{*pk}, nil
|
||||||
ecdsa.PrivateKey{
|
|
||||||
PublicKey: ecdsa.PublicKey{
|
|
||||||
Curve: c,
|
|
||||||
X: x,
|
|
||||||
Y: y,
|
|
||||||
},
|
|
||||||
D: new(big.Int).SetBytes(priv),
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPrivateKeyFromHex returns a Secp256k1 PrivateKey created from the
|
// NewPrivateKeyFromHex returns a Secp256k1 PrivateKey created from the
|
||||||
|
|
Loading…
Reference in a new issue