From aa73420207cba02a68befdbb8667f1e6ceed3f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Tue, 23 May 2017 14:58:03 +0300 Subject: accounts/keystore, crypto: enforce 256 bit keys on import --- internal/ethapi/api.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'internal') diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 62edc695c..a22c15eca 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -19,7 +19,6 @@ package ethapi import ( "bytes" "context" - "encoding/hex" "errors" "fmt" "math/big" @@ -283,12 +282,11 @@ func fetchKeystore(am *accounts.Manager) *keystore.KeyStore { // ImportRawKey stores the given hex encoded ECDSA key into the key directory, // encrypting it with the passphrase. func (s *PrivateAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { - hexkey, err := hex.DecodeString(privkey) + key, err := crypto.HexToECDSA(privkey) if err != nil { return common.Address{}, err } - - acc, err := fetchKeystore(s.am).ImportECDSA(crypto.ToECDSA(hexkey), password) + acc, err := fetchKeystore(s.am).ImportECDSA(key, password) return acc.Address, err } -- cgit v1.2.3