From 1ba8294e75f9b1e6bded10fc689abf6c6294da42 Mon Sep 17 00:00:00 2001 From: James Stanley Date: Sun, 28 Aug 2016 13:54:45 +0100 Subject: [PATCH] Use Bitcoin::Util::randInt instead of rand to generate keys (#6) Perl's built-in rand is not cryptographically-secure. In particular, it is only seeded with 4 bytes of entropy. Bitcoin::Util::randInt appears to be an improvement but also hasn't been properly analysed. --- EC/DSA.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EC/DSA.pm b/EC/DSA.pm index e0a8ab9..240fb2b 100644 --- a/EC/DSA.pm +++ b/EC/DSA.pm @@ -80,7 +80,7 @@ sub public_key { sub random { my $this = shift; my $i = 0; - $i = 256*$i + int rand 256 for 1..32; + $i = 256*$i + int Bitcoin::Util::randInt(256) for 1..32; $this->new($i); }