diff options
author | Ian Coleman <ian@iancoleman.io> | 2018-04-12 12:16:05 +1000 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2018-04-12 12:16:05 +1000 |
commit | 645945a00fe588064d33dca49f75f27e08b8f11e (patch) | |
tree | 2e4de22d9dcc064141cc79c007852f9b19e1b31f /src | |
parent | 85c906727a24ab97a3c2908c72ad37ad988ecb01 (diff) | |
download | BIP39-645945a00fe588064d33dca49f75f27e08b8f11e.tar.gz BIP39-645945a00fe588064d33dca49f75f27e08b8f11e.tar.zst BIP39-645945a00fe588064d33dca49f75f27e08b8f11e.zip |
Warn when using weak entropy and strong mnemonic
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 5 | ||||
-rw-r--r-- | src/js/index.js | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/index.html b/src/index.html index df5bf67..4056610 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -113,6 +113,11 @@ | |||
113 | <option value="21">21 <span>Words</span></option> | 113 | <option value="21">21 <span>Words</span></option> |
114 | <option value="24">24 <span>Words</span></option> | 114 | <option value="24">24 <span>Words</span></option> |
115 | </select> | 115 | </select> |
116 | <p class="weak-entropy-override-warning hidden"> | ||
117 | <span class="text-danger"> | ||
118 | The mnemonic will appear more secure than it really is. | ||
119 | </span> | ||
120 | </p> | ||
116 | </div> | 121 | </div> |
117 | </div> | 122 | </div> |
118 | <div class="col-sm-3"> | 123 | <div class="col-sm-3"> |
diff --git a/src/js/index.js b/src/js/index.js index 0a2d362..e96f4a9 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -40,6 +40,7 @@ | |||
40 | DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); | 40 | DOM.entropyWordIndexes = DOM.entropyContainer.find(".word-indexes"); |
41 | DOM.entropyChecksum = DOM.entropyContainer.find(".checksum"); | 41 | DOM.entropyChecksum = DOM.entropyContainer.find(".checksum"); |
42 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); | 42 | DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); |
43 | DOM.entropyWeakEntropyOverrideWarning = DOM.entropyContainer.find(".weak-entropy-override-warning"); | ||
43 | DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); | 44 | DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); |
44 | DOM.phrase = $(".phrase"); | 45 | DOM.phrase = $(".phrase"); |
45 | DOM.passphrase = $(".passphrase"); | 46 | DOM.passphrase = $(".passphrase"); |
@@ -1190,6 +1191,17 @@ | |||
1190 | mnemonicLength = parseInt(mnemonicLength); | 1191 | mnemonicLength = parseInt(mnemonicLength); |
1191 | var numberOfBits = 32 * mnemonicLength / 3; | 1192 | var numberOfBits = 32 * mnemonicLength / 3; |
1192 | bits = bits.substring(0, numberOfBits); | 1193 | bits = bits.substring(0, numberOfBits); |
1194 | // show warning for weak entropy override | ||
1195 | if (mnemonicLength / 3 * 32 > entropy.binaryStr.length) { | ||
1196 | DOM.entropyWeakEntropyOverrideWarning.removeClass("hidden"); | ||
1197 | } | ||
1198 | else { | ||
1199 | DOM.entropyWeakEntropyOverrideWarning.addClass("hidden"); | ||
1200 | } | ||
1201 | } | ||
1202 | else { | ||
1203 | // hide warning for weak entropy override | ||
1204 | DOM.entropyWeakEntropyOverrideWarning.addClass("hidden"); | ||
1193 | } | 1205 | } |
1194 | // Discard trailing entropy | 1206 | // Discard trailing entropy |
1195 | var bitsToUse = Math.floor(bits.length / 32) * 32; | 1207 | var bitsToUse = Math.floor(bits.length / 32) * 32; |