aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-23 21:00:06 +0800
committerzelig <viktor.tron@gmail.com>2015-03-27 03:00:18 +0800
commitc4ea921876b0535022882c568b5cc6b0269db7d4 (patch)
treeed01e6cae2563fd61e7d4eb4964e5fe2fcbcb744 /crypto/crypto.go
parent658204bafcba6332e979aee690dc5cff6e46fb42 (diff)
downloadgo-tangerine-c4ea921876b0535022882c568b5cc6b0269db7d4.tar.gz
go-tangerine-c4ea921876b0535022882c568b5cc6b0269db7d4.tar.zst
go-tangerine-c4ea921876b0535022882c568b5cc6b0269db7d4.zip
import/export accounts
- cli: add passwordfile flag - cli: change unlock flag only takes account - cli: with unlock you are prompted for password or use passfile with password flag - cli: unlockAccount used in normal client start (run) and accountExport - cli: getPassword used in accountCreate and accountImport - accounts: Manager.Import, Manager.Export - crypto: SaveECDSA (to complement LoadECDSA) to save to file - crypto: NewKeyFromECDSA added (used in accountImport and New = generated constructor)
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index c3d47b629..2d26dd25e 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -139,6 +139,11 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
return ToECDSA(buf), nil
}
+// SaveECDSA saves a secp256k1 private key from the given file.
+func SaveECDSA(file string, key *ecdsa.PrivateKey) error {
+ return common.WriteFile(file, FromECDSA(key))
+}
+
func GenerateKey() (*ecdsa.PrivateKey, error) {
return ecdsa.GenerateKey(S256(), rand.Reader)
}