From fcaa3343e2787467a9713c2f5c8659dd54cedf54 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 16 Sep 2024 15:46:15 +0200 Subject: [PATCH] fix: taproot multisig --- core/.changelog.d/4159.added | 1 + core/mocks/generated/trezorcrypto/bip340.pyi | 3 ++- core/src/apps/bitcoin/sign_tx/bitcoin.py | 1 + core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 core/.changelog.d/4159.added diff --git a/core/.changelog.d/4159.added b/core/.changelog.d/4159.added new file mode 100644 index 0000000000..ad9e535615 --- /dev/null +++ b/core/.changelog.d/4159.added @@ -0,0 +1 @@ +Taproot Multisig send and spend diff --git a/core/mocks/generated/trezorcrypto/bip340.pyi b/core/mocks/generated/trezorcrypto/bip340.pyi index 855cb20029..e401f81ecb 100644 --- a/core/mocks/generated/trezorcrypto/bip340.pyi +++ b/core/mocks/generated/trezorcrypto/bip340.pyi @@ -45,9 +45,10 @@ def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool: def tweak_public_key( public_key: bytes, root_hash: bytes | None = None, -) -> bytes: +) -> tuple[int, bytes]: """ Tweaks the public key with the specified root_hash. + First element of tuple is the parity, second is the tweaked public key. """ diff --git a/core/src/apps/bitcoin/sign_tx/bitcoin.py b/core/src/apps/bitcoin/sign_tx/bitcoin.py index cc1e9d3946..7ce448066c 100644 --- a/core/src/apps/bitcoin/sign_tx/bitcoin.py +++ b/core/src/apps/bitcoin/sign_tx/bitcoin.py @@ -551,6 +551,7 @@ class Bitcoin: i, tx_info.tx, self.get_sighash_type(txi), + None, ) else: return tx_info.sig_hasher.hash143( diff --git a/core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py b/core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py index e234069aaf..13560b51f4 100644 --- a/core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py +++ b/core/tests/test_apps.bitcoin.segwit.bip341.p2tr.py @@ -278,7 +278,7 @@ class TestSegwitBip341P2TR(unittest.TestCase): for sh in tx["signature_hashes"]: txi = tx["inputs"][sh["index"]] - result = hasher.hash341(sh["index"], tx["sign_tx"], sh["hash_type"]) + result = hasher.hash341(sh["index"], tx["sign_tx"], sh["hash_type"], None) self.assertEqual( result, sh["result"], f"signature_hash tx {i} input {sh['index']}" )