Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EC::DSA uses Perl's 'rand' to generate Bitcoin keys #6

Open
jes opened this issue Aug 28, 2016 · 2 comments
Open

EC::DSA uses Perl's 'rand' to generate Bitcoin keys #6

jes opened this issue Aug 28, 2016 · 2 comments

Comments

@jes
Copy link
Contributor

jes commented Aug 28, 2016

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.

@jes
Copy link
Contributor Author

jes commented Aug 28, 2016

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.

jes added a commit to jes/libbitcoin-perl that referenced this issue Aug 28, 2016
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.
@jes
Copy link
Contributor Author

jes commented Aug 29, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant