<p>Yoroi is using the <a href="https://github.com/bitcoinjs/bip39" rel="nofollow noreferrer"><code>bip39</code> JavaScript library</a> to generate the mnemonic.</p>
<p>When we look at <a href="https://github.com/bitcoinjs/bip39/blob/master/src/index.js#L139-L146" rel="nofollow noreferrer">its code</a>, we can discover the generation is actually pretty simple:</p>
<pre><code>function generateMnemonic(strength, rng, wordlist) {
    strength = strength || 128;
    if (strength % 32 !== 0) {
        throw new TypeError(INVALID_ENTROPY);
    }
    rng = rng || randomBytes;
    return entropyToMnemonic(rng(strength / 8), wordlist);
}
</code></pre>
<p>We see that as no random number generator (<code>rnd</code>) is defined, it uses the <a href="https://github.com/crypto-browserify/randombytes" rel="nofollow noreferrer"><code>randombytes</code> library</a> by default, which is in place using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues" rel="nofollow noreferrer">Crypto.getRandomValues()</a> function that is provided from your browser.</p>
<p>To sum this up, Yoroi is using randomness algorithm of your browser, which - depending on the browser - is your system-level entropy source.</p>

CC BY-SA 4.0
2021-06-02T07:32:30.083Z
2021-06-02T07:32:30.083Z
Marek Mahut - StakeNuts
<p>What randomness algo does Yoroi use for the wallet generation? Interested in seeing how secure it is.</p>

<yoroi><randomness>
What randomness algorithm does Yoroi use for wallet generation?
# What randomness algorithm does Yoroi use for wallet generation?

(Asked by: username_0 on 2021-06-01)

What randomness algo does Yoroi use for the wallet generation? Interested in seeing how secure it is.

**Tags:** yoroi, randomness

---

## 1 answers

### Answer by username_1 on 2021-06-02. Score: 1 | Accepted answer

Yoroi is using the bip39 JavaScript library to generate the mnemonic.
When we look at its code, we can discover the generation is actually pretty simple:
function generateMnemonic(strength, rng, wordlist) {
    strength = strength || 128;
    if (strength % 32 !== 0) {
        throw new TypeError(INVALID_ENTROPY);
    }
    rng = rng || randomBytes;
    return entropyToMnemonic(rng(strength / 8), wordlist);
}

We see that as no random number generator (rnd) is defined, it uses the randombytes library by default, which is in place using the Crypto.getRandomValues() function that is provided from your browser.
To sum this up, Yoroi is using randomness algorithm of your browser, which - depending on the browser - is your system-level entropy source.


---

