diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-27 04:08:15 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-03-27 04:08:15 +0800 |
commit | 829240c3252d9da09c9000e42b0686425a313e8b (patch) | |
tree | 5b5fe5aeb443a8fd8a325743490b8fb416a903d3 /crypto/crypto.go | |
parent | 658204bafcba6332e979aee690dc5cff6e46fb42 (diff) | |
parent | 7577d1261403dbabdb30e21415d34b4e5da466ec (diff) | |
download | dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar.gz dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar.bz2 dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar.lz dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar.xz dexon-829240c3252d9da09c9000e42b0686425a313e8b.tar.zst dexon-829240c3252d9da09c9000e42b0686425a313e8b.zip |
Merge pull request #550 from ethersphere/frontier/cli-key
import/export accounts
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r-- | crypto/crypto.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go index c3d47b629..442942c6c 100644 --- a/crypto/crypto.go +++ b/crypto/crypto.go @@ -9,6 +9,7 @@ import ( "crypto/sha256" "fmt" "io" + "io/ioutil" "os" "encoding/hex" @@ -139,6 +140,12 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) { return ToECDSA(buf), nil } +// SaveECDSA saves a secp256k1 private key to the given file with restrictive +// permissions +func SaveECDSA(file string, key *ecdsa.PrivateKey) error { + return ioutil.WriteFile(file, FromECDSA(key), 0600) +} + func GenerateKey() (*ecdsa.PrivateKey, error) { return ecdsa.GenerateKey(S256(), rand.Reader) } |