From bb800319674e8a0f22769ae4af668c66e9536b15 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Sat, 13 Oct 2018 16:36:13 +0800 Subject: core: crypto: ecdsa: add method to create PrivateKey from ecdsa.PrivateKey (#195) --- core/crypto/ecdsa/ecdsa.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'core') diff --git a/core/crypto/ecdsa/ecdsa.go b/core/crypto/ecdsa/ecdsa.go index 0196c47..9556981 100644 --- a/core/crypto/ecdsa/ecdsa.go +++ b/core/crypto/ecdsa/ecdsa.go @@ -57,6 +57,15 @@ func NewPrivateKey() (*PrivateKey, error) { }, nil } +// NewPrivateKeyFromECDSA creates a new PrivateKey structure from +// ecdsa.PrivateKey. +func NewPrivateKeyFromECDSA(key *ecdsa.PrivateKey) *PrivateKey { + return &PrivateKey{ + privateKey: *key, + publicKey: *newPublicKey(key), + } +} + // newPublicKey creates a new PublicKey structure. func newPublicKey(prvKey *ecdsa.PrivateKey) *publicKey { return &publicKey{ -- cgit v1.2.3