aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-04-09 19:24:08 +0800
committerobscuren <geffobscura@gmail.com>2015-04-09 19:24:08 +0800
commitc6b25a40464edcb3de992f016bcaef59bb75fa7e (patch)
tree46e2af5e39f5f29e039768c1e95617979db60706 /crypto
parent8d059e54f1cac3cb7a44d9eb62336c514156b8d3 (diff)
parent558683d10cb059a55b181d94d82c2c7292f96680 (diff)
downloaddexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar.gz
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar.bz2
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar.lz
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar.xz
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.tar.zst
dexon-c6b25a40464edcb3de992f016bcaef59bb75fa7e.zip
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
Diffstat (limited to 'crypto')
-rw-r--r--crypto/crypto.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 7d1d51fa6..9865c87c4 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -121,7 +121,7 @@ func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error) {
// LoadECDSA loads a secp256k1 private key from the given file.
func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
- buf := make([]byte, 32)
+ buf := make([]byte, 64)
fd, err := os.Open(file)
if err != nil {
return nil, err
@@ -130,13 +130,20 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
if _, err := io.ReadFull(fd, buf); err != nil {
return nil, err
}
- return ToECDSA(buf), nil
+
+ key, err := hex.DecodeString(string(buf))
+ if err != nil {
+ return nil, err
+ }
+
+ return ToECDSA(key), 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)
+ k := hex.EncodeToString(FromECDSA(key))
+ return ioutil.WriteFile(file, []byte(k), 0600)
}
func GenerateKey() (*ecdsa.PrivateKey, error) {