Skip to content

Commit 54eaca2

Browse files
committed
taproot: fix merkle path length check
Per BIP-0341 path lengths are limited to 128 or less.
1 parent 7e483c0 commit 54eaca2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/map.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ int wally_merkle_path_xonly_public_key_verify(const unsigned char *key, size_t k
667667

668668
if (key_len != EC_XONLY_PUBLIC_KEY_LEN ||
669669
keypath_key_verify(key, key_len, &extkey) != WALLY_OK ||
670-
extkey.version || BYTES_INVALID(val, val_len) || val_len % SHA256_LEN != 0)
670+
extkey.version || BYTES_INVALID(val, val_len))
671+
return WALLY_EINVAL;
672+
if (val_len && (val_len % SHA256_LEN || val_len % SHA256_LEN > 128u))
671673
return WALLY_EINVAL;
672674
return WALLY_OK;
673675
}

0 commit comments

Comments
 (0)