I am trying to follow BIP341 to understand the signature hash calculation for taproot script path spends.
From the bitcoin testing framework code, I see that if the transaction is spending from a script path (as opposed to a key path spend), the sighash needs these additional bytes appended.
if (scriptpath):
ss += TaggedHash("TapLeaf", bytes([leaf_ver]) + ser_string(script))
ss += bytes([0])
ss += struct.pack("<i", codeseparator_pos)
Where are these bytes described in the BIP?
And in case it's not clear from the BIP, what is the purpose for the last two lines: 0x00
and struct.pack("<i", codeseparator_pos)
?