libbitcoin-perl
libbitcoin-perl copied to clipboard
EC::DSA uses Perl's 'rand' to generate Bitcoin keys
Perl's rand is not even remotely cryptographically-secure.
This should probably use, at minimum, Bitcoin::Util::randInt. And it would probably be better for Bitcoin::Util::randInt to use Bytes::Random::Secure or similar instead of its custom thing.
In particular, from a quick glance through the Perl source, rand is seeded with only 4 bytes. Which means libbitcoin-perl will, on first invocation, generate one of only 4 billion different keys.
I wrote a program that simply generates and prints a private key. I ran it 1.3 million times, and of the 1.3 million keys, 219 appeared twice. This is not safe.