aboutsummaryrefslogtreecommitdiffstats
path: root/mobile
diff options
context:
space:
mode:
authorFelix Lange <fjl@users.noreply.github.com>2017-05-25 04:30:47 +0800
committerGitHub <noreply@github.com>2017-05-25 04:30:47 +0800
commitef25b826e655f8e6a57fc7a05454bf356382bd5f (patch)
treec843d8b5ca0064804e55f5d66dd910c0c106fc05 /mobile
parent261b3e235160d30cc7176e02fd0a43f2b60409c6 (diff)
parent136f78ff0a324f7f79296143a6ab7c2dd8a2c37d (diff)
downloaddexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar.gz
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar.bz2
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar.lz
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar.xz
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.tar.zst
dexon-ef25b826e655f8e6a57fc7a05454bf356382bd5f.zip
Merge pull request #14502 from karalabe/mobile-import-ecdsa
Enforce 256 bit keys on raw import, support raw mobile imports
Diffstat (limited to 'mobile')
-rw-r--r--mobile/accounts.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/mobile/accounts.go b/mobile/accounts.go
index f5b7e81aa..977999c3a 100644
--- a/mobile/accounts.go
+++ b/mobile/accounts.go
@@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
+ "github.com/ethereum/go-ethereum/crypto"
)
const (
@@ -176,6 +177,11 @@ func (ks *KeyStore) NewAccount(passphrase string) (*Account, error) {
return &Account{account}, nil
}
+// UpdateAccount changes the passphrase of an existing account.
+func (ks *KeyStore) UpdateAccount(account *Account, passphrase, newPassphrase string) error {
+ return ks.keystore.Update(account.account, passphrase, newPassphrase)
+}
+
// ExportKey exports as a JSON key, encrypted with newPassphrase.
func (ks *KeyStore) ExportKey(account *Account, passphrase, newPassphrase string) (key []byte, _ error) {
return ks.keystore.Export(account.account, passphrase, newPassphrase)
@@ -190,9 +196,17 @@ func (ks *KeyStore) ImportKey(keyJSON []byte, passphrase, newPassphrase string)
return &Account{acc}, nil
}
-// UpdateAccount changes the passphrase of an existing account.
-func (ks *KeyStore) UpdateAccount(account *Account, passphrase, newPassphrase string) error {
- return ks.keystore.Update(account.account, passphrase, newPassphrase)
+// ImportECDSAKey stores the given encrypted JSON key into the key directory.
+func (ks *KeyStore) ImportECDSAKey(key []byte, passphrase string) (account *Account, _ error) {
+ privkey, err := crypto.ToECDSA(key)
+ if err != nil {
+ return nil, err
+ }
+ acc, err := ks.keystore.ImportECDSA(privkey, passphrase)
+ if err != nil {
+ return nil, err
+ }
+ return &Account{acc}, nil
}
// ImportPreSaleKey decrypts the given Ethereum presale wallet and stores