aboutsummaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-05-23 19:58:03 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-05-23 19:58:03 +0800
commitaa73420207cba02a68befdbb8667f1e6ceed3f4d (patch)
tree76b4fb7ffc9440e7ff27b22dc367355d4fc84f5c /internal
parent3556962053267def82f1a9f9e97a26f7b7c1450e (diff)
downloaddexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar.gz
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar.bz2
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar.lz
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar.xz
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.tar.zst
dexon-aa73420207cba02a68befdbb8667f1e6ceed3f4d.zip
accounts/keystore, crypto: enforce 256 bit keys on import
Diffstat (limited to 'internal')
-rw-r--r--internal/ethapi/api.go6
1 files changed, 2 insertions, 4 deletions
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
}