width: auto!important;
display: inline-block;
}
- .languages * {
+ .languages a {
padding-left: 10px;
}
+ .languages a:nth-of-type(1) {
+ margin-left: -12px;
+ padding-left: 0;
+ }
.monospace {
font-family: monospace;
}
<div class="form-group">
<div class="col-sm-2"></div>
<div class="col-sm-10">
- <p>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum)</p>
- <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a></p>
+ <p data-translate>You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum).</p>
+ <p data-translate-html>
+ For more info see the
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki" target="_blank">BIP39 spec</a>.
+ </p>
</div>
</div>
<div class="form-group generate-container">
<div class="col-sm-10">
<div class="form-inline">
<div class="input-group-inline">
+ <span data-translate>Generate a random mnemonic, or enter your own below</span>:
<button class="btn generate">Generate</button>
- <span>a random</span>
<select id="strength" class="strength form-control">
<option value="3">3</option>
<option value="6">6</option>
<option value="21">21</option>
<option value="24">24</option>
</select>
- word mnemonic, or enter your own below.
+ <span data-translate>words</span>
</div>
</div>
</div>
</div>
<div class="entropy-container hidden">
<div class="form-group text-danger">
- <label class="col-sm-2 control-label">Warning</label>
+ <label class="col-sm-2 control-label" data-translate>Warning</label>
<div class="col-sm-10 form-control-static">
- Entropy is an advanced feature.
- Your mnemonic may be insecure if this feature is used incorrectly.
- <a href="#entropy-notes">Read more</a>
+ <span data-translate>Entropy is an advanced feature. Your mnemonic may be insecure if this feature is used incorrectly.</span>
+ <a href="#entropy-notes" data-translate>Read more</a>
</div>
</div>
<div class="form-group">
- <label for="entropy" class="col-sm-2 control-label">Entropy</label>
+ <label for="entropy" class="col-sm-2 control-label" data-translate>Entropy</label>
<div class="col-sm-7">
- <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards"></textarea>
+ <textarea id="entropy" rows="2" class="entropy form-control" placeholder="Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards" data-translate-placeholder></textarea>
<div class="row">
- <label class="col-sm-3 control-label">Strength</label>
+ <label class="col-sm-3 control-label" data-translate>Strength</label>
<div class="strength col-sm-3 form-control-static"></div>
- <label class="col-sm-3 control-label">Event Count</label>
+ <label class="col-sm-3 control-label" data-translate>Event Count</label>
<div class="event-count col-sm-3 form-control-static"></div>
</div>
<div class="row">
- <label class="col-sm-3 control-label">Entropy Type</label>
+ <label class="col-sm-3 control-label" data-translate>Entropy Type</label>
<div class="type col-sm-3 form-control-static"></div>
- <label class="col-sm-3 control-label">Bits Per Event</label>
+ <label class="col-sm-3 control-label" data-translate>Bits Per Event</label>
<div class="bits-per-event col-sm-3 form-control-static"></div>
</div>
<div class="row">
- <label class="col-sm-3 control-label">Word Count</label>
+ <label class="col-sm-3 control-label" data-translate>Word Count</label>
<div class="word-count col-sm-3 form-control-static"></div>
- <label class="col-sm-3 control-label">Total Bits</label>
+ <label class="col-sm-3 control-label" data-translate>Total Bits</label>
<div class="bits col-sm-3 form-control-static"></div>
</div>
- <label class="col-sm-3 control-label">Filtered Entropy</label>
+ <label class="col-sm-3 control-label" data-translate>Filtered Entropy</label>
<div class="filtered col-sm-9 form-control-static"></div>
- <label class="col-sm-3 control-label">Raw Binary</label>
+ <label class="col-sm-3 control-label" data-translate>Raw Binary</label>
<div class="binary col-sm-9 form-control-static"></div>
- <label class="col-sm-3 control-label">Mnemonic Length</label>
+ <label class="col-sm-3 control-label" data-translate>Mnemonic Length</label>
<div class="col-sm-9">
<select class="mnemonic-length form-control">
- <option value="raw">From entropy length (3 words per 32 bits)</option>
- <option value="12">12 Words</option>
- <option value="15" selected>15 Words</option>
- <option value="18">18 Words</option>
- <option value="21">21 Words</option>
- <option value="24">24 Words</option>
+ <option value="raw" data-translate>From entropy length (3 words per 32 bits)</option>
+ <option value="12">12 <span data-translate>Words</span></option>
+ <option value="15" selected>15 <span data-translate>Words</option>
+ <option value="18">18 <span data-translate>Words</span></option>
+ <option value="21">21 <span data-translate>Words</span></option>
+ <option value="24">24 <span data-translate>Words</span></option>
</select>
</div>
</div>
<div class="col-sm-3">
- <p>Valid entropy values include:</p>
+ <p data-translate>Valid entropy values include:</p>
<ul>
- <li><strong>Binary</strong> [0-1]<br>101010011</li>
- <li><strong>Base 6</strong> [0-5]<br>123434014</li>
- <li><strong>Dice</strong> [1-6]<br>62535634</li>
- <li><strong>Base 10</strong> [0-9]<br>90834528</li>
- <li><strong>Hex</strong> [0-9A-F]<br>4187a8bfd9</li>
- <li><strong>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc</li>
+ <li><strong data-translate>Binary</strong> [0-1]<br>101010011</li>
+ <li><strong data-translate>Base 6</strong> [0-5]<br>123434014</li>
+ <li><strong data-translate>Dice</strong> [1-6]<br>62535634</li>
+ <li><strong data-translate>Base 10</strong> [0-9]<br>90834528</li>
+ <li><strong data-translate>Hex</strong> [0-9A-F]<br>4187a8bfd9</li>
+ <li><strong data-translate>Card</strong> [A2-9TJQK][CDHS]<br>ahqs9dtc</li>
</ul>
</div>
</div>
<div class="col-sm-10 checkbox">
<label>
<input type="checkbox" class="use-entropy">
- Supply my own source of entropy
+ <span data-translate>Supply my own source of entropy</span>
</label>
</div>
</div>
<div class="form-group">
- <label class="col-sm-2 control-label"></label>
+ <label class="col-sm-2 control-label" data-translate>Mnemonic Language</label>
<div class="col-sm-10 languages">
- <a href="#english">English</a>
- <a href="#japanese" title="Japanese">日本語</a>
- <a href="#spanish" title="Spanish">Español</a>
- <a href="#chinese_simplified" title="Chinese (Simplified)">中文(简体)</a>
- <a href="#chinese_traditional" title="Chinese (Traditional)">中文(繁體)</a>
- <a href="#french" title="French">Français</a>
- <a href="#italian" title="Italian">Italiano</a>
+ <div class="form-control no-border">
+ <a href="#english">English</a>
+ <a href="#japanese" title="Japanese">日本語</a>
+ <a href="#spanish" title="Spanish">Español</a>
+ <a href="#chinese_simplified" title="Chinese (Simplified)">中文(简体)</a>
+ <a href="#chinese_traditional" title="Chinese (Traditional)">中文(繁體)</a>
+ <a href="#french" title="French">Français</a>
+ <a href="#italian" title="Italian">Italiano</a>
+ </div>
</div>
</div>
<div class="form-group">
- <label for="phrase" class="col-sm-2 control-label">BIP39 Mnemonic</label>
+ <label for="phrase" class="col-sm-2 control-label" data-translate>BIP39 Mnemonic</label>
<div class="col-sm-10">
<textarea id="phrase" class="phrase form-control"></textarea>
</div>
</div>
<div class="form-group">
- <label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
+ <label for="passphrase" class="col-sm-2 control-label" data-translate>BIP39 Passphrase (optional)</label>
<div class="col-sm-10">
<textarea id="passphrase" class="passphrase form-control"></textarea>
</div>
</div>
<div class="form-group">
- <label for="seed" class="col-sm-2 control-label">BIP39 Seed</label>
+ <label for="seed" class="col-sm-2 control-label" data-translate>BIP39 Seed</label>
<div class="col-sm-10">
<textarea id="seed" class="seed form-control" readonly="readonly"></textarea>
</div>
</div>
<div class="form-group">
- <label for="network-phrase" class="col-sm-2 control-label">Coin</label>
+ <label for="network-phrase" class="col-sm-2 control-label" data-translate>Coin</label>
<div class="col-sm-10">
<select id="network-phrase" class="network form-control">
<!-- populated by javascript -->
</div>
</div>
<div class="form-group">
- <label for="root-key" class="col-sm-2 control-label">BIP32 Root Key</label>
+ <label for="root-key" class="col-sm-2 control-label" data-translate>BIP32 Root Key</label>
<div class="col-sm-10">
<textarea id="root-key" class="root-key form-control"></textarea>
</div>
<br>
<div class="col-sm-2"></div>
<div class="col-sm-10">
- <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a></p>
+ <p data-translate-html>
+ For more info see the
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">BIP44 spec</a>.
+ </p>
</div>
<div class="form-group">
<label for="purpose" class="col-sm-2 control-label">
- <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank">Purpose</a>
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#purpose" target="_blank" data-translate>Purpose</a>
</label>
<div class="col-sm-10">
<input id="purpose" type="text" class="purpose form-control" value="44">
</div>
<div class="form-group">
<label for="coin" class="col-sm-2 control-label">
- <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank">Coin</a>
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#registered-coin-types" target="_blank" data-translate>Coin</a>
</label>
<div class="col-sm-10">
<input id="coin" type="text" class="coin form-control" value="0">
</div>
<div class="form-group">
<label for="account" class="col-sm-2 control-label">
- <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank">Account</a>
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account" target="_blank" data-translate>Account</a>
</label>
<div class="col-sm-10">
<input id="account" type="text" class="account form-control" value="0">
</div>
<div class="form-group">
<label for="change" class="col-sm-2 control-label">
- <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank">External / Internal</a>
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#change" target="_blank" data-translate>External / Internal</a>
</label>
<div class="col-sm-10">
<input id="change" type="text" class="change form-control" value="0">
</div>
</div>
<div class="form-group">
- <label for="bip44-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
+ <label for="bip44-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label>
<div class="col-sm-10">
<input id="bip44-path" type="text" class="path form-control" value="m/44'/0'/0'/0" readonly="readonly">
</div>
<br>
<div class="col-sm-2"></div>
<div class="col-sm-10">
- <p>For more info see the <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a></p>
+ <p data-translate>
+ For more info see the
+ <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">BIP32 spec</a>
+ </p>
</div>
<div class="form-group">
- <label for="bip32-path" class="col-sm-2 control-label">BIP32 Derivation Path</label>
+ <label for="bip32-path" class="col-sm-2 control-label" data-translate>BIP32 Derivation Path</label>
<div class="col-sm-10">
<input id="bip32-path" type="text" class="path form-control" value="m/0">
</div>
<div class="col-sm-2"></div>
<label class="col-sm-10">
<input class="hardened-addresses" type="checkbox">
- Use hardened addresses
+ <span data-translate>Use hardened addresses</span>
</label>
</div>
<div class="form-group">
- <label for="mycelium-path" class="col-sm-2 control-label">Mycelium Wallet</label>
+ <label for="mycelium-path" class="col-sm-2 control-label" data-translate>Mycelium Wallet</label>
<div class="col-sm-10">
- <p class="form-control no-border">
- <code>m/44'/0'/0'</code> generates extended keys for import / export.
+ <p class="form-control no-border" data-translate-html>
+ <code>m/44'/0'/0'</code> generates extended keys for import / export
</p>
- <p class="form-control no-border">
- <code>m/44'/0'/1'</code> to generate the next account. Continue incrementing for more accounts (most use a single account).
+ <p class="form-control no-border" data-translate-html>
+ <code>m/44'/0'/1'</code> for the next account. Continue incrementing for more accounts (most use a single account).
</p>
- <p class="form-control no-border">
- <code>m/44'/0'/0'/0</code> to generate public addresses.
+ <p class="form-control no-border" data-translate-html>
+ <code>m/44'/0'/0'/0</code> generates public addresses
</p>
- <p class="form-control no-border">
- <code>m/44'/0'/0'/1</code> to generate change addresses.
+ <p class="form-control no-border" data-translate-html>
+ <code>m/44'/0'/0'/1</code> generates change addresses
</p>
- <p class="form-control no-border">
- For more info see the <a href="http://www.mycelium.com/" target="_blank">Mycelium Wallet homepage</a>
+ <p class="form-control no-border" data-translate-html>
+ For more info see the
+ <a href="http://www.mycelium.com/" target="_blank">Mycelium Wallet homepage</a>
</p>
</div>
</div>
<div class="form-group">
- <label for="core-path" class="col-sm-2 control-label">Bitcoin Core</label>
+ <label for="core-path" class="col-sm-2 control-label" data-translate>Bitcoin Core</label>
<div class="col-sm-10">
- <p class="form-control no-border">
+ <p class="form-control no-border" data-translate-html>
Use path <code>m/0'/0'</code> with hardened addresses.
</p>
- <p class="form-control no-border">
- For more info see the <a href="https://github.com/bitcoin/bitcoin/pull/8035" target="_blank">Bitcoin Core BIP32 implementation</a>
+ <p class="form-control no-border" data-translate-html>
+ For more info see the
+ <a href="https://github.com/bitcoin/bitcoin/pull/8035" target="_blank">Bitcoin Core BIP32 implementation</a>
</p>
</div>
</div>
<div class="form-group">
- <label class="col-sm-2 control-label">Block Explorers</label>
+ <label class="col-sm-2 control-label" data-translate>Block Explorers</label>
<div class="col-sm-10">
<p class="form-control no-border">
- Use path <code>m/44'/0'/0'</code>.
- Only enter the <code>xpub</code> extended key into block explorer search fields, never the <code>xprv</code> key.
+ <span data-translate-html>Use path <code>m/44'/0'/0'</code>.</span>
+ <span data-translate-html>Only enter the <code>xpub</code> extended key into block explorer search fields, never the <code>xprv</code> key.</span>
</p>
<p class="form-control no-border">
- Supported by <a href="https://blockchain.info/" target="_blank">blockchain.info</a>.
+ <span data-translate>Can be used with</span>:
+ <a href="https://blockchain.info/" target="_blank">blockchain.info</a>
</p>
</div>
</div>
</div>
<form class="form-horizontal" role="form">
<div class="form-group">
- <label for="extended-priv-key" class="col-sm-2 control-label">BIP32 Extended Key</label>
+ <label for="extended-priv-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Key</label>
<div class="col-sm-10">
<textarea id="extended-priv-key" class="extended-priv-key form-control" readonly="readonly"></textarea>
</div>
</div>
<div class="form-group">
- <label for="extended-pub-key" class="col-sm-2 control-label">BIP32 Extended Key (addresses only)</label>
+ <label for="extended-pub-key" class="col-sm-2 control-label" data-translate>BIP32 Extended Key (addresses only)</label>
<div class="col-sm-10">
<textarea id="extended-pub-key" class="extended-pub-key form-control" readonly="readonly"></textarea>
</div>
<div class="row">
<div class="col-md-12">
<h2>Derived Addresses</h2>
- <p>Note these addreses are derived from the <strong>BIP32 Extended Key</strong></p>
+ <p data-translate>Note these addreses are derived from the BIP32 Extended Key</p>
<table class="table table-striped">
<thead>
<th>
<div class="input-group">
- Path
- <button class="index-toggle">Toggle</button>
+ <span data-translate>Path</span>
+ <button class="index-toggle" data-translate>Toggle</button>
</div>
</th>
<th>
<div class="input-group">
- Address
- <button class="address-toggle">Toggle</button>
+ <span data-translate>Address</span>
+ <button class="address-toggle" data-translate>Toggle</button>
</div>
</th>
<th>
<div class="input-group">
- Public Key
- <button class="public-key-toggle">Toggle</button>
+ <span data-translate>Public Key</span>
+ <button class="public-key-toggle" data-translate>Toggle</button>
</div>
</th>
<th>
<div class="input-group">
- Private Key
- <button class="private-key-toggle">Toggle</button>
+ <span data-translate>Private Key</span>
+ <button class="private-key-toggle" data-translate>Toggle</button>
</div>
</th>
</thead>
</table>
</div>
</div>
- <span>Show next </button>
+ <span data-translate>Show more rows</span>:
<input type="number" class="rows-to-add" value="20">
- <button class="more">Show</button>
+ <button class="more" data-translate>Show</button>
<hr>
<div class="row">
<div class="col-md-12">
- <h2>More info</h2>
- <h3>BIP39 <span class="small">Mnemonic code for generating deterministic keys</span></h3>
- <p>
+ <h2 data-translate>More info</h2>
+ <h3>BIP39 <span class="small" data-translate>Mnemonic code for generating deterministic keys</span></h3>
+ <p data-translate-html>
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki">official BIP39 spec</a>
</p>
- <h3>BIP32 <span class="small">Hierarchical Deterministic Wallets</span></h3>
- <p>
+ <h3>BIP32 <span class="small" data-translate>Hierarchical Deterministic Wallets</span></h3>
+ <p data-translate-html>
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" target="_blank">official BIP32 spec</a>
- and see the demo at
+ </p>
+ <p data-translate-html>
+ See the demo at
<a href="http://bip32.org/" target="_blank">bip32.org</a>
</p>
- <h3>BIP44 <span class="small">Multi-Account Hierarchy for Deterministic Wallets</span></h3>
- <p>
+ <h3>BIP44 <span class="small" data-translate>Multi-Account Hierarchy for Deterministic Wallets</span></h3>
+ <p data-translate-html>
Read more at the
<a href="https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki" target="_blank">official BIP44 spec</a>
</p>
- <h3>Private Keys</h3>
+ <h3 data-translate>Private Keys</h3>
<p>
- Use private keys at
- <a href="https://web.archive.org/web/20150707020924/https://brainwallet.org/" target="_blank">brainwallet.org</a>,
- but be careful - it can be easy to make mistakes if you
- don't know what you're doing
+ <span data-translate-html>
+ Use private keys at
+ <a href="https://web.archive.org/web/20150707020924/https://brainwallet.org/" target="_blank">brainwallet.org</a>.
+ </span>
+ <span data-translate>Be careful - it can be easy to make mistakes if you don't know what you're doing.</span>
</p>
- <h3 id="entropy-notes">Entropy</h3>
+ <h3 id="entropy-notes" data-translate>Entropy</h3>
<p>
- Entropy values must be sourced from a
- <a href="https://en.wikipedia.org/wiki/Random_number_generation" target="_blank">strong source of randomness</a>.
- This means flipping a fair coin, rolling a fair dice, noise measurements etc. Do <strong>NOT</strong> use
- phrases from books, lyrics from songs, your birthday or steet address, keyboard mashing, or anything you <i>think</i>
- is random, because chances are <em>overwhelming</em> that it isn't random enough for the needs of this tool.
+ <span data-translate-html>
+ Entropy values must be sourced from a
+ <a href="https://en.wikipedia.org/wiki/Random_number_generation" target="_blank">strong source of randomness</a>.
+ </span>
+ <span data-translate>This means flipping a fair coin, rolling a fair dice, noise measurements etc.</span>
+ <span data-translate-html>
+ Do <strong>NOT</strong> use phrases from books, lyrics from songs, your birthday or steet address,
+ keyboard mashing, or anything you <i>think</i> is random, because chances are overwhelming it isn't
+ random enough for the needs of this tool.
+ </span>
</p>
<p>
- The random mnemonic generator on this page uses a
- <a href="https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues" target="_blank">cryptographically secure random number generator</a>,
- and can generally be trusted more than your own intuition about randomness.
- If cryptographic randomness isn't available in your browser, this page will show a warning and <i>will not generate
- random mnemonics</i>.
+ <span data-translate-html>
+ The random mnemonic generator on this page uses a
+ <a href="https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues" target="_blank">cryptographically secure random number generator</a>.
+ </span>
+ <span data-translate>The built in random generator can generally be trusted more than your own intuition about randomness.</span>
+ <span data-translate>If cryptographic randomness isn't available in your browser, this page will show a warning and the generate button will not work.</span>
+ <span data-translate>In that case you might choose to use your own source of entropy.</span>
</p>
<p>
- <a href="https://bitcointalk.org/index.php?topic=311000.msg3345309#msg3345309" target="_blank">You are not a good source of entropy.</a>
+ <a href="https://bitcointalk.org/index.php?topic=311000.msg3345309#msg3345309" target="_blank" data-translate>You are not a good source of entropy.</a>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <h2>Offline Usage</h2>
+ <h2 data-translate>Offline Usage</h2>
- <p>
+ <p data-translate>
You can use this tool without having to be online.
</p>
- <p>
+ <p data-translate>
In your browser, select file save-as, and save this page
as a file.
</p>
- <p>
+ <p data-translate>
Double-click that file to open it in a browser
on any offline computer.
</p>
<p>
- Alternatively, download it from
- <a href="https://github.com/iancoleman/bip39">
- https://github.com/iancoleman/bip39
- </a>
+ <span data-translate>Alternatively, download the file from the repository</span>
+ -
+ <a href="https://github.com/iancoleman/bip39">https://github.com/iancoleman/bip39</a>
+ </p>
</div>
</div>
<div class="row">
<div class="col-md-12">
- <h2>This project is 100% open-source code</h2>
+ <h2 data-translate>This project is 100% open-source code</h2>
<p>
- <span>Get the source code at - </span>
+ <span data-translate>Get the source code from the repository</span>
+ -
<a href="https://github.com/iancoleman/bip39" target="_blank">
https://github.com/iancoleman/bip39
</a>
</p>
- <h3>Libraries</h3>
+ <h3 data-translate>Libraries</h3>
<p>
<span>BitcoinJS - </span>
h[7] = h[7]+h7 | 0;
}
};
+</script>
+ <script>// An extremely basic translation library
+//
+// Example usage:
+//
+// Set some html to be translated. Do this using the 'data-translate' attribute:
+//
+// <div data-translate>Test</div>
+// <div data-translate-html><em>keep em tag</em></div>
+// <input data-translate-placeholder placeholder="Example text">
+//
+// Obtain all the phrases to be translated via js debug console:
+//
+// Translate.phrasesAsJson();
+//
+// Use that template to translate the phrases into another language.
+// Leave the key the same. Change the value to the new language.
+//
+// Create a js file to load the new phrases. In this example for Spanish,
+// es.js will contain the following code:
+//
+// Translate.loadForeignPhrases("es", {
+// "Test": "Test in Spanish",
+// "<em>keep em tag</em>": "<em>keep em tag in Spanish</em>",
+// "Example text": "Example text in Spanish"
+// });
+//
+// In your UI put a listener for clicking on the Spanish button:
+//
+// mySpanishButton.addEventListener("click", function() {
+// Translate.setLanguage("es");
+// });
+// myEnglishButton.addEventListener("click", function() {
+// Translate.setLanguage("en");
+// });
+
+Translate = new (function() {
+
+ var defaultLanguage = "en";
+
+ var allPhrases = {};
+ allPhrases[defaultLanguage] = {};
+
+ // Node types
+
+ var text = {
+ selector: "[data-translate]",
+ getKey: function() {
+ return this.textContent.trim().replace(/\s+/g, " ");
+ },
+ setPhrase: function(p) {
+ this.textContent = p;
+ },
+ }
+
+ var html = {
+ selector: "[data-translate-html]",
+ getKey: function() {
+ return this.innerHTML.trim().replace(/\s+/g, " ");
+ },
+ setPhrase: function(p) {
+ this.innerHTML = p;
+ },
+ }
+
+ var placeholder = {
+ selector: "[data-translate-placeholder]",
+ getKey: function() {
+ return this.getAttribute("placeholder").trim().replace(/\s+/g, " ");
+ },
+ setPhrase: function(p) {
+ this.setAttribute("placeholder", p);
+ },
+ }
+
+ // Get elements to be translated
+ var allEls = getEls(text)
+ .concat(getEls(html))
+ .concat(getEls(placeholder));
+
+ // Provides access to phrases from a non-default language.
+ // See phrases_en.js for example usage.
+ this.loadForeignPhrases = function(language, phrases) {
+ allPhrases[language] = phrases;
+ }
+
+ // Displays a different language, eg "en" or "fr"
+ this.setLanguage = function(language) {
+ for (var i=0; i<allEls.length; i++) {
+ var el = allEls[i];
+ var key = el.key;
+ if (!(language in allPhrases)) {
+ console.log(language + " not in allPhrases");
+ return;
+ }
+ if (!(key in allPhrases[language])) {
+ console.log(language + " does not contain phrase: " + key);
+ return;
+ }
+ var phrase = allPhrases[language][key];
+ el.setPhrase(phrase);
+ }
+ }
+
+ // Converts the phrases to a key-pair json file.
+ // This is a good way to export phrases for use in translation tools.
+ this.phrasesAsJson = function(language) {
+ var keys = [];
+ for (var i=0; i<allEls.length; i++) {
+ var el = allEls[i];
+ var key = el.key;
+ keys.push(key);
+ }
+ keys.sort();
+ var output = {};
+ for (var i=0; i<keys.length; i++) {
+ var key = keys[i];
+ var translated = "";
+ if (language in allPhrases && key in allPhrases[language]) {
+ translated = allPhrases[language][key];
+ }
+ output[key] = translated;
+ }
+ return JSON.stringify(output, null, 2);
+ }
+
+ function getEls(nodeType) {
+ var nodes = document.querySelectorAll(nodeType.selector);
+ var els = [];
+ for (var i=0; i<nodes.length; i++) {
+ var node = nodes[i];
+ node.getKey = nodeType.getKey;
+ node.setPhrase = nodeType.setPhrase;
+ node.key = node.getKey();
+ allPhrases[defaultLanguage][node.key] = node.key;
+ els.push(node);
+ }
+ return els;
+ }
+
+})();
+</script>
+ <script>Translate.loadForeignPhrases("en",
+{
+ "<code>m/44'/0'/0'/0</code> generates public addresses": "<code>m/44'/0'/0'/0</code> generates public addresses",
+ "<code>m/44'/0'/0'/1</code> generates change addresses": "<code>m/44'/0'/0'/1</code> generates change addresses",
+ "<code>m/44'/0'/0'</code> generates extended keys for import / export": "<code>m/44'/0'/0'</code> generates extended keys for import / export",
+ "<code>m/44'/0'/1'</code> for the next account. Continue incrementing for more accounts (most use a single account).": "<code>m/44'/0'/1'</code> for the next account. Continue incrementing for more accounts (most use a single account).",
+ "Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards": "Accepts binary, base 6, 6-sided dice, base 10, hexadecimal, cards",
+ "Account": "Account",
+ "Address": "Address",
+ "Alternatively, download the file from the repository": "Alternatively, download the file from the repository",
+ "BIP32 Derivation Path": "BIP32 Derivation Path",
+ "BIP32 Extended Key": "BIP32 Extended Key",
+ "BIP32 Extended Key (addresses only)": "BIP32 Extended Key (addresses only)",
+ "BIP32 Root Key": "BIP32 Root Key",
+ "BIP39 Mnemonic": "BIP39 Mnemonic",
+ "BIP39 Passphrase (optional)": "BIP39 Passphrase (optional)",
+ "BIP39 Seed": "BIP39 Seed",
+ "Base 10": "Base 10",
+ "Base 6": "Base 6",
+ "Be careful - it can be easy to make mistakes if you don't know what you're doing.": "Be careful - it can be easy to make mistakes if you don't know what you're doing.",
+ "Binary": "Binary",
+ "Bitcoin Core": "Bitcoin Core",
+ "Bits Per Event": "Bits Per Event",
+ "Block Explorers": "Block Explorers",
+ "Can be used with": "Can be used with",
+ "Card": "Card",
+ "Coin": "Coin",
+ "Dice": "Dice",
+ "Do <strong>NOT</strong> use phrases from books, lyrics from songs, your birthday or steet address, keyboard mashing, or anything you <i>think</i> is random, because chances are overwhelming it isn't random enough for the needs of this tool.": "Do <strong>NOT</strong> use phrases from books, lyrics from songs, your birthday or steet address, keyboard mashing, or anything you <i>think</i> is random, because chances are overwhelming it isn't random enough for the needs of this tool.",
+ "Double-click that file to open it in a browser on any offline computer.": "Double-click that file to open it in a browser on any offline computer.",
+ "Entropy": "Entropy",
+ "Entropy Type": "Entropy Type",
+ "Entropy is an advanced feature. Your mnemonic may be insecure if this feature is used incorrectly.": "Entropy is an advanced feature. Your mnemonic may be insecure if this feature is used incorrectly.",
+ "Entropy values must be sourced from a <a href=\"https://en.wikipedia.org/wiki/Random_number_generation\" target=\"_blank\">strong source of randomness</a>.": "Entropy values must be sourced from a <a href=\"https://en.wikipedia.org/wiki/Random_number_generation\" target=\"_blank\">strong source of randomness</a>.",
+ "Event Count": "Event Count",
+ "External / Internal": "External / Internal",
+ "Filtered Entropy": "Filtered Entropy",
+ "For more info see the <a href=\"http://www.mycelium.com/\" target=\"_blank\">Mycelium Wallet homepage</a>": "For more info see the <a href=\"http://www.mycelium.com/\" target=\"_blank\">Mycelium Wallet homepage</a>",
+ "For more info see the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\" target=\"_blank\">BIP39 spec</a>.": "For more info see the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\" target=\"_blank\">BIP39 spec</a>.",
+ "For more info see the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki\" target=\"_blank\">BIP44 spec</a>.": "For more info see the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki\" target=\"_blank\">BIP44 spec</a>.",
+ "For more info see the <a href=\"https://github.com/bitcoin/bitcoin/pull/8035\" target=\"_blank\">Bitcoin Core BIP32 implementation</a>": "For more info see the <a href=\"https://github.com/bitcoin/bitcoin/pull/8035\" target=\"_blank\">Bitcoin Core BIP32 implementation</a>",
+ "For more info see the BIP32 spec": "For more info see the BIP32 spec",
+ "From entropy length (3 words per 32 bits)": "From entropy length (3 words per 32 bits)",
+ "Generate a random mnemonic, or enter your own below": "Generate a random mnemonic, or enter your own below",
+ "Get the source code from the repository": "Get the source code from the repository",
+ "Hex": "Hex",
+ "Hierarchical Deterministic Wallets": "Hierarchical Deterministic Wallets",
+ "If cryptographic randomness isn't available in your browser, this page will show a warning and the generate button will not work.": "If cryptographic randomness isn't available in your browser, this page will show a warning and the generate button will not work.",
+ "In that case you might choose to use your own source of entropy.": "In that case you might choose to use your own source of entropy.",
+ "In your browser, select file save-as, and save this page as a file.": "In your browser, select file save-as, and save this page as a file.",
+ "Libraries": "Libraries",
+ "Mnemonic Language": "Mnemonic Language",
+ "Mnemonic Length": "Mnemonic Length",
+ "Mnemonic code for generating deterministic keys": "Mnemonic code for generating deterministic keys",
+ "More info": "More info",
+ "Multi-Account Hierarchy for Deterministic Wallets": "Multi-Account Hierarchy for Deterministic Wallets",
+ "Mycelium Wallet": "Mycelium Wallet",
+ "Note these addreses are derived from the BIP32 Extended Key": "Note these addreses are derived from the BIP32 Extended Key",
+ "Offline Usage": "Offline Usage",
+ "Only enter the <code>xpub</code> extended key into block explorer search fields, never the <code>xprv</code> key.": "Only enter the <code>xpub</code> extended key into block explorer search fields, never the <code>xprv</code> key.",
+ "Path": "Path",
+ "Private Key": "Private Key",
+ "Private Keys": "Private Keys",
+ "Public Key": "Public Key",
+ "Purpose": "Purpose",
+ "Raw Binary": "Raw Binary",
+ "Read more": "Read more",
+ "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\" target=\"_blank\">official BIP32 spec</a>": "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\" target=\"_blank\">official BIP32 spec</a>",
+ "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\">official BIP39 spec</a>": "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki\">official BIP39 spec</a>",
+ "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki\" target=\"_blank\">official BIP44 spec</a>": "Read more at the <a href=\"https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki\" target=\"_blank\">official BIP44 spec</a>",
+ "See the demo at <a href=\"http://bip32.org/\" target=\"_blank\">bip32.org</a>": "See the demo at <a href=\"http://bip32.org/\" target=\"_blank\">bip32.org</a>",
+ "Show": "Show",
+ "Show more rows": "Show more rows",
+ "Strength": "Strength",
+ "Supply my own source of entropy": "Supply my own source of entropy",
+ "The built in random generator can generally be trusted more than your own intuition about randomness.": "The built in random generator can generally be trusted more than your own intuition about randomness.",
+ "The random mnemonic generator on this page uses a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues\" target=\"_blank\">cryptographically secure random number generator</a>.": "The random mnemonic generator on this page uses a <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/RandomSource/getRandomValues\" target=\"_blank\">cryptographically secure random number generator</a>.",
+ "This means flipping a fair coin, rolling a fair dice, noise measurements etc.": "This means flipping a fair coin, rolling a fair dice, noise measurements etc.",
+ "This project is 100% open-source code": "This project is 100% open-source code",
+ "Toggle": "Toggle",
+ "Total Bits": "Total Bits",
+ "Use hardened addresses": "Use hardened addresses",
+ "Use path <code>m/0'/0'</code> with hardened addresses.": "Use path <code>m/0'/0'</code> with hardened addresses.",
+ "Use path <code>m/44'/0'/0'</code>.": "Use path <code>m/44'/0'/0'</code>.",
+ "Use private keys at <a href=\"https://web.archive.org/web/20150707020924/https://brainwallet.org/\" target=\"_blank\">brainwallet.org</a>.": "Use private keys at <a href=\"https://web.archive.org/web/20150707020924/https://brainwallet.org/\" target=\"_blank\">brainwallet.org</a>.",
+ "Valid entropy values include:": "Valid entropy values include:",
+ "Warning": "Warning",
+ "Word Count": "Word Count",
+ "You are not a good source of entropy.": "You are not a good source of entropy.",
+ "You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum).": "You can enter an existing BIP39 mnemonic, or generate a new random one. Typing your own twelve words will probably not work how you expect, since the words require a particular structure (the last word is a checksum).",
+ "You can use this tool without having to be online.": "You can use this tool without having to be online.",
+ "words": "words"
+}
+);
</script>
<script>WORDLISTS = typeof WORDLISTS == "undefined" ? {} : WORDLISTS;
WORDLISTS["english"] = [
while (entropyBin.length < expectedBits) {
entropyBin = "0" + entropyBin;
}
- // Assume cards are NOT replaced.
- // Additional entropy decreases as more cards are used. This means
- // total possible entropy is measured using n!, not base^n.
- // eg the second last card can be only one of two, not one of fifty two
- // so the added entropy for that card is only one bit at most
+ // Cards binary must be handled differently, since they're not replaced
if (base.asInt == 52) {
- var totalDecks = Math.ceil(base.parts.length / 52);
- var totalCards = totalDecks * 52;
- var totalCombos = factorial(52).pow(totalDecks);
- var totalRemainingCards = totalCards - base.parts.length;
- var remainingDecks = Math.floor(totalRemainingCards / 52);
- var remainingCards = totalRemainingCards % 52;
- var remainingCombos = factorial(52).pow(remainingDecks).multiply(factorial(remainingCards));
- var currentCombos = totalCombos.divide(remainingCombos);
- var numberOfBits = Math.log2(currentCombos);
- var maxWithoutReplace = BigInteger.pow(2, numberOfBits);
- // Use a bunch of sorted decks to measure entropy from, populated
- // as needed.
- var sortedDecks = [];
- // Initialize the final entropy value for these cards
- var entropyInt = BigInteger.ZERO;
- // Track how many instances of each card have been used, and thus
- // how many decks are in use.
- var cardCounts = {};
- // Track the total bits of entropy that remain, which diminishes as
- // each card is drawn.
- var totalBitsLeft = numberOfBits;
- // Work out entropy contribution of each card drawn
- for (var i=0; i<base.parts.length; i++) {
- // Get the card that was drawn
- var cardLower = base.parts[i];
- var card = cardLower.toUpperCase();
- // Initialize the deck for this card if needed, to track how
- // much entropy it adds.
- if (!(card in cardCounts)) {
- cardCounts[card] = 0;
- }
- // Get the deck this card is from
- var deckIndex = cardCounts[card];
- while (deckIndex > sortedDecks.length-1) {
- sortedDecks.push(getSortedDeck());
- }
- // See how many bits this card contributes (depends on how many
- // are left in the deck it's from)
- var deckForCard = sortedDecks[deckIndex];
- var cardsLeftInDeck = deckForCard.length;
- var additionalBits = Math.log2(cardsLeftInDeck);
- // Work out the min and max value for this card
- var nextTotalBitsLeft = totalBitsLeft - additionalBits;
- var minPossibleNewEntropy = TWO.pow(nextTotalBitsLeft).subtract(1);
- var maxPossibleNewEntropy = TWO.pow(totalBitsLeft).subtract(1);
- var diff = maxPossibleNewEntropy.subtract(minPossibleNewEntropy);
- // BigInteger aggresively floors numbers which greatly affects
- // the small numbers. In that case, use native Math library
- var useBigInt = totalBitsLeft >= 32;
- if (!useBigInt) {
- minPossibleNewEntropy = Math.round(Math.pow(2, nextTotalBitsLeft)-1);
- maxPossibleNewEntropy = Math.round(Math.pow(2, totalBitsLeft)-1);
- diff = maxPossibleNewEntropy - minPossibleNewEntropy;
- }
- // Scale the value between possible min and max depending on
- // this card value
- var thisCardIndex = deckForCard.indexOf(card);
- var toAdd = BigInteger.ZERO;
- if (cardsLeftInDeck > 1) {
- if (useBigInt) {
- toAdd = diff.multiply(thisCardIndex)
- .divide(deckForCard.length - 1)
- .add(minPossibleNewEntropy);
- }
- else {
- var ratio = thisCardIndex / (deckForCard.length -1);
- var f = diff * ratio;
- toAdd = new BigInteger(f).add(minPossibleNewEntropy);
- }
- }
- // Add this card entropy to existing entropy
- entropyInt = entropyInt.add(toAdd);
- // Remove this card from the deck it comes from
- deckForCard.splice(thisCardIndex,1);
- // Ensure the next insance of this card uses the next deck
- cardCounts[card] = cardCounts[card] + 1;
- // Next card drawn has less total remaining bits to work with
- totalBitsLeft = nextTotalBitsLeft;
- }
- // Convert to binary
- var entropyBin = entropyInt.toString(2);
- var numberOfBitsInt = Math.floor(numberOfBits);
- while (entropyBin.length < numberOfBitsInt) {
- entropyBin = "0" + entropyBin;
- }
+ entropyBin = getCardBinary(base.parts);
}
// Supply a 'filtered' entropy string for display purposes
var entropyClean = base.parts.join("");
}
}
+ // Assume cards are NOT replaced.
+ // Additional entropy decreases as more cards are used. This means
+ // total possible entropy is measured using n!, not base^n.
+ // eg the second last card can be only one of two, not one of fifty two
+ // so the added entropy for that card is only one bit at most
+ function getCardBinary(cards) {
+ // Track how many instances of each card have been used, and thus
+ // how many decks are in use.
+ var cardCounts = {};
+ var numberOfDecks = 0;
+ // Work out number of decks by max(duplicates)
+ for (var i=0; i<cards.length; i++) {
+ // Get the card that was drawn
+ var cardLower = cards[i];
+ var card = cardLower.toUpperCase();
+ // Initialize the count for this card if needed
+ if (!(card in cardCounts)) {
+ cardCounts[card] = 0;
+ }
+ cardCounts[card] += 1;
+ // See if this is max(duplicates)
+ if (cardCounts[card] > numberOfDecks) {
+ numberOfDecks = cardCounts[card];
+ }
+ }
+ // Work out the total number of bits for this many decks
+ // See http://crypto.stackexchange.com/q/41886
+ var gainedBits = Math.log2(factorial(52 * numberOfDecks));
+ var lostBits = 52 * Math.log2(factorial(numberOfDecks));
+ var maxBits = gainedBits - lostBits;
+ // Convert the drawn cards to a binary representation.
+ // The exact technique for doing this is unclear.
+ // See
+ // http://crypto.stackexchange.com/a/41896
+ // "I even doubt that this is well defined (only the average entropy
+ // is, I believe)."
+ // See
+ // https://github.com/iancoleman/bip39/issues/33#issuecomment-263021856
+ // "The binary representation can be the first log(permutations,2) bits
+ // of the sha-2 hash of the normalized deck string."
+ //
+ // In this specific implementation, the first N bits of the hash of the
+ // normalized cards string is being used. Uppercase, no spaces; eg
+ // sha256("AH8DQSTC2H")
+ var totalCards = numberOfDecks * 52;
+ var percentUsed = cards.length / totalCards;
+ // Calculate the average number of bits of entropy for the number of
+ // cards drawn.
+ var numberOfBits = Math.floor(maxBits * percentUsed);
+ // Create a normalized string of the selected cards
+ var normalizedCards = cards.join("").toUpperCase();
+ // Convert to binary using the SHA256 hash of the normalized cards.
+ // If the number of bits is more than 256, multiple rounds of hashing
+ // are used until the required number of bits is reached.
+ var entropyBin = "";
+ var iterations = 0;
+ while (entropyBin.length < numberOfBits) {
+ var hashedCards = sjcl.hash.sha256.hash(normalizedCards);
+ for (var j=0; j<iterations; j++) {
+ hashedCards = sjcl.hash.sha256.hash(hashedCards);
+ }
+ var hashHex = sjcl.codec.hex.fromBits(hashedCards);
+ for (var i=0; i<hashHex.length; i++) {
+ var decimal = parseInt(hashHex[i], 16);
+ var binary = decimal.toString(2);
+ while (binary.length < 4) {
+ binary = "0" + binary;
+ }
+ entropyBin = entropyBin + binary;
+ }
+ iterations = iterations + 1;
+ }
+ // Truncate to the appropriate number of bits.
+ entropyBin = entropyBin.substring(0, numberOfBits);
+ return entropyBin;
+ }
+
// Polyfill for Math.log2
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2#Polyfill
Math.log2 = Math.log2 || function(x) {