aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/secp256k1
diff options
context:
space:
mode:
authorGustav Simonsson <gustav.simonsson@gmail.com>2015-02-05 00:06:06 +0800
committerGustav Simonsson <gustav.simonsson@gmail.com>2015-02-11 05:49:28 +0800
commit8c056aebe10c8c56f7c25889780b04e00f9ca00b (patch)
tree9186028c43f33dec61d21924866248da2c559330 /crypto/secp256k1
parente40c1c62ce0c2d9567066d84ea74fd24b424a81a (diff)
downloaddexon-8c056aebe10c8c56f7c25889780b04e00f9ca00b.tar.gz
dexon-8c056aebe10c8c56f7c25889780b04e00f9ca00b.tar.zst
dexon-8c056aebe10c8c56f7c25889780b04e00f9ca00b.zip
Set both key generation and ECDSA nonce to use mixed entropy
* Move random entropy functions to new package randentropy * Add function to get n bytes entropy where up to first 32 bytes are mixed with OS entropy sources
Diffstat (limited to 'crypto/secp256k1')
-rw-r--r--crypto/secp256k1/secp256.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go
index c01598b84..c1e37629e 100644
--- a/crypto/secp256k1/secp256.go
+++ b/crypto/secp256k1/secp256.go
@@ -15,6 +15,7 @@ import "C"
import (
"bytes"
"errors"
+ "github.com/ethereum/go-ethereum/crypto/randentropy"
"unsafe"
)
@@ -68,7 +69,7 @@ func GenerateKeyPair() ([]byte, []byte) {
const seckey_len = 32
var pubkey []byte = make([]byte, pubkey_len)
- var seckey []byte = RandByte(seckey_len)
+ var seckey []byte = randentropy.GetEntropyMixed(seckey_len)
var pubkey_ptr *C.uchar = (*C.uchar)(unsafe.Pointer(&pubkey[0]))
var seckey_ptr *C.uchar = (*C.uchar)(unsafe.Pointer(&seckey[0]))
@@ -124,7 +125,7 @@ int secp256k1_ecdsa_sign_compact(const unsigned char *msg, int msglen,
*/
func Sign(msg []byte, seckey []byte) ([]byte, error) {
- nonce := RandByte(32)
+ nonce := randentropy.GetEntropyMixed(32)
var sig []byte = make([]byte, 65)
var recid C.int