|
|
|
@ -19,56 +19,25 @@ import pytest
|
|
|
|
|
|
|
|
|
|
from trezorlib import device, exceptions, messages
|
|
|
|
|
|
|
|
|
|
from .common import MNEMONIC_SHAMIR_20_3of6, recovery_enter_shares
|
|
|
|
|
|
|
|
|
|
pytestmark = pytest.mark.skip_t1
|
|
|
|
|
|
|
|
|
|
SHARES_20_3of6 = [
|
|
|
|
|
"extra extend academic bishop cricket bundle tofu goat apart victim enlarge program behavior permit course armed jerky faint language modern",
|
|
|
|
|
"extra extend academic acne away best indicate impact square oasis prospect painting voting guest either argue username racism enemy eclipse",
|
|
|
|
|
"extra extend academic arcade born dive legal hush gross briefing talent drug much home firefly toxic analysis idea umbrella slice",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
SHARES_33_2of5 = [
|
|
|
|
|
MNEMONIC_SHAMIR_33_2of5 = [
|
|
|
|
|
"hobo romp academic axis august founder knife legal recover alien expect emphasis loan kitchen involve teacher capture rebuild trial numb spider forward ladle lying voter typical security quantity hawk legs idle leaves gasoline",
|
|
|
|
|
"hobo romp academic agency ancestor industry argue sister scene midst graduate profile numb paid headset airport daisy flame express scene usual welcome quick silent downtown oral critical step remove says rhythm venture aunt",
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VECTORS = (
|
|
|
|
|
(SHARES_20_3of6, "491b795b80fc21ccdf466c0fbc98c8fc"),
|
|
|
|
|
(MNEMONIC_SHAMIR_20_3of6, "491b795b80fc21ccdf466c0fbc98c8fc"),
|
|
|
|
|
(
|
|
|
|
|
SHARES_33_2of5,
|
|
|
|
|
MNEMONIC_SHAMIR_33_2of5,
|
|
|
|
|
"b770e0da1363247652de97a39bdbf2463be087848d709ecbf28e84508e31202a",
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def enter_all_shares(debug, shares):
|
|
|
|
|
word_count = len(shares[0].split(" "))
|
|
|
|
|
|
|
|
|
|
# Homescreen - proceed to word number selection
|
|
|
|
|
yield
|
|
|
|
|
debug.press_yes()
|
|
|
|
|
# Input word number
|
|
|
|
|
code = yield
|
|
|
|
|
assert code == messages.ButtonRequestType.MnemonicWordCount
|
|
|
|
|
debug.input(str(word_count))
|
|
|
|
|
# Homescreen - proceed to share entry
|
|
|
|
|
yield
|
|
|
|
|
debug.press_yes()
|
|
|
|
|
# Enter shares
|
|
|
|
|
for share in shares:
|
|
|
|
|
code = yield
|
|
|
|
|
assert code == messages.ButtonRequestType.MnemonicInput
|
|
|
|
|
# Enter mnemonic words
|
|
|
|
|
for word in share.split(" "):
|
|
|
|
|
debug.input(word)
|
|
|
|
|
|
|
|
|
|
# Homescreen - continue
|
|
|
|
|
# or Homescreen - confirm success
|
|
|
|
|
yield
|
|
|
|
|
debug.press_yes()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.setup_client(uninitialized=True)
|
|
|
|
|
@pytest.mark.parametrize("shares, secret", VECTORS)
|
|
|
|
|
def test_secret(client, shares, secret):
|
|
|
|
@ -78,7 +47,7 @@ def test_secret(client, shares, secret):
|
|
|
|
|
yield # Confirm Recovery
|
|
|
|
|
debug.press_yes()
|
|
|
|
|
# run recovery flow
|
|
|
|
|
yield from enter_all_shares(debug, shares)
|
|
|
|
|
yield from recovery_enter_shares(debug, shares)
|
|
|
|
|
|
|
|
|
|
with client:
|
|
|
|
|
client.set_input_flow(input_flow)
|
|
|
|
@ -105,7 +74,7 @@ def test_recover_with_pin_passphrase(client):
|
|
|
|
|
yield # Enter PIN again
|
|
|
|
|
debug.input("654")
|
|
|
|
|
# Proceed with recovery
|
|
|
|
|
yield from enter_all_shares(debug, SHARES_20_3of6)
|
|
|
|
|
yield from recovery_enter_shares(debug, MNEMONIC_SHAMIR_20_3of6)
|
|
|
|
|
|
|
|
|
|
with client:
|
|
|
|
|
client.set_input_flow(input_flow)
|
|
|
|
@ -150,7 +119,7 @@ def test_noabort(client):
|
|
|
|
|
debug.press_no()
|
|
|
|
|
yield # Homescreen - go back to process
|
|
|
|
|
debug.press_no()
|
|
|
|
|
yield from enter_all_shares(debug, SHARES_20_3of6)
|
|
|
|
|
yield from recovery_enter_shares(debug, MNEMONIC_SHAMIR_20_3of6)
|
|
|
|
|
|
|
|
|
|
with client:
|
|
|
|
|
client.set_input_flow(input_flow)
|
|
|
|
@ -163,7 +132,7 @@ def test_noabort(client):
|
|
|
|
|
@pytest.mark.parametrize("nth_word", range(3))
|
|
|
|
|
def test_wrong_nth_word(client, nth_word):
|
|
|
|
|
debug = client.debug
|
|
|
|
|
share = SHARES_20_3of6[0].split(" ")
|
|
|
|
|
share = MNEMONIC_SHAMIR_20_3of6[0].split(" ")
|
|
|
|
|
|
|
|
|
|
def input_flow():
|
|
|
|
|
yield # Confirm Recovery
|
|
|
|
@ -202,9 +171,9 @@ def test_wrong_nth_word(client, nth_word):
|
|
|
|
|
@pytest.mark.setup_client(uninitialized=True)
|
|
|
|
|
def test_same_share(client):
|
|
|
|
|
debug = client.debug
|
|
|
|
|
first_share = SHARES_20_3of6[0].split(" ")
|
|
|
|
|
first_share = MNEMONIC_SHAMIR_20_3of6[0].split(" ")
|
|
|
|
|
# second share is first 4 words of first
|
|
|
|
|
second_share = SHARES_20_3of6[0].split(" ")[:4]
|
|
|
|
|
second_share = MNEMONIC_SHAMIR_20_3of6[0].split(" ")[:4]
|
|
|
|
|
|
|
|
|
|
def input_flow():
|
|
|
|
|
yield # Confirm Recovery
|
|
|
|
|