diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-16 01:46:57 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2015-10-16 01:46:57 +0800 |
commit | f466243417f60531998e8b500f2bb043af5b3d2a (patch) | |
tree | 9f8387b65d2a9d54a94ed26bc6a57ecfde3489f6 /crypto/crypto.go | |
parent | cefe5c80b1cdcab606a169c0be65d9d2ba9bc941 (diff) | |
parent | f32fa075f14d2b3a1213098274e0ba88c7761283 (diff) | |
download | dexon-f466243417f60531998e8b500f2bb043af5b3d2a.tar.gz dexon-f466243417f60531998e8b500f2bb043af5b3d2a.tar.zst dexon-f466243417f60531998e8b500f2bb043af5b3d2a.zip |
Merge pull request #1853 from Gustav-Simonsson/libsecp256k1_update
Update libsecp256k1, Go wrapper and tests
Diffstat (limited to 'crypto/crypto.go')
-rw-r--r-- | crypto/crypto.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go index 272050106..49793ded9 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 } @@ -326,3 +328,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 + } +} |