Skip to content

Commit 3d243d8

Browse files
committed
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.
1 parent 79bb53d commit 3d243d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

bip-0341.mediawiki

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ TapTweak = tagged_hash("TapTweak", p + ABCDE)
249249

250250
<source lang="python">
251251
def taproot_sign_key(script_tree, internal_seckey, hash_type, bip340_aux_rand):
252-
_, h = taproot_tree_helper(script_tree)
252+
if script_tree is None:
253+
h = bytes()
254+
else:
255+
_, h = taproot_tree_helper(script_tree)
253256
output_seckey = taproot_tweak_seckey(internal_seckey, h)
254257
sig = schnorr_sign(sighash(hash_type), output_seckey, bip340_aux_rand)
255258
if hash_type != 0:

0 commit comments

Comments
 (0)