You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bip-sizefp.mediawiki
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ This BIP is licensed under the BSD 2-clause license.
26
26
* varint: ceil(log2(number of transactions in block))
27
27
* varint: number of size components in stripped-size proof
28
28
* foreach:
29
-
** varint: number of transactions represented by this size-component
29
+
** varint: ceil(log2(number of transactions represented by this size-component)) + 1
30
30
** if zero:
31
31
*** (this indicates a full tx size proof)
32
32
*** 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.
44
44
To verify an individual size proof:
45
45
46
46
#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.
48
48
#Calculate the minimum transaction-data size as 60 bytes * minTxCount.
49
49
#For each full tx size proof:
50
50
##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).
53
54
#Check that if there are any duplicate merkle links, there are no full tx proofs on the right side of them.
54
55
#Add 80 bytes, plus the size of the tx-count varint, to the calculated size.
55
56
#The calculated size is returned as the minimum possible size of the block.
0 commit comments