<p><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/170328341bdcf2a22d6ee6df1df587ea4e83c8a9/src/ecpair.js#L90" rel="nofollow noreferrer">This</a> code calls <a href="https://github.com/crypto-browserify/randombytes/blob/master/browser.js#L25" rel="nofollow noreferrer">this</a> code, which calls <a href="https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues#Example" rel="nofollow noreferrer"><code>crypto.getRandomValues</code></a>, which is a trustworthy cryptographically secure random number generator. It's secure enough to compete with bitaddress.org, as long as one's browser was not hacked.</p>

CC BY-SA 3.0
2018-02-14T13:13:04.397Z
Thank you, that was a big help. I think the phrase "Implementations are also required to use a seed with enough entropy, like a system-level entropy source." on the page you mentioned is interesting. So I guess, if I use bitcoinjs in my application, I would still have to provide a seed myself. If not I wonder where BitcoinJS takes it from.
Dalit Sairio
CC BY-SA 3.0
2018-02-14T13:37:03.823Z
@DalitSairio "system-level entropy source" is called by browsers. Browsers will ask the system for entropy, and the `getRandomValues` will be secure enough. You don't need to provide a seed.
MCCCS
CC BY-SA 4.0
2022-04-24T08:01:50.170Z
@MCCCS please give your feedback on "easyseed(1) is also the first component for my campaign to urge that users stop using saved webpages to generate their Bitcoin magic bits. ... But most importantly, as a rule of thumb, Javascript code cannot reliably acquire proper entropy for generating random numbers.  This is a persistent general problem, and specifically subject to extended fretting by the author[1] of the most popular BIP39 webpage.

easyseed(1) reads bits straight off /dev/urandom, or from user-provided keymat." https://bitcointalk.org/index.php?topic=2664861.0
HansBKK
CC BY-SA 3.0
2018-02-13T13:22:13.407Z
2018-02-13T13:22:13.407Z
MCCCS
<p>The library BitcoinJS (<a href="https://github.com/bitcoinjs" rel="nofollow noreferrer">https://github.com/bitcoinjs</a>) has a method called <code>makeRandom()</code>. Where does its entropy (randomness) come from? Is it as secure as the method from <a href="http://bitaddress.org/" rel="nofollow noreferrer">http://bitaddress.org/</a> (moving around the mouse), or even more so?</p>

<bitcoinjs><random>
Where does the entropy of BitcoinJS' makeRandom() come from?
Dalit Sairio
# Where does the entropy of BitcoinJS' makeRandom() come from?

(Asked by: username_0 on 2018-02-13)

The library BitcoinJS (<https://github.com/bitcoinjs>) has a method called `makeRandom()`. Where does its entropy (randomness) come from? Is it as secure as the method from <http://bitaddress.org/> (moving around the mouse), or even more so?

**Tags:** bitcoinjs, random


---

## 1 answers

### Answer by username_1 on 2018-02-13. Score: 1 | Accepted answer

[This](https://github.com/bitcoinjs/bitcoinjs-lib/blob/170328341bdcf2a22d6ee6df1df587ea4e83c8a9/src/ecpair.js#L90) code calls [this](https://github.com/crypto-browserify/randombytes/blob/master/browser.js#L25) code, which calls [`crypto.getRandomValues`](https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues#Example), which is a trustworthy cryptographically secure random number generator. It's secure enough to compete with bitaddress.org, as long as one's browser was not hacked.

> **Comments:**
> **username_0**: Thank you, that was a big help. I think the phrase "Implementations are also required to use a seed with enough entropy, like a system-level entropy source." on the page you mentioned is interesting. So I guess, if I use bitcoinjs in my application, I would still have to provide a seed myself. If not I wonder where BitcoinJS takes it from.  
> **username_1**: @username_0 "system-level entropy source" is called by browsers. Browsers will ask the system for entropy, and the `getRandomValues` will be secure enough. You don't need to provide a seed.  
> **username_2**: @username_1 please give your feedback on "easyseed(1) is also the first component for my campaign to urge that users stop using saved webpages to generate their Bitcoin magic bits. ... But most importantly, as a rule of thumb, Javascript code cannot reliably acquire proper entropy for generating random numbers.  This is a persistent general problem, and specifically subject to extended fretting by the author[1] of the most popular BIP39 webpage.  easyseed(1) reads bits straight off /dev/urandom, or from user-provided keymat." https://bitcointalk.org/index.php?topic=2664861.0  

---

