示例#1
0
 def test_deterministic(self):
     arr = ShareSet.generate_shares(
         "abandon "*11+"about", 2, 3, passphrase=b"qwe",
         exponent=1,
         randint=lambda v1,v2: 7 # very non-random rng
     )
     self.assertEqual(arr, [
         "academic discuss acrobat leader ambition human stay item benefit ladle endless season empty install reaction jewelry adapt lift idea victim",
         "academic discuss beard leader beaver argue geology ivory muscle prisoner forward aluminum sugar float ancient daisy legs verify railroad general",
         "academic discuss ceramic leader dragon preach pipeline shelter branch roster away envy resident crazy payroll staff adapt crush closet burning",
     ])
示例#2
0
 def test_generate(self):
     test_cases = ["zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong", "void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold"]
     for bip39_mnemonic in test_cases:
         passphrase = b"embittest"
         for k, n in ((2, 3), (3, 5), (5, 5), (9, 9), (13, 15), (2, 8)):
             slip39_mnemonics = ShareSet.generate_shares(
                 bip39_mnemonic, k, n, passphrase=passphrase, exponent=2
             )
             self.assertEqual(
                 ShareSet.recover_mnemonic(slip39_mnemonics[:k], passphrase),
                 bip39_mnemonic,
             )