bip360: correct the claimed P2MR witness size saving #2223

pull jeanpablojp wants to merge 1 commits into bitcoin:master from jeanpablojp:bip360-fix-size-claim changing 1 files +1 −1
  1. jeanpablojp commented at 2:23 PM on July 28, 2026: contributor

    In Transaction Size and Fees, the BIP says a P2MR witness "will always be 32 bytes smaller than an equivalent P2TR script path spend witness". That holds at every depth except m = 7, where it is 34.

    The control blocks are 1 + 32m for P2MR and 33 + 32m for P2TR, and each is serialised with a compact size prefix. At m = 7 the P2TR control block is 257 bytes, which crosses the 253-byte boundary and takes a 3-byte prefix, while the P2MR one is 225 bytes and still takes 1:

    def cs(n): return 1 if n < 253 else 3
    for m in range(1, 12):
        a, b = 1 + 32*m, 33 + 32*m
        print(m, (cs(b) + b) - (cs(a) + a))
    # 1..6 -> 32, 7 -> 34, 8..11 -> 32
    

    The same section already footnotes this boundary a few paragraphs earlier, for the P2MR side only ("If m >= 8, then the compact size will use 3 bytes rather than 1 byte"), so the reasoning is there, it just isn't carried into the comparison.

    Noticed while measuring witness weights for a regtest implementation of the BIP.

  2. bip360: correct the claimed P2MR witness size saving
    The Transaction Size and Fees section says a P2MR witness is always 32
    bytes smaller than an equivalent P2TR script path spend witness. The
    control blocks are 1 + 32*m and 33 + 32*m bytes, each serialised with
    a compact size prefix, so at m = 7 the P2TR control block is 257 bytes
    and takes a 3-byte prefix while the P2MR one is 225 bytes and takes 1.
    The saving there is 34 bytes, not 32. Every other depth up to 128
    gives 32.
    
    The section already footnotes this boundary for the P2MR side a few
    paragraphs earlier.
    33202403b3
  3. jonatack added the label Proposed BIP modification on Jul 28, 2026
  4. jonatack added the label Pending acceptance on Jul 28, 2026
  5. cryptoquick commented at 8:41 PM on August 1, 2026: contributor

    This is a good refinement. While CompactSize can in principle use 5- or 9-byte encodings, BIP 341 caps the control block at 33 + 32 * 128 = 4,129 bytes, so we never reach the next threshold at 65,536. The only deviation from the constant 32-byte saving is therefore the single case, m = 7.

  6. jonatack removed the label Pending acceptance on Aug 3, 2026
  7. jonatack commented at 4:03 AM on August 3, 2026: member

    ACK, should be the only exception to note here.

  8. jonatack merged this on Aug 3, 2026
  9. jonatack closed this on Aug 3, 2026


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-08-20 04:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me