Ejemplo n.º 1
0
 def test_generate(self):
     mnemonics = generate(24)
     mnemonics = mnemonics.split(" ")
     mnemonics_length = len(mnemonics)
     self.assertEqual(mnemonics_length, 24)
     for word in mnemonics:
         self.assertTrue(word in WORDLIST["english"])
Ejemplo n.º 2
0
 def test_generate_italian(self):
     language = "italian"
     mnemonics = generate(24, language)
     mnemonics = mnemonics.split(" ")
     mnemonics_length = len(mnemonics)
     self.assertEqual(mnemonics_length, 24)
     for word in mnemonics:
         self.assertTrue(word in WORDLIST[language])
Ejemplo n.º 3
0
    def test_recovery(self):
        mnemonics = generate(18)
        # Get 5 of 8 split
        shamir_shares = split_shares(mnemonics, 7, 10)
        self.assertEqual(len(shamir_shares), 10)
        recovered_mnemonics = combine_shares(shamir_shares[:9])
        self.assertEqual(recovered_mnemonics, mnemonics)

        self.assertRaises(BadRequest, combine_shares, shamir_shares[:6])
Ejemplo n.º 4
0
 def test_split_shares_base58(self):
     mnemonics = generate(15)
     # Get 5 of 8 split
     shamir_shares = split_shares(mnemonics, 5, 8, encoding=Encoding.BASE58)
     self.assertEqual(len(shamir_shares), 8)
     random.shuffle(shamir_shares)
     recovered_mnemonics = combine_shares(shamir_shares[:5],
                                          encoding=Encoding.BASE58)
     self.assertEqual(recovered_mnemonics, mnemonics)
Ejemplo n.º 5
0
    def generate_mnemonics(self):
        """
        Callback function for generate button
        """
        number_of_words = int(self.numberWords.currentText())
        language = self.languageComboBox.currentText()
        mnemonics = generate(number_of_words, language=language)

        self.sharesTextEdit.clear()
        self.mnemonicsTextEdit.setText(mnemonics)
Ejemplo n.º 6
0
    def test_split_shares_italian(self):
        language = "italian"
        mnemonics = generate(15, language)
        # Get 5 of 8 split
        shamir_shares = split_shares(mnemonics, 5, 8, language=language)
        self.assertEqual(len(shamir_shares), 8)

        random.shuffle(shamir_shares)
        recovered_mnemonics = combine_shares(shamir_shares[:5],
                                             language=language)
        self.assertEqual(recovered_mnemonics, mnemonics)
Ejemplo n.º 7
0
def gen(words, export, lang):
    """
    Command to generate new set of BIP39 mnemonics
    """
    if words not in [12,15,18,21,24]:
        raise click.BadParameter(message="Incorrect option selected. Options available- [12,15,18,21,24]")

    new_mnemonics = generate(words, LANG_MAP[lang])
    click.echo(new_mnemonics)

    if export:
        file_handler = open("mnemonic.txt", "w")
        file_handler.write(new_mnemonics)
        file_handler.close()
Ejemplo n.º 8
0
 def test_recovery_base58(self):
     mnemonics = generate(18)
     # Get 5 of 8 split
     shamir_shares = split_shares(mnemonics,
                                  7,
                                  10,
                                  encoding=Encoding.BASE58)
     self.assertEqual(len(shamir_shares), 10)
     recovered_mnemonics = combine_shares(shamir_shares[:9],
                                          encoding=Encoding.BASE58)
     self.assertEqual(recovered_mnemonics, mnemonics)
     #Verify not equal values with less shares
     recovered_incorrect = combine_shares(shamir_shares[:6],
                                          encoding=Encoding.BASE58)
     self.assertNotEqual(mnemonics, recovered_incorrect)
Ejemplo n.º 9
0
    def test_base58_french(self):
        language = "french"
        mnemonics = generate(24, language=language)
        # Get 5 of 8 split
        shamir_shares = split_shares(mnemonics,
                                     10,
                                     15,
                                     encoding=Encoding.BASE58,
                                     language=language)
        self.assertEqual(len(shamir_shares), 15)
        random.shuffle(shamir_shares)
        recovered_mnemonics = combine_shares(shamir_shares[:10],
                                             encoding=Encoding.BASE58,
                                             language=language)
        self.assertEqual(recovered_mnemonics, mnemonics)

        recovered_incorrect = combine_shares(shamir_shares[:6],
                                             encoding=Encoding.BASE58,
                                             language=language)
        self.assertNotEqual(mnemonics, recovered_incorrect)
Ejemplo n.º 10
0
    def test_base58_italian(self):
        language = "italian"
        mnemonics = generate(15, language=language)
        # Get 5 of 8 split
        shamir_shares = split_shares(mnemonics,
                                     5,
                                     8,
                                     encoding=Encoding.BASE58,
                                     language=language)
        self.assertEqual(len(shamir_shares), 8)
        random.shuffle(shamir_shares)
        recovered_mnemonics = combine_shares(shamir_shares[:5],
                                             encoding=Encoding.BASE58,
                                             language=language)
        self.assertEqual(recovered_mnemonics, mnemonics)

        recovered_incorrect = combine_shares(shamir_shares[:3],
                                             encoding=Encoding.BASE58,
                                             language=language)
        self.assertNotEqual(mnemonics, recovered_incorrect)