mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-25 20:00:40 +00:00
@@ -18,6 +18,10 @@ module.exports.BigInteger = require('javascript-biginteger')
|
|||||||
|
|
||||||
module.exports.bip38 = require('bip38')
|
module.exports.bip38 = require('bip38')
|
||||||
|
|
||||||
|
/* bip85 */
|
||||||
|
|
||||||
|
module.exports.bip85 = require('bip85')
|
||||||
|
|
||||||
/* bitcoinjs-lib */
|
/* bitcoinjs-lib */
|
||||||
|
|
||||||
module.exports.bitcoin = require('bitcoinjs-lib')
|
module.exports.bitcoin = require('bitcoinjs-lib')
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
"bchaddrjs-slp": "git://github.com/simpleledger/bchaddrjs.git#af16e44a6bfbe4b3980a62dba50e2f68ed864c6b",
|
||||||
"bip38": "2.0.2",
|
"bip38": "2.0.2",
|
||||||
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
"bip38grs": "git://github.com/Groestlcoin/bip38grs.git#091975b01679b74dc0a4136bb743fe17791b0151",
|
||||||
|
"bip85": "0.0.3",
|
||||||
"bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit",
|
"bitcoinjs-lib": "git://github.com/iancoleman/bitcoinjs-lib.git#v3.3.2_16bit",
|
||||||
"bs58": "^4.0.1",
|
"bs58": "^4.0.1",
|
||||||
"buffer": "^5.4.3",
|
"buffer": "^5.4.3",
|
||||||
|
|||||||
@@ -248,6 +248,95 @@
|
|||||||
<textarea id="root-key" class="root-key private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
<textarea id="root-key" class="root-key private-data form-control" data-show-qr autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-2"></div>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<label class="control-label text-weight-normal">
|
||||||
|
<input type="checkbox" class="showBip85" />
|
||||||
|
Show <a href="https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki">BIP85</a>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 hidden">
|
||||||
|
<label for="bip85-application" class="col-sm-2 control-label">BIP85 Application</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<select id="bip85-application" class="form-control">
|
||||||
|
<option value="bip39" selected>BIP39</option>
|
||||||
|
<option value="wif">WIF</option>
|
||||||
|
<option value="xprv">Xprv</option>
|
||||||
|
<option value="hex">Hex</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 bip85-mnemonic-language-input hidden">
|
||||||
|
<label for="bip85-mnemonic-language" class="col-sm-2 control-label">BIP85 Mnemonic Language</label>
|
||||||
|
<div class="col-sm-10 languages">
|
||||||
|
<select id="bip85-mnemonic-language" class="strength form-control">
|
||||||
|
<option value="0" selected>English</option>
|
||||||
|
<option value="1">日本語</option>
|
||||||
|
<option value="2">한국어</option>
|
||||||
|
<option value="3">Español</option>
|
||||||
|
<option value="4">中文(简体)</option>
|
||||||
|
<option value="5">中文(繁體)</option>
|
||||||
|
<option value="6">Français</option>
|
||||||
|
<option value="7">Italiano</option>
|
||||||
|
<option value="8">Čeština</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 bip85-mnemonic-length-input hidden">
|
||||||
|
<label for="bip85-mnemonic-length" class="col-sm-2 control-label">BIP85 Mnemonic Length</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<select id="bip85-mnemonic-length" class="strength form-control">
|
||||||
|
<option value="12" selected>12</option>
|
||||||
|
<option value="18">18</option>
|
||||||
|
<option value="24">24</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 hidden">
|
||||||
|
<span class="bip85-bytes-input">
|
||||||
|
<label for="bip85-bytes" class="col-sm-2 control-label">BIP85 Bytes</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input id="bip85-bytes" type="text" class="change form-control" value="64" />
|
||||||
|
</div>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 bip85-index-input hidden">
|
||||||
|
<label for="bip85-index" class="col-sm-2 control-label">BIP85 Index</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<input id="bip85-index" type="text" class="change form-control" value="0" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group bip85 hidden">
|
||||||
|
<label for="phrase" class="col-sm-2 control-label">BIP85 Child Key</label>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<textarea
|
||||||
|
id="bip85Field"
|
||||||
|
data-show-qr
|
||||||
|
class="bip85Field private-data form-control"
|
||||||
|
title="BIP85 Child Key"
|
||||||
|
rows="3"
|
||||||
|
></textarea>
|
||||||
|
<p class="help-block">
|
||||||
|
<span id="bip85Warn" class="text-danger">The value of the "BIP85 Child Key" field shown above is not used
|
||||||
|
anywhere on this page. It can be used as a new key.
|
||||||
|
(In case of the BIP39 application, you can paste it into the "BIP39 Mnemonic"
|
||||||
|
field to use it as a new mnemonic). Please read the
|
||||||
|
<a href="https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki">BIP85 specs</a>
|
||||||
|
for more information. This is an advanced feature and should only be used if you understand what it does.
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group litecoin-ltub-container hidden">
|
<div class="form-group litecoin-ltub-container hidden">
|
||||||
<label for="litecoin-use-ltub" class="col-sm-2 control-label">Prefixes</label>
|
<label for="litecoin-use-ltub" class="col-sm-2 control-label">Prefixes</label>
|
||||||
<div class="col-sm-10 checkbox">
|
<div class="col-sm-10 checkbox">
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -94,6 +94,18 @@
|
|||||||
DOM.bip84accountXprv = $("#bip84 .account-xprv");
|
DOM.bip84accountXprv = $("#bip84 .account-xprv");
|
||||||
DOM.bip84accountXpub = $("#bip84 .account-xpub");
|
DOM.bip84accountXpub = $("#bip84 .account-xpub");
|
||||||
DOM.bip84change = $("#bip84 .change");
|
DOM.bip84change = $("#bip84 .change");
|
||||||
|
DOM.bip85 = $('.bip85');
|
||||||
|
DOM.showBip85 = $('.showBip85');
|
||||||
|
DOM.bip85Field = $('.bip85Field');
|
||||||
|
DOM.bip85application = $('#bip85-application');
|
||||||
|
DOM.bip85mnemonicLanguage = $('#bip85-mnemonic-language');
|
||||||
|
DOM.bip85mnemonicLanguageInput = $('.bip85-mnemonic-language-input');
|
||||||
|
DOM.bip85mnemonicLength = $('#bip85-mnemonic-length');
|
||||||
|
DOM.bip85mnemonicLengthInput = $('.bip85-mnemonic-length-input');
|
||||||
|
DOM.bip85index = $('#bip85-index');
|
||||||
|
DOM.bip85indexInput = $('.bip85-index-input');
|
||||||
|
DOM.bip85bytes = $('#bip85-bytes');
|
||||||
|
DOM.bip85bytesInput = $('.bip85-bytes-input');
|
||||||
DOM.bip141unavailable = $("#bip141 .unavailable");
|
DOM.bip141unavailable = $("#bip141 .unavailable");
|
||||||
DOM.bip141available = $("#bip141 .available");
|
DOM.bip141available = $("#bip141 .available");
|
||||||
DOM.bip141path = $("#bip141-path");
|
DOM.bip141path = $("#bip141-path");
|
||||||
@@ -141,6 +153,7 @@
|
|||||||
DOM.more.on("click", showMore);
|
DOM.more.on("click", showMore);
|
||||||
DOM.seed.on("input", delayedSeedChanged);
|
DOM.seed.on("input", delayedSeedChanged);
|
||||||
DOM.rootKey.on("input", delayedRootKeyChanged);
|
DOM.rootKey.on("input", delayedRootKeyChanged);
|
||||||
|
DOM.showBip85.on('change', toggleBip85);
|
||||||
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
|
DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged);
|
||||||
DOM.bip32path.on("input", calcForDerivationPath);
|
DOM.bip32path.on("input", calcForDerivationPath);
|
||||||
DOM.bip44account.on("input", calcForDerivationPath);
|
DOM.bip44account.on("input", calcForDerivationPath);
|
||||||
@@ -149,6 +162,11 @@
|
|||||||
DOM.bip49change.on("input", calcForDerivationPath);
|
DOM.bip49change.on("input", calcForDerivationPath);
|
||||||
DOM.bip84account.on("input", calcForDerivationPath);
|
DOM.bip84account.on("input", calcForDerivationPath);
|
||||||
DOM.bip84change.on("input", calcForDerivationPath);
|
DOM.bip84change.on("input", calcForDerivationPath);
|
||||||
|
DOM.bip85application.on('input', calcBip85);
|
||||||
|
DOM.bip85mnemonicLanguage.on('change', calcBip85);
|
||||||
|
DOM.bip85mnemonicLength.on('change', calcBip85);
|
||||||
|
DOM.bip85index.on('input', calcBip85);
|
||||||
|
DOM.bip85bytes.on('input', calcBip85);
|
||||||
DOM.bip141path.on("input", calcForDerivationPath);
|
DOM.bip141path.on("input", calcForDerivationPath);
|
||||||
DOM.bip141semantics.on("change", tabChanged);
|
DOM.bip141semantics.on("change", tabChanged);
|
||||||
DOM.tab.on("shown.bs.tab", tabChanged);
|
DOM.tab.on("shown.bs.tab", tabChanged);
|
||||||
@@ -268,6 +286,7 @@
|
|||||||
var passphrase = DOM.passphrase.val();
|
var passphrase = DOM.passphrase.val();
|
||||||
calcBip32RootKeyFromSeed(phrase, passphrase);
|
calcBip32RootKeyFromSeed(phrase, passphrase);
|
||||||
calcForDerivationPath();
|
calcForDerivationPath();
|
||||||
|
calcBip85();
|
||||||
// Show the word indexes
|
// Show the word indexes
|
||||||
showWordIndexes();
|
showWordIndexes();
|
||||||
writeSplitPhrase(phrase);
|
writeSplitPhrase(phrase);
|
||||||
@@ -404,6 +423,7 @@
|
|||||||
}
|
}
|
||||||
// Calculate and display
|
// Calculate and display
|
||||||
calcForDerivationPath();
|
calcForDerivationPath();
|
||||||
|
calcBip85();
|
||||||
}
|
}
|
||||||
|
|
||||||
function rootKeyChanged() {
|
function rootKeyChanged() {
|
||||||
@@ -418,6 +438,7 @@
|
|||||||
// Calculate and display
|
// Calculate and display
|
||||||
calcBip32RootKeyFromBase58(rootKeyBase58);
|
calcBip32RootKeyFromBase58(rootKeyBase58);
|
||||||
calcForDerivationPath();
|
calcForDerivationPath();
|
||||||
|
calcBip85();
|
||||||
}
|
}
|
||||||
|
|
||||||
function litecoinUseLtubChanged() {
|
function litecoinUseLtubChanged() {
|
||||||
@@ -440,6 +461,75 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleBip85() {
|
||||||
|
if (DOM.showBip85.prop('checked')) {
|
||||||
|
DOM.bip85.removeClass('hidden');
|
||||||
|
calcBip85();
|
||||||
|
} else {
|
||||||
|
DOM.bip85.addClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleBip85Fields() {
|
||||||
|
if (DOM.showBip85.prop('checked')) {
|
||||||
|
DOM.bip85mnemonicLanguageInput.addClass('hidden');
|
||||||
|
DOM.bip85mnemonicLengthInput.addClass('hidden');
|
||||||
|
DOM.bip85bytesInput.addClass('hidden');
|
||||||
|
|
||||||
|
var app = DOM.bip85application.val();
|
||||||
|
if (app === 'bip39') {
|
||||||
|
DOM.bip85mnemonicLanguageInput.removeClass('hidden');
|
||||||
|
DOM.bip85mnemonicLengthInput.removeClass('hidden');
|
||||||
|
} else if (app === 'hex') {
|
||||||
|
DOM.bip85bytesInput.removeClass('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcBip85() {
|
||||||
|
if (!DOM.showBip85.prop('checked')) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleBip85Fields();
|
||||||
|
|
||||||
|
var app = DOM.bip85application.val();
|
||||||
|
|
||||||
|
var phrase = DOM.phrase.val();
|
||||||
|
var passphrase = DOM.passphrase.val();
|
||||||
|
if (!phrase) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var master = libs.bip85.BIP85.fromMnemonic(phrase, passphrase);
|
||||||
|
|
||||||
|
var result;
|
||||||
|
|
||||||
|
const index = parseInt(DOM.bip85index.val(), 10);
|
||||||
|
|
||||||
|
if (app === 'bip39') {
|
||||||
|
const language = parseInt(DOM.bip85mnemonicLanguage.val(), 10);
|
||||||
|
const length = parseInt(DOM.bip85mnemonicLength.val(), 10);
|
||||||
|
|
||||||
|
result = master.deriveBIP39(language, length, index).toMnemonic();
|
||||||
|
} else if (app === 'wif') {
|
||||||
|
result = master.deriveWIF(index).toWIF();
|
||||||
|
} else if (app === 'xprv') {
|
||||||
|
result = master.deriveXPRV(index).toXPRV();
|
||||||
|
} else if (app === 'hex') {
|
||||||
|
const bytes = parseInt(DOM.bip85bytes.val(), 10);
|
||||||
|
|
||||||
|
result = master.deriveHex(bytes, index).toEntropy();
|
||||||
|
}
|
||||||
|
|
||||||
|
hideValidationError();
|
||||||
|
DOM.bip85Field.val(result);
|
||||||
|
} catch (e) {
|
||||||
|
showValidationError('BIP85: ' + e.message);
|
||||||
|
DOM.bip85Field.val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function calcForDerivationPath() {
|
function calcForDerivationPath() {
|
||||||
clearDerivedKeys();
|
clearDerivedKeys();
|
||||||
clearAddressesList();
|
clearAddressesList();
|
||||||
|
|||||||
@@ -4960,6 +4960,24 @@ it('Shows split prase cards', function(done) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Pull Request 454 https://github.com/iancoleman/bip39/pull/454
|
||||||
|
// Add BIP85 support
|
||||||
|
it('Show BIP85', function(done) {
|
||||||
|
var originalPhrase = "install scatter logic circle pencil average fall shoe quantum disease suspect usage";
|
||||||
|
driver.findElement(By.css('.phrase'))
|
||||||
|
.sendKeys(originalPhrase);
|
||||||
|
driver.sleep(generateDelay).then(function() {
|
||||||
|
driver.findElement(By.css('.showBip85')).click();
|
||||||
|
driver.findElement(By.css('.showBip85')).isSelected().then(function(isSelected) {
|
||||||
|
expect(isSelected).toBe(true)
|
||||||
|
driver.findElement(By.css('#bip85Field')).getAttribute("value").then(function(childMnemonic) {
|
||||||
|
expect(childMnemonic).toBe('girl mad pet galaxy egg matter matrix prison refuse sense ordinary nose')
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// It allows manually specifying the entropy type
|
// It allows manually specifying the entropy type
|
||||||
it('Allows entropy type to be manually selected', function(done) {
|
it('Allows entropy type to be manually selected', function(done) {
|
||||||
driver.findElement(By.css('.use-entropy'))
|
driver.findElement(By.css('.use-entropy'))
|
||||||
|
|||||||
Reference in New Issue
Block a user