aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorBas van Kervel <basvankervel@ziggo.nl>2015-04-09 16:59:37 +0800
committerBas van Kervel <basvankervel@ziggo.nl>2015-04-09 16:59:37 +0800
commitef393da9334adcf99187c0825df025596ae41fb3 (patch)
tree5c9074d00cb774d3b739fe735d3e73636b69d12f /crypto/crypto.go
parentb3a3fdf9a447bd2b3f862380d87c675138da78e7 (diff)
downloadgo-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar.gz
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar.bz2
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar.lz
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar.xz
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.tar.zst
go-tangerine-ef393da9334adcf99187c0825df025596ae41fb3.zip
removed utility function and implemented hex conversation in crypto functions
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index 6e3ffbd4a..9865c87c4 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -130,13 +130,20 @@ func LoadECDSA(file string) (*ecdsa.PrivateKey, error) {
if _, err := io.ReadFull(fd, buf); err != nil {
return nil, err
}
- return ToECDSA(common.HexBytes2Bytes(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, common.Bytes2HexBytes(FromECDSA(key)), 0600)
+ k := hex.EncodeToString(FromECDSA(key))
+ return ioutil.WriteFile(file, []byte(k), 0600)
}
func GenerateKey() (*ecdsa.PrivateKey, error) {