diff options
author | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
---|---|---|
committer | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
commit | 3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch) | |
tree | 401c52c4972a68229ea283a394a0b0a5f3cfdc8e /crypto/crypto.go | |
parent | a5330fe0c569b75cb8a524f60f7e8dc06498262b (diff) | |
parent | fe070ab5c32702033489f1b9d1655ea1b894c29e (diff) | |
download | dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2 dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip |
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r-- | crypto/crypto.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go index 8161769d3..e51726e62 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -79,7 +79,7 @@ func ToECDSA(d []byte) (*ecdsa.PrivateKey, error) { return toECDSA(d, true) } -// ToECDSAUnsafe blidly converts a binary blob to a private key. It should almost +// ToECDSAUnsafe blindly converts a binary blob to a private key. It should almost // never be used unless you are sure the input is valid and want to avoid hitting // errors due to bad origin encoding (0 prefixes cut off). func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey { @@ -98,6 +98,9 @@ func toECDSA(d []byte, strict bool) (*ecdsa.PrivateKey, error) { } priv.D = new(big.Int).SetBytes(d) priv.PublicKey.X, priv.PublicKey.Y = priv.PublicKey.Curve.ScalarBaseMult(d) + if priv.PublicKey.X == nil { + return nil, errors.New("invalid private key") + } return priv, nil } |