richardkiss/pycoin — pull request #10 by mflaxman (2013-11-19 19:14:50+00:00)
Title: Switch from `/dev/urandom` to `/dev/random`

From the linux man page (http://www.linuxmanpages.com/man4/random.4.php):

"When read, /dev/urandom device will return as many bytes as are requested. As a result, if there is not sufficient entropy in the entropy pool, the returned values are theoretically vulnerable to a cryptographic attack..."

Perhaps this is paranoia, but for something as critical as generating bitcoin wallet keys being extra cautious seems prudent. The downside is that when generating a large number of wallet keys dev/random could block (same link):

"When the entropy pool is empty, reads from /dev/random will block until additional environmental noise is gathered."

I did some non-scientific testing and found I was able to call dev_random_entropy() 10,000 times on my laptop from /dev/random and /dev/urandom in ~46 seconds each. I can't say if there would be blocking issues on a fresh-install of a VM (say that only has shell access) or if my script had called dev_random_entropy() 100x more times. Even if there were potential blocking issues, I think it'd be better to risk massive key generation being a little slow due to blocking vs being a little insecure. Of course users could always decide to use /dev/urandom if they didn't want to risk blocking, this is just changing the default/reference example.

Thanks for releasing such an awesome library (and blog) Richard, it's really great! Apologies if my comment is incorrect, you're much more knowledgeable on this topic than I am.