2

BIP341 uses a function named compact_size in two instances: when constructing the tapleaf hash, it takes as input the size of the spending script, and when constructing the signature message, if the annex is present, it takes as input the size of the annex.

However, unlike other functions in the document which are mostly defined in BIP340, I can't find the definition for this one in either of them, so what is it?

1 Answer 1

4

It refers to the CompactSize encoding frequently used in the Bitcoin P2P protocol for integers (in particular, lengths of vectors). It's also called VarInt in some other protocol descriptions. Since it predates the BIP process (was part of the original 2009 Bitcoin protocol), it is not described in any BIP.

It encodes integers between 0 and 252 as a single byte, though bigger integers as 3, 5, or 9 bytes.

It is not in BIP340 because it has nothing to do with the digital signature scheme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.