def backup_flow_slip39_advanced(client): mnemonics = [] def input_flow(): # 1. Confirm Reset # 2. shares info # 3. Set & Confirm number of groups # 4. threshold info # 5. Set & confirm group threshold value # 6-15: for each of 5 groups: # 1. Set & Confirm number of shares # 2. Set & confirm share threshold value # 16. Confirm show seeds yield from click_through(client.debug, screens=16, code=B.ResetDevice) # show & confirm shares for all groups for _ in range(5): for _ in range(5): # mnemonic phrases btn_code = yield assert btn_code == B.ResetDevice mnemonic = read_and_confirm_mnemonic(client.debug, words=20) mnemonics.append(mnemonic) # Confirm continue to next share btn_code = yield assert btn_code == B.Success client.debug.press_yes() # safety warning btn_code = yield assert btn_code == B.Success client.debug.press_yes() with client: client.set_input_flow(input_flow) client.set_expected_responses( [messages.ButtonRequest(code=B.ResetDevice)] * 6 # intro screens + [ messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), ] * 5 # group thresholds + [ messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), ] * 25 # individual shares + [messages.ButtonRequest(code=B.Success), messages.Success()]) device.backup(client) mnemonics = mnemonics[0:3] + mnemonics[5:8] + mnemonics[10:13] ms = shamir.combine_mnemonics(mnemonics) identifier, iteration_exponent, _, _, _ = shamir._decode_mnemonics( mnemonics) secret = shamir._encrypt(ms, b"", iteration_exponent, identifier) return secret
def _check_no_pin(client): client.clear_session() assert client.features.pin_protection is False def input_flow(): yield from _input_flow_set_pin(client.debug, PIN4) yield from _input_flow_clear_pin(client.debug, PIN4) with client: client.set_expected_responses( [messages.ButtonRequest()] * 4 + [messages.Success(), messages.Features()] + [messages.ButtonRequest()] * 3 + [messages.Success(), messages.Features()]) client.set_input_flow(input_flow) device.change_pin(client) device.change_pin(client, remove=True) assert client.features.pin_protection is False
def test_verify_message(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses( [proto.ButtonRequest(), proto.Success()]) self.client.verify_message( 'Bitcoin', '14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e', unhexlify( '209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80' ), 'This is an example of a signed message.')
def test_apply_settings(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([ proto.PinMatrixRequest(), proto.ButtonRequest(), proto.Success(), proto.Features() ]) # TrezorClient reinitializes device self.client.apply_settings(label='nazdar')
def test_ping(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success() ]) self.client.ping('msg', True, True, True)
def test_pin(self): self.setup_mnemonic_pin_passphrase() with self.client: assert self.client.debug.read_pin()[0] == self.pin4 self.client.setup_debuglink(button=True, pin_correct=True) self.client.set_expected_responses( [proto.ButtonRequest(), proto.PinMatrixRequest(), proto.Success()] ) self._some_protected_call(True, True, False)
def set_autolock_delay(client, delay): with client: client.use_pin_sequence([PIN4]) client.set_expected_responses([ pin_request(client), messages.ButtonRequest(), messages.Success(), messages.Features(), ]) device.apply_settings(client, auto_lock_delay_ms=delay)
def test_apply_settings(self, client): with client: client.use_pin_sequence([PIN4]) client.set_expected_responses([ proto.PinMatrixRequest(), proto.ButtonRequest(), proto.Success(), proto.Features(), ]) # TrezorClient reinitializes device device.apply_settings(client, label="nazdar")
def _check_pin(client, pin): client.clear_session() assert client.features.pin_protection is True with client: client.set_expected_responses( [messages.ButtonRequest()] * 5 + [messages.Success(), messages.Features()]) client.set_input_flow(_input_flow_change_pin(client.debug, pin, pin)) device.change_pin(client)
def test_pin(self, client): with client: assert client.debug.read_pin()[0] == "1234" client.setup_debuglink(button=True, pin_correct=True) client.set_expected_responses([ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.Success() ]) self._some_protected_call(client, True, True, False)
def test_pin_passphrase(self): mnemonic = self.mnemonic12.split(" ") ret = self.client.call_raw( proto.RecoveryDevice( passphrase_protection=True, pin_protection=True, label="label", enforce_wordlist=True, )) # Confirm Recovery assert isinstance(ret, proto.ButtonRequest) self.client.debug.press_yes() ret = self.client.call_raw(proto.ButtonAck()) # Enter word count assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicWordCount) self.client.debug.input(str(len(mnemonic))) ret = self.client.call_raw(proto.ButtonAck()) # Enter mnemonic words assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicInput) self.client.transport.write(proto.ButtonAck()) for word in mnemonic: time.sleep(1) self.client.debug.input(word) ret = self.client.transport.read() # Enter PIN for first time assert ret == proto.ButtonRequest(code=proto.ButtonRequestType.Other) self.client.debug.input("654") ret = self.client.call_raw(proto.ButtonAck()) # Enter PIN for second time assert ret == proto.ButtonRequest(code=proto.ButtonRequestType.Other) self.client.debug.input("654") ret = self.client.call_raw(proto.ButtonAck()) # Confirm success assert isinstance(ret, proto.ButtonRequest) self.client.debug.press_yes() ret = self.client.call_raw(proto.ButtonAck()) # Workflow succesfully ended assert ret == proto.Success(message="Device recovered") # Mnemonic is the same self.client.init_device() assert self.client.debug.read_mnemonic_secret( ) == self.mnemonic12.encode() assert self.client.features.pin_protection is True assert self.client.features.passphrase_protection is True
def test_backup_slip39_basic(client): assert client.features.needs_backup is True mnemonics = [] def input_flow(): # 1. Checklist # 2. Number of shares (5) # 3. Checklist # 4. Threshold (3) # 5. Checklist # 6. Confirm show seeds yield from click_through(client.debug, screens=6, code=B.ResetDevice) # Mnemonic phrases for _ in range(5): yield # Phrase screen mnemonic = read_and_confirm_mnemonic(client.debug, words=20) mnemonics.append(mnemonic) yield # Confirm continue to next client.debug.press_yes() # Confirm backup yield client.debug.press_yes() with client: client.set_input_flow(input_flow) client.set_expected_responses([ messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), messages.ButtonRequest(code=B.ResetDevice), messages.ButtonRequest(code=B.Success), messages.ButtonRequest(code=B.Success), messages.Success(), ]) device.backup(client) client.init_device() assert client.features.needs_backup is False expected_ms = shamir.combine_mnemonics(MNEMONIC_SLIP39_BASIC_20_3of6) actual_ms = shamir.combine_mnemonics(mnemonics[:3]) assert expected_ms == actual_ms
def test_set_remove_wipe_code(client): # Test set wipe code. assert client.features.wipe_code_protection is False with client: client.set_expected_responses( [messages.ButtonRequest()] * 5 + [messages.Success(), messages.Features()]) client.set_input_flow( _input_flow_set_wipe_code(client.debug, PIN4, WIPE_CODE4)) device.change_wipe_code(client) client.init_device() assert client.features.wipe_code_protection is True _check_wipe_code(client, PIN4, WIPE_CODE4) # Test change wipe code. with client: client.set_expected_responses( [messages.ButtonRequest()] * 5 + [messages.Success(), messages.Features()]) client.set_input_flow( _input_flow_set_wipe_code(client.debug, PIN4, WIPE_CODE6)) device.change_wipe_code(client) client.init_device() assert client.features.wipe_code_protection is True _check_wipe_code(client, PIN4, WIPE_CODE6) # Test remove wipe code. with client: client.set_expected_responses( [messages.ButtonRequest()] * 3 + [messages.Success(), messages.Features()]) client.set_input_flow(_input_flow_clear_pin(client.debug, PIN4)) device.change_wipe_code(client, remove=True) client.init_device() assert client.features.wipe_code_protection is False
def test_nopin_nopassphrase(self, client): mnemonic = MNEMONIC12.split(" ") ret = client.call_raw( proto.RecoveryDevice( passphrase_protection=False, pin_protection=False, label="label", enforce_wordlist=True, )) # Confirm Recovery assert isinstance(ret, proto.ButtonRequest) client.debug.press_yes() ret = client.call_raw(proto.ButtonAck()) # Homescreen assert isinstance(ret, proto.ButtonRequest) client.debug.press_yes() ret = client.call_raw(proto.ButtonAck()) # Enter word count assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicWordCount) client.debug.input(str(len(mnemonic))) ret = client.call_raw(proto.ButtonAck()) # Homescreen assert isinstance(ret, proto.ButtonRequest) client.debug.press_yes() ret = client.call_raw(proto.ButtonAck()) # Enter mnemonic words assert ret == proto.ButtonRequest( code=proto.ButtonRequestType.MnemonicInput) client.transport.write(proto.ButtonAck()) for word in mnemonic: client.debug.input(word) ret = client.transport.read() # Confirm success assert isinstance(ret, proto.ButtonRequest) client.debug.press_yes() ret = client.call_raw(proto.ButtonAck()) # Workflow succesfully ended assert ret == proto.Success(message="Device recovered") # Mnemonic is the same client.init_device() assert client.debug.read_mnemonic_secret() == MNEMONIC12.encode() assert client.features.pin_protection is False assert client.features.passphrase_protection is False assert client.features.backup_type is proto.BackupType.Bip39
def test_apply_homescreen(self): self.setup_mnemonic_pin_passphrase() img = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x04\x88\x02\x00\x00\x00\x02\x91\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x90@\x00\x11@\x00\x00\x00\x00\x00\x00\x08\x00\x10\x92\x12\x04\x00\x00\x05\x12D\x00\x00\x00\x00\x00 \x00\x00\x08\x00Q\x00\x00\x02\xc0\x00\x00\x00\x00\x00\x00\x00\x10\x02 \x01\x04J\x00)$\x00\x00\x00\x00\x80\x00\x00\x00\x00\x08\x10\xa1\x00\x00\x02\x81 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\tP\x00\x00\x00\x00\x00\x00 \x00\x00\xa0\x00\xa0R \x12\x84\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x08\x00\tP\x00\x00\x00\x00 \x00\x04 \x00\x80\x02\x00@\x02T\xc2 \x00\x00\x00\x00\x00\x00\x00\x10@\x00)\t@\n\xa0\x80\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x80@\x14\xa9H\x04\x00\x00\x88@\x00\x00\x00\x00\x00\x02\x02$\x00\x15B@\x00\nP\x00\x00\x00\x00\x00\x80\x00\x00\x91\x01UP\x00\x00 \x02\x00\x00\x00\x00\x00\x00\x02\x08@ Z\xa5 \x00\x00\x80\x00\x00\x00\x00\x00\x00\x08\xa1%\x14*\xa0\x00\x00\x02\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00@\xaa\x91 \x00\x05E\x80\x00\x00\x00\x00\x00\x02*T\x05-D\x00\x00\x05 @\x00\x00\x00\x00\x00%@\x80\x11V\xa0\x88\x00\x05@\xb0\x00\x00\x00\x00\x00\x818$\x04\xabD \x00\x06\xa1T\x00\x00\x00\x00\x02\x03\xb8\x01R\xd5\x01\x00\x00\x05AP\x00\x00\x00\x00\x08\xadT\x00\x05j\xa4@\x00\x87ah\x00\x00\x00\x00\x02\x8d\xb8\x08\x00.\x01\x00\x00\x02\xa5\xa8\x10\x00\x00\x00*\xc1\xec \n\xaa\x88 \x02@\xf6\xd0\x02\x00\x00\x00\x0bB\xb6\x14@U"\x80\x00\x01{`\x00\x00\x00\x00M\xa3\xf8 \x15*\x00\x00\x00\x10n\xc0\x04\x00\x00\x02\x06\xc2\xa8)\x00\x96\x84\x80\x00\x00\x1b\x00\x00\x80@\x10\x87\xa7\xf0\x84\x10\xaa\x10\x00\x00D\x00\x00\x02 \x00\x8a\x06\xfa\xe0P\n-\x02@\x00\x12\x00\x00\x00\x00\x10@\x83\xdf\xa0\x00\x08\xaa@\x00\x00\x01H\x00\x05H\x04\x12\x01\xf7\x81P\x02T\t\x00\x00\x00 \x00\x00\x84\x10\x00\x00z\x00@)* \x00\x00\x01\n\xa0\x02 \x05\n\x00\x00\x05\x10\x84\xa8\x84\x80\x00\x00@\x14\x00\x92\x10\x80\x00\x04\x11@\tT\x00\x00\x00\x00\n@\x00\x08\x84@$\x00H\x00\x12Q\x02\x00\x00\x00\x00\x90\x02A\x12\xa8\n\xaa\x92\x10\x04\xa8\x10@\x00\x00\x04\x04\x00\x04I\x00\x04\x14H\x80"R\x01\x00\x00\x00!@\x00\x00$\xa0EB\x80\x08\x95hH\x00\x00\x00\x84\x10 \x05Z\x00\x00(\x00\x02\x00\xa1\x01\x00\x00\x04\x00@\x82\x00\xadH*\x92P\x00\xaaP\x00\x00\x00\x00\x11\x02\x01*\xad\x01\x00\x01\x01"\x11D\x08\x00\x00\x10\x80 \x00\x81W\x80J\x94\x04\x08\xa5 !\x00\x00\x00\x02\x00B*\xae\xa1\x00\x80\x10\x01\x08\xa4\x00\x00\x00\x00\x00\x84\x00\t[@"HA\x04E\x00\x84\x00\x00\x00\x10\x00\x01J\xd5\x82\x90\x02\x00!\x02\xa2\x00\x00\x00\x00\x00\x00\x00\x05~\xa0\x00 \x10\n)\x00\x11\x00\x00\x00\x00\x00\x00!U\x80\xa8\x88\x82\x80\x01\x00\x00\x00\x00\x00\x00H@\x11\xaa\xc0\x82\x00 *\n\x00\x00\x00\x00\x00\x00\x00\x00\n\xabb@ \x04\x00! \x84\x00\x00\x00\x00\x02@\xa5\x15A$\x04\x81(\n\x00\x00\x00\x00\x00\x00 \x01\x10\x02\xe0\x91\x02\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01 \xa9\tQH@\x91 P\x00\x00\x00\x00\x00\x00\x08\x00\x00\xa0T\xa5\x00@\x80\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"\x00\x00\x00\x00\xa2\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00 T\xa0\t\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00@\x02\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00*\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x10\x00\x00\x10\x02\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00@\x04\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00@\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x08@\x10\x00\x00\x00\x00' with self.client: self.client.set_expected_responses([proto.PinMatrixRequest(), proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(homescreen=img)
def test_apply_auto_lock_delay(self): self.setup_mnemonic_pin_passphrase() with self.client: self.client.set_expected_responses(EXPECTED_RESPONSES_PIN) device.apply_settings(self.client, auto_lock_delay_ms=int(10e3)) # 10 secs time.sleep(0.1) # sleep less than auto-lock delay with self.client: # No PIN protection is required. self.client.set_expected_responses([proto.Success()]) self.client.ping(msg="", pin_protection=True) time.sleep(10.1) # sleep more than auto-lock delay with self.client: self.client.set_expected_responses( [proto.PinMatrixRequest(), proto.Success()]) self.client.ping(msg="", pin_protection=True)
def test_recovery_device(self): with self.client: self.client.set_mnemonic(self.mnemonic12) self.client.set_expected_responses( [proto.WordRequest()] * 24 + [proto.Success(), proto.Features()]) self.client.recovery_device(12, False, False, 'label', 'english') # This must fail, because device is already initialized with pytest.raises(Exception): self.client.recovery_device(12, False, False, 'label', 'english')
def test_ping(self, client): with client: client.set_expected_responses( [ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success(), ] ) client.ping("msg", True, True, True)
def test_change_pin(self, client): with client: client.set_expected_responses([ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.Success(), proto.Features(), ]) device.change_pin(client)
def test_apply_settings(self): self.setup_mnemonic_pin_passphrase() assert self.client.features.label == 'test' with self.client: self.client.set_expected_responses([proto.PinMatrixRequest(), proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(label='new label') assert self.client.features.label == 'new label'
def test_invalid_language(self): self.setup_mnemonic_pin_passphrase() assert self.client.features.language == 'english' with self.client: self.client.set_expected_responses([proto.PinMatrixRequest(), proto.ButtonRequest(), proto.Success(), proto.Features()]) self.client.apply_settings(language='nonexistent') assert self.client.features.language == 'english'
def test_change_pin(self): with self.client: self.setup_mnemonic_pin_passphrase() self.client.set_expected_responses([ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.PinMatrixRequest(), proto.Success(), proto.Features() ]) self.client.change_pin()
def test_reset_device(self): with self.client: self.client.set_expected_responses( [proto.EntropyRequest()] + [proto.ButtonRequest()] * 24 + [proto.Success(), proto.Features()]) self.client.reset_device(False, 128, True, False, 'label', 'english') # This must fail, because device is already initialized with pytest.raises(Exception): self.client.reset_device(False, 128, True, False, 'label', 'english')
def recover(client, mnemonic): debug = client.debug words = mnemonic.split(" ") def input_flow(): yield # Confirm recovery debug.press_yes() yield # Homescreen debug.press_yes() yield # Enter word count debug.input(str(len(words))) yield # Homescreen debug.press_yes() yield # Enter words for word in words: debug.input(word) yield # confirm success debug.press_yes() with client: client.set_input_flow(input_flow) client.set_expected_responses([ messages.ButtonRequest(code=B.ProtectCall), messages.ButtonRequest(code=B.RecoveryHomepage), messages.ButtonRequest(code=B.MnemonicWordCount), messages.ButtonRequest(code=B.RecoveryHomepage), messages.ButtonRequest(code=B.MnemonicInput), messages.ButtonRequest(code=B.Success), messages.Success(), messages.Features(), ]) ret = device.recover(client, pin_protection=False, label="label") # Workflow successfully ended assert ret == messages.Success(message="Device recovered") assert client.features.pin_protection is False assert client.features.passphrase_protection is False
def test_set_remove_wipe_code(client): # Test set wipe code. assert client.features.wipe_code_protection is None _ensure_unlocked(client, PIN4) assert client.features.wipe_code_protection is False with client: client.set_expected_responses( [messages.ButtonRequest()] * 5 + [messages.Success(), messages.Features()]) client.use_pin_sequence([PIN4, WIPE_CODE4, WIPE_CODE4]) device.change_wipe_code(client) client.init_device() assert client.features.wipe_code_protection is True _check_wipe_code(client, PIN4, WIPE_CODE4) # Test change wipe code. with client: client.set_expected_responses( [messages.ButtonRequest()] * 5 + [messages.Success(), messages.Features()]) client.use_pin_sequence([PIN4, WIPE_CODE6, WIPE_CODE6]) device.change_wipe_code(client) client.init_device() assert client.features.wipe_code_protection is True _check_wipe_code(client, PIN4, WIPE_CODE6) # Test remove wipe code. with client: client.set_expected_responses( [messages.ButtonRequest()] * 3 + [messages.Success(), messages.Features()]) client.use_pin_sequence([PIN4]) device.change_wipe_code(client, remove=True) client.init_device() assert client.features.wipe_code_protection is False
def test_verify_long(self): self.setup_mnemonic_nopin_nopassphrase() with self.client: self.client.set_expected_responses([ proto.ButtonRequest(code=proto.ButtonRequestType.Other), proto.ButtonRequest(code=proto.ButtonRequestType.Other), proto.Success(message='Message verified') ]) self.client.lisk_verify_message( unhexlify('8bca6b65a1a877767b746ea0b3c4310d404aa113df99c1b554e1802d70185ab5'), unhexlify('458ca5896d0934866992268f7509b5e954d568b1251e20c19bd3149ee3c86ffb5a44d1c2a0abbb99a3ab4767272dbb0e419b4579e890a24919ebbbe6cc0f970f'), 'VeryLongMessage!' * 64 )
def test_expected_responses(self, client): # This is low-level test of set_expected_responses() # feature of debugging client with pytest.raises(AssertionError), client: # Scenario 1 - Received unexpected message client.set_expected_responses([]) self._some_protected_call(client, True, True, True) with pytest.raises(AssertionError), client: # Scenario 2 - Received other than expected message client.set_expected_responses([proto.Success()]) self._some_protected_call(client, True, True, True) with pytest.raises(AssertionError), client: # Scenario 3 - Not received expected message client.set_expected_responses( [proto.ButtonRequest(), proto.Success(), proto.Success()] ) # This is expected, but not received self._some_protected_call(client, True, False, False) with pytest.raises(AssertionError), client: # Scenario 4 - Received what expected client.set_expected_responses( [ proto.ButtonRequest(), proto.PinMatrixRequest(), proto.PassphraseRequest(), proto.Success(message="random data"), ] ) self._some_protected_call(client, True, True, True) with pytest.raises(AssertionError), client: # Scenario 5 - Failed message by field filter client.set_expected_responses( [proto.ButtonRequest(), proto.Success(message="wrong data")] ) self._some_protected_call(client, True, True, True)
def test_verify(self): self.setup_mnemonic_nopin_nopassphrase() with self.client: self.client.set_expected_responses([ proto.ButtonRequest(code=proto.ButtonRequestType.Other), proto.ButtonRequest(code=proto.ButtonRequestType.Other), proto.Success(message='Message verified') ]) self.client.lisk_verify_message( unhexlify('eb56d7bbb5e8ea9269405f7a8527fe126023d1db2c973cfac6f760b60ae27294'), unhexlify('7858ae7cd52ea6d4b17e800ca60144423db5560bfd618b663ffbf26ab66758563df45cbffae8463db22dc285dd94309083b8c807776085b97d05374d79867d05'), 'This is an example of a signed message.' )
def test_set_wipe_code_to_pin(client): _ensure_unlocked(client, PIN4) with client: client.set_expected_responses( [messages.ButtonRequest()] * 6 + [messages.Success(), messages.Features()]) client.use_pin_sequence([PIN4, PIN4, WIPE_CODE4, WIPE_CODE4]) device.change_wipe_code(client) client.init_device() assert client.features.wipe_code_protection is True _check_wipe_code(client, PIN4, WIPE_CODE4)
def test_verify_message(self, client): with client: client.set_expected_responses( [proto.ButtonRequest(), proto.ButtonRequest(), proto.Success()] ) btc.verify_message( client, "Bitcoin", "14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e", bytes.fromhex( "209e23edf0e4e47ff1dec27f32cd78c50e74ef018ee8a6adf35ae17c7a9b0dd96f48b493fd7dbab03efb6f439c6383c9523b3bbc5f1a7d158a6af90ab154e9be80" ), "This is an example of a signed message.", )