}, name);
}
+function selectBip85Language(language) {
+ driver.executeScript(function() {
+ var selectText = arguments[0];
+ $(".bip85-mnemonic-language option[selected]").removeAttr("selected");
+ $(".bip85-mnemonic-language option").filter(function(i,e) {
+ return $(e).html() == selectText;
+ }).prop("selected", true);
+ $(".bip85-mnemonic-language").trigger("change");
+ }, language);
+}
+
function testEntropyType(done, entropyText, entropyTypeUnsafe) {
// entropy type is compiled into regexp so needs escaping
// see https://stackoverflow.com/a/2593661
phrase: "abandon abandon ability",
firstAddress: "Mw2vK2Bvex1yYtYF6sfbEg2YGoUc98YUD2",
firstPubKey: "0398066486fe87cbcb9da8e29d180b44937b6c43ad1ec4d3bddd77b7905765937e",
- firstPrivKey: "L4A8sSkrGndiXyZdj6Fnju8Wu76s96cdHHmPxV3C5M2R2w4GVNco",
+ firstPrivKey: "TkJvbqVdNnGsCtFaV2nE8x3qqhYnYriRkGAB4747cEDRg9VUKKiz",
};
testNetwork(done, params);
});
};
testNetwork(done, params);
});
+it('Allows selection of Cosmos Hub', function(done) {
+ var params = {
+ selectText: "ATOM - Cosmos Hub",
+ phrase: "abandon abandon ability",
+ firstAddress: "cosmos17mkch9syem8gtf6wh7p38thdgav6dwezpkylny",
+ firstPubKey: "cosmospub1addwnpepq0sgn66ty4suk5vx3hsmxxqd5z3amegqwlu59funrzyz5u8r9758qhl84ys",
+ firstPrivKey: "zUnETPxmE2vkHzLHTAlO9wg8PL/GEEBc1I4yVwvSV8M=",
+ };
+ testNetwork(done, params);
+});
it('Allows selection of Auroracoin', function(done) {
var params = {
selectText: "AUR - Auroracoin",
};
testNetwork(done, params);
});
+it('Allows selection of FIO', function(done) {
+ var params = {
+ selectText: "FIO - Foundation for Interwallet Operability",
+ phrase: "valley alien library bread worry brother bundle hammer loyal barely dune brave",
+ firstPubKey: "FIO5kJKNHwctcfUM5XZyiWSqSTM5HTzznJP9F3ZdbhaQAHEVq575o",
+ firstPrivKey: "5Kbb37EAqQgZ9vWUHoPiC2uXYhyGSFNbL6oiDp24Ea1ADxV1qnu",
+ };
+ testNetwork(done, params);
+});
+it('Allows selection of Firo', function(done) {
+ var params = {
+ selectText: "FIRO - Firo (Zcoin rebrand)",
+ phrase: "abandon abandon ability",
+ firstAddress: "a6VcMdP4XgAA9Tr7xNszmPG5FZpfRf17Cq",
+ firstPubKey: "0236f2348c32dc62d69488b01988ed1154df261723ec60461cb6e62189984c62db",
+ firstPrivKey: "Y8k3XQRQrJoABEao4Sw45s744g6xth7yviNqFcN7zqPqKUJrrKTQ",
+ };
+ testNetwork(done, params);
+});
+it('Allows selection of Zcoin', function(done) {
+ var params = {
+ selectText: "XZC - Zcoin (rebranded to Firo)",
+ phrase: "abandon abandon ability",
+ firstAddress: "a6VcMdP4XgAA9Tr7xNszmPG5FZpfRf17Cq",
+ firstPubKey: "0236f2348c32dc62d69488b01988ed1154df261723ec60461cb6e62189984c62db",
+ firstPrivKey: "Y8k3XQRQrJoABEao4Sw45s744g6xth7yviNqFcN7zqPqKUJrrKTQ",
+ };
+ testNetwork(done, params);
+});
it('Allows selection of Firstcoin', function(done) {
var params = {
selectText: "FRST - Firstcoin",
};
testNetwork(done, params);
});
+it('Allows selection of Ritocoin', function(done) {
+ var params = {
+ selectText: "RITO - Ritocoin",
+ phrase: "abandon abandon ability",
+ firstAddress: "BMbHdwDiuaZh4ATp8Xapf4srv3swzAGgkf",
+ firstPubKey: "036f5f55dc37fa97294a2a5ae4d92735d4392d4405cbbebebf2d70d5d6781be622",
+ firstPrivKey: "Mdaumz3494kxCeiEBame4ZBzjtTQ5mYzD8notv2EBW8FcNy3PiYd",
+ };
+ testNetwork(done, params);
+});
it('Allows selection of Rubycoin', function(done) {
var params = {
selectText: "RBY - Rubycoin",
};
testNetwork(done, params);
});
-it('Allows selection of Zcoin', function(done) {
- var params = {
- selectText: "XZC - Zcoin",
- phrase: "abandon abandon ability",
- firstAddress: "a6VcMdP4XgAA9Tr7xNszmPG5FZpfRf17Cq",
- firstPubKey: "0236f2348c32dc62d69488b01988ed1154df261723ec60461cb6e62189984c62db",
- firstPrivKey: "Y8k3XQRQrJoABEao4Sw45s744g6xth7yviNqFcN7zqPqKUJrrKTQ",
- };
- testNetwork(done, params);
-});
it('Allows selection of Zcash', function(done) {
var params = {
selectText: "ZEC - Zcash",
};
testNetwork(done, params);
});
+it('Allows selection of Nano', function(done) {
+ var params = {
+ selectText: "NANO - Nano",
+ phrase: "deal wedding panda forum property artist whip total word student sea middle",
+ firstAddress: "nano_15fum9n68681dz73qyu37fuc9tro84gqm86eptdqpm9jutkfnt34agkoqpw5",
+ firstPubKey: "0dbb99e84310c05fca1bfb612b76a3eb15309d79988cb6977b4cf1dea4da6822",
+ firstPrivKey: "30633c8497cc47e0aefd52c7971ffd45e6c5d166274c7978feca3482a859c0af",
+ };
+ testNetwork(done, params);
+});
it('Allows selection of Wagerr', function(done) {
var params = {
selectText: "WGR - Wagerr",
});
it('Allows selection of RBTC - RSK', function(done) {
var params = {
- selectText: "RBTC - RSK",
+ selectText: "R-BTC - RSK",
phrase: "abandon abandon ability",
- firstAddress: "RGtz5TDdtviAZ9haz1YAUNQzcGVFm5bQrP",
- firstPubKey: "0219d9b5087ab68edc8a714969d8cb70e7159417b47a05932b227e6f417c7962b9",
- firstPrivKey: "UsiDPMcpYqCwtzGXo4wiPZp7cwBaKdmbmseioTc1rFQsg21adFc8",
+ firstAddress: "0x37CA764c4b2fe819108448b80d2F35921b035931",
+ firstPubKey: "0x0219d9b5087ab68edc8a714969d8cb70e7159417b47a05932b227e6f417c7962b9",
+ firstPrivKey: "0x6e6f48cc422825f7fd68f2200d3dde757849f15342f252eeb0bc4ebc46089fe1",
};
testNetwork(done, params);
});
it('Allows selection of tRBTC - RSK Testnet', function(done) {
var params = {
- selectText: "tRBTC - RSK Testnet",
+ selectText: "tR-BTC - RSK Testnet",
phrase: "abandon abandon ability",
- firstAddress: "RHkrWgnSdJHxQAqEsMErhUUa4icXY6xUUC",
- firstPubKey: "03f77eb7bd83e92ef47be1abddae7f71fb0bc8a7a1ee4b193662a86ed2705ffc5b",
- firstPrivKey: "UpqfuSEDKoacrPh4wMV4sJZqCB6DJfYe81oWBr4eb7y9FWQWoo2A",
+ firstAddress: "0x176484B5a155Fe802aCB26055eb1c193D5A576d5",
+ firstPubKey: "0x03f77eb7bd83e92ef47be1abddae7f71fb0bc8a7a1ee4b193662a86ed2705ffc5b",
+ firstPrivKey: "0x18c2400d2f818d28b80d0e31235873bfeef644fc45fd702f54ae0d422cff6ab3",
};
testNetwork(done, params);
});
};
testNetwork(done, params);
});
+it('Allows selection of CranePay', function(done) {
+ var params = {
+ selectText: "CRP - CranePay",
+ phrase: "abandon abandon ability",
+ firstAddress: "CcUHPqgmef1BmgWFa9g3YNc8scgVXVh8ip",
+ firstPubKey: "0392af9ea9dc78170c6f68c50bac926f960e50769295f539ac6382a3af2b928740",
+ firstPrivKey: "KHTCAvKHKg1WdLoDSg3VjjyZK5Wk1ihzJENpp2YMb1RmAxrCZrXX",
+ };
+ testNetwork(done, params);
+});
+it('Allows selection of Scribe', function(done) {
+ var params = {
+ selectText: "SCRIBE - Scribe",
+ phrase: "abandon abandon ability",
+ firstAddress: "RYAnPeBLD8veZ9Tw8xugeTC2f9PeZonLHM",
+ firstPubKey: "02c912bc4759c8a209475502fb5352ff5be8a8f13eb72f1732ee25125cd53edc1e",
+ firstPrivKey: "HLZWvNCEUv4ghygjH9A2EYCa9HNRcxe5CS42kzUTmoxJYp3z96QE",
+ };
+ testNetwork(done, params);
+});
+it('Allows selection of Binance Smart Chain', function(done) {
+ var params = {
+ selectText: "BSC - Binance Smart Chain",
+ phrase: "abandon abandon ability",
+ firstAddress: "0xe5815d5902Ad612d49283DEdEc02100Bd44C2772",
+ firstPubKey: "0x03e723e5b3aa7d72213f01139aa4783e1b34f74e1a04534e3fd8e29bfe2768af8a",
+ firstPrivKey: "0x8f253078b73d7498302bb78c171b23ce7a8fb511987d2b2702b731638a4a15e7",
+ };
+ testNetwork(done, params);
+});
+
+it('Allows selection of TRX on Tron', function(done) {
+ var params = {
+ selectText: "TRX - Tron",
+ phrase: "abandon abandon ability",
+ firstAddress: "TA891Fu7vVz595BGQpNX2MCzr7yBcxuoC7",
+ firstPubKey: "0337bbb060e6166066f7f9e59e52f67bc23a6c9d0cbc815b82b6d89112444842e7",
+ firstPrivKey: "3a8fbd0379a815764979de86a3fcda759cb62d49e784e7b2a9a03206c90cfae2",
+ };
+ testNetwork(done, params);
+});
+
+it('Allows selection of ZooBlockchain', function(done) {
+ var params = {
+ selectText: "ZBC - ZooBlockchain",
+ phrase: "shy invest oxygen real lunar moral merge corn program air affair amazing dove imitate combine solve library fresh case alcohol pole question act thing",
+ firstAddress: "ZBC_MGEZVH3U_SXPCBHTU_KSWDPQ4X_K6MSI3VR_CQAYMTLC_RXUMM3DJ_LFABCAXA",
+ firstPubKey: "61899a9f7495de209e7454ac37c3975799246eb11401864d628de8c66c695940",
+ firstPrivKey: "adb11e79068fa7366ec4f5963ad57115d666b1ad2b369b92d962563adf7dd48b",
+ };
+ testNetwork(done, params);
+});
// BIP39 seed is set from phrase
it('Sets the bip39 seed from the prhase', function(done) {
testEntropyBits(done, "0000", "4");
});
it("Shows the number of bits of entropy for 1 character of base 6 (dice)", function(done) {
- // 6 in card is 0 in base 6, 0 in base 6 is 2.6 bits (rounded down to 2 bits)
+ // 6 in card is 0 in base 6, 0 is mapped to 00 by entropy.js
testEntropyBits(done, "6", "2");
});
it("Shows the number of bits of entropy for 1 character of base 10 with 3 bits", function(done) {
testEntropyBits(done, "7", "3");
});
it("Shows the number of bits of entropy for 1 character of base 10 with 4 bis", function(done) {
- testEntropyBits(done, "8", "4");
+ // 8 in base 10 is mapped to 0 by entropy.js
+ testEntropyBits(done, "8", "1");
});
it("Shows the number of bits of entropy for 1 character of hex", function(done) {
testEntropyBits(done, "F", "4");
});
it("Shows the number of bits of entropy for 2 characters of base 10", function(done) {
- testEntropyBits(done, "29", "6");
+ // 2 as base 10 is binary 010, 9 is mapped to binary 1 by entropy.js
+ testEntropyBits(done, "29", "4");
});
it("Shows the number of bits of entropy for 2 characters of hex", function(done) {
testEntropyBits(done, "0A", "8");
testEntropyBits(done, "000A", "16");
});
it("Shows the number of bits of entropy for 4 characters of base 6", function(done) {
- testEntropyBits(done, "5555", "11");
+ // 5 in base 6 is mapped to binary 1
+ testEntropyBits(done, "5555", "4");
});
it("Shows the number of bits of entropy for 4 characters of base 6 dice", function(done) {
// uses dice, so entropy is actually 0000 in base 6, which is 4 lots of
- // 2.58 bits, which is 10.32 bits (rounded down to 10 bits)
- testEntropyBits(done, "6666", "10");
+ // binary 00
+ testEntropyBits(done, "6666", "8");
});
it("Shows the number of bits of entropy for 4 charactes of base 10", function(done) {
- // Uses base 10, which is 4 lots of 3.32 bits, which is 13.3 bits (rounded
- // down to 13)
- testEntropyBits(done, "2227", "13");
+ // 2 in base 10 is binary 010 and 7 is binary 111 so is 4 events of 3 bits
+ testEntropyBits(done, "2227", "12");
});
it("Shows the number of bits of entropy for 4 characters of hex with 2 leading zeros", function(done) {
testEntropyBits(done, "222F", "16");
testEntropyBits(done, "FFFF", "16");
});
it("Shows the number of bits of entropy for 10 characters of base 10", function(done) {
- // 10 events at 3.32 bits per event
- testEntropyBits(done, "0000101017", "33");
+ // 10 events with 3 bits for each event
+ testEntropyBits(done, "0000101017", "30");
+});
+it("Shows the number of bits of entropy for 10 characters of base 10 account for bias", function(done) {
+ // 9 events with 3 bits per event and 1 event with 1 bit per event
+ testEntropyBits(done, "0000101018", "28");
});
it("Shows the number of bits of entropy for a full deck of cards", function(done) {
- // cards are not replaced, so a full deck is not 52^52 entropy which is 296
- // bits, it's 52!, which is 225 bits
- testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "225");
+ // removing bias is 32*5 + 16*4 + 4*2
+ testEntropyBits(done, "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks", "232");
});
it("Shows details about the entered entropy", function(done) {
entropy: "7d",
type: "card",
events: "1",
- bits: "4",
+ bits: "5",
words: 0,
strength: "less than a second",
}
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
type: "card (full deck)",
events: "52",
- bits: "225",
+ bits: "232",
words: 21,
strength: "centuries",
}
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks3d",
type: "card (full deck, 1 duplicate: 3d)",
events: "53",
- bits: "254",
+ bits: "237",
words: 21,
strength: "centuries",
}
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d",
type: "card (2 duplicates: 3d 4d, 1 missing: KS)",
events: "53",
- bits: "254",
+ bits: "240",
words: 21,
strength: "centuries",
}
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqs3d4d5d6d",
type: "card (4 duplicates: 3d 4d 5d..., 1 missing: KS)",
events: "55",
- bits: "264",
- words: 24,
+ bits: "250",
+ words: 21,
strength: "centuries",
}
);
it("Shows details about the entered entropy", function(done) {
testEntropyFeedback(done,
// Next test was throwing uncaught error in zxcvbn
- // Also tests 451 bits, ie Math.log2(52!)*2 = 225.58 * 2
{
entropy: "ac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsksac2c3c4c5c6c7c8c9ctcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
type: "card (full deck, 52 duplicates: ac 2c 3c...)",
events: "104",
- bits: "499",
- words: 45,
+ bits: "464",
+ words: 42,
strength: "centuries",
}
);
entropy: "asAS",
type: "card (1 duplicate: AS)",
events: "2",
- bits: "9",
+ bits: "8",
words: 0,
strength: "less than a second",
}
entropy: "ASas",
type: "card (1 duplicate: as)",
events: "2",
- bits: "9",
+ bits: "8",
words: 0,
strength: "less than a second",
}
entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d5d6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
type: "card (1 missing: 9C)",
events: "51",
- bits: "221",
- words: 18,
+ bits: "227",
+ words: 21,
strength: "centuries",
}
);
entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjdqdkdah2h3h4h5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
type: "card (2 missing: 9C 5D)",
events: "50",
- bits: "216",
+ bits: "222",
words: 18,
strength: "centuries",
}
entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d7d8d9dtdjd kdah2h3h 5h6h7h8h9hthjhqhkhas2s3s4s5s6s7s8s9stsjsqsks",
type: "card (4 missing: 9C 5D QD...)",
events: "48",
- bits: "208",
+ bits: "212",
words: 18,
strength: "centuries",
}
entropy: "ac2c3c4c5c6c7c8c tcjcqckcad2d3d4d 6d 8d9d jd kdah2h3h 5h6h7h8h9hthjhqhkh 2s3s4s5s6s7s8s9stsjsqsks",
type: "card",
events: "45",
- bits: "195",
+ bits: "198",
words: 18,
strength: "centuries",
}
);
});
it("Shows details about the entered entropy", function(done) {
+ // multiple decks does not affect the bits per event
+ // since the bits are hardcoded in entropy.js
testEntropyFeedback(done,
- // Multiple decks of cards increases bits per event
{
entropy: "3d",
events: "1",
- bits: "4",
- bitsPerEvent: "4.34",
+ bits: "5",
+ bitsPerEvent: "4.46",
}
);
});
{
entropy: "3d3d",
events: "2",
- bits: "9",
- bitsPerEvent: "4.80",
+ bits: "10",
+ bitsPerEvent: "4.46",
}
);
});
entropy: "3d3d3d",
events: "3",
bits: "15",
- bitsPerEvent: "5.01",
+ bitsPerEvent: "4.46",
}
);
});
entropy: "3d3d3d3d",
events: "4",
bits: "20",
- bitsPerEvent: "5.14",
+ bitsPerEvent: "4.46",
}
);
});
{
entropy: "3d3d3d3d3d",
events: "5",
- bits: "26",
- bitsPerEvent: "5.22",
+ bits: "25",
+ bitsPerEvent: "4.46",
}
);
});
{
entropy: "3d3d3d3d3d3d",
events: "6",
- bits: "31",
- bitsPerEvent: "5.28",
+ bits: "30",
+ bitsPerEvent: "4.46",
}
);
});
{
entropy: "3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d",
events: "33",
- bits: "184",
- bitsPerEvent: "5.59",
+ bits: "165",
+ bitsPerEvent: "4.46",
strength: 'less than a second - Repeats like "abcabcabc" are only slightly harder to guess than "abc"',
}
);
// https://bip32jp.github.io/english/index.html
// NOTES:
// Is incompatible with:
+// base 6
// base 20
it('Is compatible with bip32jp.github.io', function(done) {
- var entropy = "543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543210543";
- var expectedPhrase = "train then jungle barely whip fiber purpose puppy eagle cloud clump hospital robot brave balcony utility detect estate old green desk skill multiply virus";
+ var entropy = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
+ var expectedPhrase = "primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary fetch primary foster";
driver.findElement(By.css('.use-entropy'))
.click();
driver.findElement(By.css('.entropy'))
});
});
+// 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('Show BIP85 in non-English languages', function(done) {
+ pending("BIP85 library update");
+ 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();
+ selectBip85Language("3");
+ 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).not.toBe('girl mad pet galaxy egg matter matrix prison refuse sense ordinary nose')
+ //expect(childMnemonic).toBe('Not sure yet, something Spanish')
+ done();
+ })
+ });
+ });
+});
+
// It allows manually specifying the entropy type
it('Allows entropy type to be manually selected', function(done) {
driver.findElement(By.css('.use-entropy'))