|
|
|
@ -19,8 +19,6 @@ package randentropy |
|
|
|
|
import ( |
|
|
|
|
crand "crypto/rand" |
|
|
|
|
"io" |
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/crypto/sha3" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
var Reader io.Reader = &randEntropy{} |
|
|
|
@ -34,14 +32,6 @@ func (*randEntropy) Read(bytes []byte) (n int, err error) { |
|
|
|
|
return len(bytes), nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// TODO: copied from crypto.go , move to sha3 package?
|
|
|
|
|
func Sha3(data []byte) []byte { |
|
|
|
|
d := sha3.NewKeccak256() |
|
|
|
|
d.Write(data) |
|
|
|
|
|
|
|
|
|
return d.Sum(nil) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetEntropyCSPRNG(n int) []byte { |
|
|
|
|
mainBuff := make([]byte, n) |
|
|
|
|
_, err := io.ReadFull(crand.Reader, mainBuff) |
|
|
|
|