From 3d243d8a49cefd16d628b85cc3ef0f54bd71f107 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Fri, 12 Aug 2022 08:24:30 +0000 Subject: BIP 341: allow taproot_sign_key with no script tree In contrast to taproot_output_script, taproot_sign_key was not able to deal with a script_tree that is None. This commit fixes taproot_sign_key such that it can sign for such outputs. This commit avoids changing the behavior of the functions except taproot_sign_key at the cost of having some code duplication. Alternatively, one could let taproot_tree_helper deal with a None script_tree directly. --- bip-0341.mediawiki | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bip-0341.mediawiki') diff --git a/bip-0341.mediawiki b/bip-0341.mediawiki index 9bc8723..8d2af3c 100644 --- a/bip-0341.mediawiki +++ b/bip-0341.mediawiki @@ -249,7 +249,10 @@ TapTweak = tagged_hash("TapTweak", p + ABCDE) def taproot_sign_key(script_tree, internal_seckey, hash_type, bip340_aux_rand): - _, h = taproot_tree_helper(script_tree) + if script_tree is None: + h = bytes() + else: + _, h = taproot_tree_helper(script_tree) output_seckey = taproot_tweak_seckey(internal_seckey, h) sig = schnorr_sign(sighash(hash_type), output_seckey, bip340_aux_rand) if hash_type != 0: -- cgit v1.2.3