Skip to content

Commit ab70580

Browse files
committed
bip-sizefp: Minor tweaks
1 parent 50965e7 commit ab70580

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bip-sizefp.mediawiki

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ This BIP is licensed under the BSD 2-clause license.
2626
* varint: ceil(log2(number of transactions in block))
2727
* varint: number of size components in stripped-size proof
2828
* foreach:
29-
** varint: number of transactions represented by this size-component
29+
** varint: ceil(log2(number of transactions represented by this size-component)) + 1
3030
** if zero:
3131
*** (this indicates a full tx size proof)
3232
*** 256-bit: SHA2 midstate up until just before the final SHA2 chunk
@@ -44,12 +44,13 @@ This BIP is licensed under the BSD 2-clause license.
4444
To verify an individual size proof:
4545

4646
#Check that at least one size component is a full tx size proof. (At least one size component MUST be a full tx size proof.)
47-
#Determine the minimum number of transactions in the block (minTxCount). It is either <code>pow(ceil(log2(txcount)) - 1, 2)</code>, or the position of the last full tx proof (minus one, if using 0-based positions).
47+
#Determine the minimum number of transactions in the block (minTxCount). It is either <code>pow(ceil(log2(txcount)) - 1, 2)</code>, or the position of the last full tx proof (plus one, if using 0-based positions). Note that the last full tx proof from *either* of the size proofs (stripped-size and full-size) should be used here.
4848
#Calculate the minimum transaction-data size as 60 bytes * minTxCount.
4949
#For each full tx size proof:
5050
##Subtract the minimal 60 bytes it is presumed to consume, and add the claimed total size of tx.
51-
##Take the SHA2 midstate, and update it with the final SHA2 chunk (which needs to be padded, including with the total tx size). The final SHA2 hash is the transaction id.
52-
#Build the merkle root, and compare it to the block header.
51+
##Take the SHA2 midstate, and update it with the final SHA2 chunk (which needs to be padded, including with the total tx size). The final SHA2 hash is the transaction id (stripped-size proof) or hash (full-size proof).
52+
#For the full-size proof, replace the 60 byte default with any larger sizes proven from the stripped-size proof.
53+
#Build the merkle root, and compare it to the block header (stripped-size proof) or witness commitment (full-size proof).
5354
#Check that if there are any duplicate merkle links, there are no full tx proofs on the right side of them.
5455
#Add 80 bytes, plus the size of the tx-count varint, to the calculated size.
5556
#The calculated size is returned as the minimum possible size of the block.

0 commit comments

Comments
 (0)