1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

core/reset: check three words

closes #289
This commit is contained in:
Tomas Susanka 2019-07-08 09:37:36 +02:00
parent 96cdd886bc
commit db0847282a
3 changed files with 12 additions and 11 deletions

View File

@ -68,14 +68,15 @@ async def confirm_backup_again(ctx):
async def _confirm_share_words(ctx, share_index, share_words): async def _confirm_share_words(ctx, share_index, share_words):
numbered = list(enumerate(share_words)) numbered = list(enumerate(share_words))
# check a word from the first half # check three words
first_half = numbered[: len(numbered) // 2] third = len(numbered) // 3
if not await _confirm_word(ctx, share_index, first_half): # if the num of words is not dividable by 3 let's add 1
return False # to have more words at the beggining and to check all of them
if len(numbered) % 3:
third += 1
# check a word from the second half for part in utils.chunks(numbered, third):
second_half = numbered[len(numbered) // 2 :] if not await _confirm_word(ctx, share_index, part):
if not await _confirm_word(ctx, share_index, second_half):
return False return False
return True return True

View File

@ -84,7 +84,7 @@ class TestMsgResetDeviceT2(TrezorTest):
self.client.debug.press_yes() self.client.debug.press_yes()
# check share # check share
for _ in range(2): for _ in range(3):
time.sleep(1) time.sleep(1)
index = self.client.debug.state().reset_word_pos index = self.client.debug.state().reset_word_pos
self.client.debug.input(words[index]) self.client.debug.input(words[index])

View File

@ -64,7 +64,7 @@ class TestMsgResetDeviceT2(TrezorTest):
self.client.debug.press_yes() self.client.debug.press_yes()
# check backup words # check backup words
for _ in range(2): for _ in range(3):
time.sleep(1) time.sleep(1)
index = self.client.debug.state().reset_word_pos index = self.client.debug.state().reset_word_pos
self.client.debug.input(words[index]) self.client.debug.input(words[index])
@ -169,7 +169,7 @@ class TestMsgResetDeviceT2(TrezorTest):
self.client.debug.press_yes() self.client.debug.press_yes()
# check backup words # check backup words
for _ in range(2): for _ in range(3):
time.sleep(1) time.sleep(1)
index = self.client.debug.state().reset_word_pos index = self.client.debug.state().reset_word_pos
self.client.debug.input(words[index]) self.client.debug.input(words[index])