aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto.go
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-09-28 17:19:23 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-10-09 20:47:55 +0800
commitf32fa075f14d2b3a1213098274e0ba88c7761283 (patch)
tree6d198e22e34105f35a7e60a7b3376a97682f06ad /crypto/crypto.go
parent1d20b0247c35f440d3fdc3d21de19b2d5256c3cf (diff)
downloaddexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar.gz
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar.bz2
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar.lz
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar.xz
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.tar.zst
dexon-f32fa075f14d2b3a1213098274e0ba88c7761283.zip
core/secp256k1: update libsecp256k1 Go wrapper and tests
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r--crypto/crypto.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index b3a8d730b..672fb069a 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -198,7 +198,9 @@ func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error) {
return nil, fmt.Errorf("hash is required to be exactly 32 bytes (%d)", len(hash))
}
- sig, err = secp256k1.Sign(hash, common.LeftPadBytes(prv.D.Bytes(), prv.Params().BitSize/8))
+ seckey := common.LeftPadBytes(prv.D.Bytes(), prv.Params().BitSize/8)
+ defer zeroBytes(seckey)
+ sig, err = secp256k1.Sign(hash, seckey)
return
}
@@ -337,3 +339,9 @@ func PubkeyToAddress(p ecdsa.PublicKey) common.Address {
pubBytes := FromECDSAPub(&p)
return common.BytesToAddress(Sha3(pubBytes[1:])[12:])
}
+
+func zeroBytes(bytes []byte) {
+ for i := range bytes {
+ bytes[i] = 0
+ }
+}