mirror of
https://github.com/OneKeyHQ/bip39.git
synced 2026-04-29 05:30:54 +00:00
Merge pull request #280 from mctrivia/add-hack-time-for-split-cards
Add hack time calculation for Split Mnemonic Cards
This commit is contained in:
@@ -31,6 +31,10 @@ body {
|
||||
.phrase {
|
||||
word-break: keep-all;
|
||||
}
|
||||
.phraseSplitWarn {
|
||||
text-align: right;
|
||||
color: red;
|
||||
}
|
||||
.generate-container .strength {
|
||||
/* override mobile width from bootstrap */
|
||||
width: auto!important;
|
||||
|
||||
@@ -177,6 +177,7 @@
|
||||
<div class="col-sm-10">
|
||||
<textarea id="phraseSplit" class="phraseSplit private-data form-control" title="Only 2 of 3 cards needed to recover."></textarea>
|
||||
</div>
|
||||
<div id="phraseSplitWarn" class="phraseSplitWarn"></div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="passphrase" class="col-sm-2 control-label">BIP39 Passphrase (optional)</label>
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
|
||||
DOM.phrase = $(".phrase");
|
||||
DOM.splitPhrase = $(".phraseSplit");
|
||||
DOM.phraseSplitWarn = $(".phraseSplitWarn");
|
||||
DOM.passphrase = $(".passphrase");
|
||||
DOM.generateContainer = $(".generate-container");
|
||||
DOM.generate = $(".generate");
|
||||
@@ -1448,6 +1449,18 @@
|
||||
cards[i]='Card '+(i+1)+': '+wordArrayToPhrase(cards[i]); //combine words on card back to string
|
||||
}
|
||||
DOM.splitPhrase.val(cards.join("\r\n")); //make words visible
|
||||
var triesPerSecond=10000000000; //assumed number of tries per second
|
||||
var hackTime=Math.pow(2,wordCount*10/3)/triesPerSecond; //get number of bits of unknown data per card
|
||||
if (hackTime<1) {
|
||||
hackTime="<1 second";
|
||||
} else if (hackTime<86400) {
|
||||
hackTime=Math.floor(hackTime)+" seconds";
|
||||
} else if(hackTime<31557600) {
|
||||
hackTime=Math.floor(hackTime/86400)+" days";
|
||||
} else {
|
||||
hackTime=Math.floor(hackTime/31557600)+" years";
|
||||
}
|
||||
DOM.phraseSplitWarn.html("Time to hack with only one card: "+hackTime);
|
||||
}
|
||||
|
||||
function isUsingOwnEntropy() {
|
||||
|
||||
Reference in New Issue
Block a user