vbuterin/bitcoinjs-lib — pull request #3 by shesek (2013-11-27 04:21:18+00:00)
Title: Some RNG improvments

- Seed jsbn's RNG with a CSPRNG when available
- Use `H(message||privkey||random)` for picking K for signatures

Using `H(message||privkey||random)` ensures that K is always unique (since its based on the transaction hash) and that it contains data that is hard for an attacker to guess (since it contains the private key). This is the recommend way to generate K values, and is how bitcoin-qt does that. The random data is not really necessary, but can't really hurt either.

---

I actually think that its better to get rid of jsbn's rng and always use window.crypto's getRandomValues() or nodejs's randomValues(), and refuse to work at all if neither of those are available - but that's quite an extreme change and will break compatibility with some browses. If you're okay with doing that, I'll send a new pull request.