aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-04-09 05:03:47 +0800
committerBas van Kervel <basvankervel@ziggo.nl>2015-04-09 05:03:47 +0800
commitb3a3fdf9a447bd2b3f862380d87c675138da78e7 (patch)
tree77a46c32738d3a3625a7dcbb0cd292e40054cdf2 /crypto
parent6284604b52e075e454e61f2933cadaaf9ded364b (diff)
downloadgo-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar.gz
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar.bz2
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar.lz
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar.xz
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.tar.zst
go-tangerine-b3a3fdf9a447bd2b3f862380d87c675138da78e7.zip
Support for import/export hex encoded keys, closes #635
Diffstat (limited to 'crypto')
-rw-r--r--crypto/crypto.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 7d1d51fa6..6e3ffbd4a 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,13 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
if _, err := io.ReadFull(fd, buf); err != nil {
return nil, err
}
- return ToECDSA(buf), nil
+ return ToECDSA(common.HexBytes2Bytes(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)
+ return ioutil.WriteFile(file, common.Bytes2HexBytes(FromECDSA(key)), 0600)
}
func GenerateKey() (*ecdsa.PrivateKey, error) {