aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/index.html2
-rw-r--r--src/js/index.js27
-rw-r--r--tests/spec/tests.js15
3 files changed, 44 insertions, 0 deletions
diff --git a/src/index.html b/src/index.html
index 43a8e4f..67e9101 100644
--- a/src/index.html
+++ b/src/index.html
@@ -94,6 +94,8 @@
94 <div class="filtered col-sm-9 form-control-static"></div> 94 <div class="filtered col-sm-9 form-control-static"></div>
95 <label class="col-sm-3 control-label">Raw Binary</label> 95 <label class="col-sm-3 control-label">Raw Binary</label>
96 <div class="binary col-sm-9 form-control-static"></div> 96 <div class="binary col-sm-9 form-control-static"></div>
97 <label class="col-sm-3 control-label">Binary Checksum</label>
98 <div class="checksum col-sm-9 form-control-static">&nbsp;</div>
97 <label class="col-sm-3 control-label">Word Indexes</label> 99 <label class="col-sm-3 control-label">Word Indexes</label>
98 <div class="word-indexes col-sm-9 form-control-static">&nbsp;</div> 100 <div class="word-indexes col-sm-9 form-control-static">&nbsp;</div>
99 <label class="col-sm-3 control-label">Mnemonic Length</label> 101 <label class="col-sm-3 control-label">Mnemonic Length</label>
diff --git a/src/js/index.js b/src/js/index.js
index b36e992..0d573ba 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -38,6 +38,7 @@
38 DOM.entropyWordCount = DOM.entropyContainer.find(".word-count"); 38 DOM.entropyWordCount = DOM.entropyContainer.find(".word-count");
39 DOM.entropyBinary = DOM.entropyContainer.find(".binary"); 39 DOM.entropyBinary = DOM.entropyContainer.find(".binary");
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.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length"); 42 DOM.entropyMnemonicLength = DOM.entropyContainer.find(".mnemonic-length");
42 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning"); 43 DOM.entropyFilterWarning = DOM.entropyContainer.find(".filter-warning");
43 DOM.phrase = $(".phrase"); 44 DOM.phrase = $(".phrase");
@@ -1195,6 +1196,8 @@
1195 DOM.phrase.val(phrase); 1196 DOM.phrase.val(phrase);
1196 // Show the word indexes 1197 // Show the word indexes
1197 showWordIndexes(); 1198 showWordIndexes();
1199 // Show the checksum
1200 showChecksum();
1198 } 1201 }
1199 1202
1200 function clearEntropyFeedback() { 1203 function clearEntropyFeedback() {
@@ -1457,6 +1460,30 @@
1457 DOM.entropyWordIndexes.text(wordIndexesStr); 1460 DOM.entropyWordIndexes.text(wordIndexesStr);
1458 } 1461 }
1459 1462
1463 function showChecksum() {
1464 var phrase = DOM.phrase.val();
1465 var words = phraseToWordArray(phrase);
1466 var checksumBitlength = words.length / 3;
1467 var checksum = "";
1468 var binaryStr = "";
1469 var language = getLanguage();
1470 for (var i=words.length-1; i>=0; i--) {
1471 var word = words[i];
1472 var wordIndex = WORDLISTS[language].indexOf(word);
1473 var wordBinary = wordIndex.toString(2);
1474 while (wordBinary.length < 11) {
1475 wordBinary = "0" + wordBinary;
1476 }
1477 var binaryStr = wordBinary + binaryStr;
1478 if (binaryStr.length >= checksumBitlength) {
1479 var start = binaryStr.length - checksumBitlength;
1480 var end = binaryStr.length;
1481 checksum = binaryStr.substring(start, end);
1482 }
1483 }
1484 DOM.entropyChecksum.text(checksum);
1485 }
1486
1460 function updateCsv() { 1487 function updateCsv() {
1461 var tableCsv = "path,address,public key,private key\n"; 1488 var tableCsv = "path,address,public key,private key\n";
1462 var rows = DOM.addresses.find("tr"); 1489 var rows = DOM.addresses.find("tr");
diff --git a/tests/spec/tests.js b/tests/spec/tests.js
index 9e78016..f56b18d 100644
--- a/tests/spec/tests.js
+++ b/tests/spec/tests.js
@@ -2922,4 +2922,19 @@ it('Can encrypt private keys using BIP38', function(done) {
2922 }); 2922 });
2923}, bip38delay + 5000); 2923}, bip38delay + 5000);
2924 2924
2925it('Shows the checksum for the entropy', function(done) {
2926 driver.findElement(By.css('.use-entropy'))
2927 .click();
2928 driver.findElement(By.css('.entropy'))
2929 .sendKeys("00000000000000000000000000000000");
2930 driver.sleep(generateDelay).then(function() {
2931 driver.findElement(By.css('.checksum'))
2932 .getText()
2933 .then(function(text) {
2934 expect(text).toBe("1");
2935 done();
2936 });
2937 });
2938});
2939
2925}); 2940});