1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

core/tests: expand slip39 test_error_location

This commit is contained in:
Pavol Rusnak 2019-06-18 23:50:03 +02:00
parent 84d3723ee9
commit 2d8e11e827
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -156,13 +156,17 @@ class TestCryptoSlip39(unittest.TestCase):
def test_error_location(self):
mnemonics = ["duckling enlarge academic academic agency result length solution fridge kidney coal piece deal husband erode duke ajar critical decision keyboard", "theory painting academic academic armed sweater year military elder discuss acne wildlife boring employer fused large satoshi bundle carbon diagnose anatomy hamster leaves tracks paces beyond phantom capital marvel lips brave detect luck"]
mnemonics = [
"duckling enlarge academic academic agency result length solution fridge kidney coal piece deal husband erode duke ajar critical decision keyboard",
"theory painting academic academic armed sweater year military elder discuss acne wildlife boring employer fused large satoshi bundle carbon diagnose anatomy hamster leaves tracks paces beyond phantom capital marvel lips brave detect luck",
]
for mnemonic in mnemonics:
data = tuple(slip39.mnemonic_to_indices(mnemonic))
self.assertEqual(slip39.rs1024_error_index(data), None)
for i in range(len(data)):
error_data = data[:i] + (data[i]^1,) + data[i+1:]
self.assertEqual(slip39.rs1024_error_index(error_data), i)
for _ in range(50):
error_data = error_data = data[:i] + (data[i] ^ (random.uniform(1023) + 1), ) + data[i + 1:]
self.assertEqual(slip39.rs1024_error_index(error_data), i)
if __name__ == '__main__':