Skip to content

Commit

Permalink
Add test with unspendable taproot keypath during wallet registration
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed Apr 4, 2024
1 parent 63b9884 commit ec557ac
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions tests/test_register_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def run_register_test(navigator: Navigator, client: RaggerClient, speculos_globa
assert wallet_policy_id == wallet_policy.id

assert hmac.compare_digest(
hmac.new(speculos_globals.wallet_registration_key, wallet_policy_id, sha256).digest(),
hmac.new(speculos_globals.wallet_registration_key,
wallet_policy_id, sha256).digest(),
wallet_hmac,
)

Expand Down Expand Up @@ -105,7 +106,8 @@ def test_register_wallet_reject_header(navigator: Navigator, firmware: Firmware,

with pytest.raises(ExceptionRAPDU) as e:
client.register_wallet(wallet, navigator,
instructions=register_wallet_instruction_reject(firmware),
instructions=register_wallet_instruction_reject(
firmware),
testname=test_name)

assert DeviceException.exc.get(e.value.status) == DenyError
Expand Down Expand Up @@ -224,7 +226,8 @@ def test_register_miniscript_long_policy(navigator: Navigator, firmware: Firmwar
assert wallet_id == wallet.id

assert hmac.compare_digest(
hmac.new(speculos_globals.wallet_registration_key, wallet_id, sha256).digest(),
hmac.new(speculos_globals.wallet_registration_key,
wallet_id, sha256).digest(),
wallet_hmac,
)

Expand Down Expand Up @@ -381,6 +384,25 @@ def test_register_wallet_tr_script_pk(navigator: Navigator, firmware: Firmware,
test_name=test_name)


def test_register_wallet_tr_with_nums_keypath(navigator: Navigator, firmware: Firmware, client:
RaggerClient, test_name: str, speculos_globals):
# The taproot keypath is unspendable; the UX must explicitly mark it as a 'dummy' key.
# The tpub for @0 is obtained by using the NUMS (Nothing-Up-My-Sleeve) key defined in BIP-0341,
# and using 32 zero bytes as the chaincode.
# It is important that the app can detect and clearly communicate to the user that the key is
# a dummy one, therefore unusable for spending.
run_register_test(navigator, client, speculos_globals, WalletPolicy(
name="Taproot unspendable keypath",
descriptor_template="tr(@0/**,pk(@1/**))",
keys_info=[
"tpubD6NzVbkrYhZ4WLczPJWReQycCJdd6YVWXubbVUFnJ5KgU5MDQrD998ZJLSmaB7GVcCnJSDWprxmrGkJ6SvgQC6QAffVpqSvonXmeizXcrkN",
"[f5acc2fd/48'/1'/0'/2']tpubDFAqEGNyad35aBCKUAXbQGDjdVhNueno5ZZVEn3sQbW5ci457gLR7HyTmHBg93oourBssgUxuWz1jX5uhc1qaqFo9VsybY1J5FuedLfm4dK",
],
),
instructions=register_wallet_instruction_approve(firmware),
test_name=test_name)


def test_register_wallet_tr_script_sortedmulti(navigator: Navigator, firmware: Firmware, client:
RaggerClient, test_name: str, speculos_globals):
run_register_test(navigator, client, speculos_globals, WalletPolicy(
Expand Down

0 comments on commit ec557ac

Please sign in to comment.