Skip to main content

Module taproot

Module taproot 

Source
Expand description

Taproot functions from Orange Paper Section 11.2

Structs§

TaprootControlBlock
Parsed control block from Taproot script-path witness.

Constants§

TAPROOT_LEAF_VERSION_TAPSCRIPT
BIP 341 default tapscript leaf version.
TAPROOT_SCRIPT_PREFIX
Taproot output script: OP_1 <32-byte-hash>

Functions§

compute_script_merkle_root
Compute merkle root for script path using BIP 341 TapLeaf/TapBranch tagged hashes.
compute_taproot_signature_hash
Compute Taproot signature hash following BIP 341 specification. Uses TaggedHash(“TapSighash”, 0x00 || SigMsg(…)) per BIP 341.
compute_taproot_tweak
Compute Taproot tweak using proper cryptographic operations OutputKey = InternalPubKey + TaprootTweak(MerkleRoot) × G
compute_tapscript_signature_hash
Compute Tapscript signature hash per BIP 342. Same base SigMsg as key-path, with ext = codesep_pos (4) || key_version (1) || tapleaf_hash (32).
extract_taproot_output_key
Extract Taproot output key from script
is_taproot_output
Check if transaction output is Taproot
parse_taproot_script_path_witness
Parse and validate Taproot script-path witness. Returns (tapscript, stack_items) if valid, Err otherwise. Witness format: [stack_items…, script, annex?, control_block] Annex: optional, last element before control block, must start with 0x50. Control block: leaf_version (1) + internal_pubkey (32) + merkle_proof (32*n).
validate_taproot_key_aggregation
Validate Taproot key aggregation
validate_taproot_script
Validate Taproot output script
validate_taproot_script_path
Validate Taproot script path spending
validate_taproot_script_path_with_leaf_version
Validate Taproot script path spending with explicit leaf version.
validate_taproot_transaction
Validate Taproot transaction

Type Aliases§

Witness
Witness Data: 𝒲 = 𝕊* (stack of witness elements)