<option value="21">21</option>
<option value="24">24</option>
</select>
- <span>words</span>
+ <span>words</span>.
+ <p class="warning help-block hidden">
+ <span class="text-danger">
+ Mnemonics with less than 12 words have low entropy and may be guessed by an attacker.
+ </span>
+ </p>
</div>
</div>
</div>
DOM.bip141path = $("#bip141-path");
DOM.bip141semantics = $(".bip141-semantics");
DOM.generatedStrength = $(".generate-container .strength");
+ DOM.generatedStrengthWarning = $(".generate-container .warning");
DOM.hardenedAddresses = $(".hardened-addresses");
DOM.useBitpayAddressesContainer = $(".use-bitpay-addresses-container");
DOM.useBitpayAddresses = $(".use-bitpay-addresses");
function init() {
// Events
+ DOM.generatedStrength.on("change", generatedStrengthChanged);
DOM.network.on("change", networkChanged);
DOM.bip32Client.on("change", bip32ClientChanged);
DOM.useEntropy.on("change", setEntropyVisibility);
// Event handlers
+ function generatedStrengthChanged() {
+ var strength = parseInt(DOM.generatedStrength.val());
+ if (strength < 12) {
+ DOM.generatedStrengthWarning.removeClass("hidden");
+ }
+ else {
+ DOM.generatedStrengthWarning.addClass("hidden");
+ }
+ }
+
function networkChanged(e) {
clearDerivedKeys();
clearAddressesList();
});
});
+it('Shows a warning if generating weak mnemonics', function(done) {
+ driver.executeScript(function() {
+ $(".strength option[selected]").removeAttr("selected");
+ $(".strength option[value=6]").prop("selected", true);
+ $(".strength").trigger("change");
+ });
+ driver.findElement(By.css(".generate-container .warning"))
+ .getAttribute("class")
+ .then(function(classes) {
+ expect(classes).not.toContain("hidden");
+ done();
+ });
+});
+
+it('Does not show a warning if generating strong mnemonics', function(done) {
+ driver.executeScript(function() {
+ $(".strength option[selected]").removeAttr("selected");
+ $(".strength option[value=12]").prop("selected", true);
+ });
+ driver.findElement(By.css(".generate-container .warning"))
+ .getAttribute("class")
+ .then(function(classes) {
+ expect(classes).toContain("hidden");
+ done();
+ });
+});
+
});