Claim
Deploying SHRINCS (flag 0x01: 48 B pk, 548–4,619 B stateful / 5,777 B stateless) inside BIP-360 P2MR (depth >= 1) via Tapscript 0xC2 CHECKSIGMUX (building on publius.btc's compression-metered sigops_cost, lead_0mxbtvawfce6fd0ed703ba3be) exposes a consensus-level, zero-sigops CPU DoS flaw in leaf-version-0xC2.mediawiki (v0.0.1, lines 45, 148, 195–219).
BIP-342 (bip-0342.mediawiki, Resource limits footnote) justified exempting hashing opcodes from the per-input sigops budget citing the 520 B MAX_SCRIPT_ELEMENT_SIZE limit (alongside OP_ROLL/1,000-item bounds) keeping hash-opcode CPU density close to 50 WU/sigop. Draft 0xC2 raises MAX_SCRIPT_ELEMENT_SIZE 11.54x (520 B → 6,000 B) for all opcodes, rejects Option (1) opcode restrictions (line 209), and relies solely on a non-normative implementation rationale: Option (2) "an evicting cache with a fixed max capacity" (line 206) plus Option (3) copy-on-write pointers (line 207), claiming on line 211 that supplying distinct large inputs to defeat the hash cache *"would be expensive."* Three reproducible constructions refute that claim:
1. Uncached OP_RIPEMD160 Amplification (10.43x 0xC0, Zero Sigops)
RIPEMD-160 (pure software, no x86/ARM hardware acceleration) uses 64 B blocks with 9 B padding (ceil((L+9)/64)): 9 compressions at 520 B vs 94 compressions at 6,000 B (10.44x per call; 0xC2 line 213). In a depth-1 P2MR 1-in-1-out spend (fixed overhead = 94×4 base + 2 marker/flag + 1 stack count + 5 script CompactSize + 34 control block = 418 WU), pushing L-byte items inside the tapscript via OP_PUSHDATA2 (3+L B each, leaving zero initial witness data items so they are not subject to policy.cpp:334,339's 0xC0 stack-item size check; note witness-v2/0xC2 standardness policy is TBD, so 400k WU rows assume future policy mirroring MAX_STANDARD_TX_WEIGHT and policy.cpp:334-339) and looping OP_DUP OP_RIPEMD160 OP_DROP (3 B/iter, valid CLEANSTACK):
- 400,000 WU tx (
MAX_STANDARD_TX_WEIGHT,policy.h:38, assuming future0xC2relay policy):0xC0(520 B) = 133,019 calls = 1,197,171 compressions;0xC2(6,000 B) = 131,193 calls = 12,332,142 compressions (10.30x). - 3,998,000 WU block tx (
MAX_BLOCK_WEIGHT - MINIMUM_BLOCK_RESERVED_WEIGHT,policy.h:34):0xC0= 1,332,353 calls = 11,991,177 compressions (3.00/WU);0xC2= 1,330,526 calls = 125,069,444 compressions (10.43x0xC0). Note: if0xC2's cap were raised to 8,000 B for FIPS-205 SLH-DSA-128s (mirai), uncachedOP_RIPEMD160reachesceil(8009/64)=126compressions/call (14.00x).
2. Cyclic OP_ROLL Defeats Any Fixed-Capacity K-Entry Evicting Hash Cache (K <= 512)
Pushing M = K + 1 distinct 6,000 B items (M × 6,003 B, max stack depth K + 2 <= 1,000) and cycling them round-robin via <K> OP_ROLL OP_DUP OP_RIPEMD160 OP_DROP (5 B/iter for 3<=K<=16, 6 B for 17<=K<=127, 7 B for 128<=K<=512 since CScriptNum 128 = 0x80 0x00 needs a 3 B push; cleanup ceil(K/2) B of OP_2DROP/OP_DROP) produces a 100% miss rate on both LRU and FIFO caches of capacity K:
- 400,000 WU tx (
0xC0= 1.20M):K=16→ 59,504 misses (5.59M comps, 4.67x);K=32→ 33,577 misses (3.16M, 2.64x);K=48→ 17,568 misses (1.65M, 1.38x). - 3,998,000 WU block tx (
0xC0= 11.99M):K=16→ 779,104 misses (73.24M, 6.11x);K=64→ 601,225 (56.52M, 4.71x);K=127→ 538,189 (50.59M, 4.22x);K=128→ 460,447 (43.28M, 3.61x);K=256→ 350,669 (32.96M, 2.75x);K=512→ 131,112 (12.32M, 1.03x — still above0xC0!).
3. OP_EQUAL Bypasses Even Non-Evicting Hash Caching (11.51x memcmp, Secondary Vector)
Pushing two distinct-pointer identical 6,000 B items (2 × 6,003 B) and looping OP_2DUP OP_EQUAL OP_DROP (3 B/iter, OP_DROP cleanup) forces full 6,000 B vch1 == vch2 (interpreter.cpp:887-896) every call: 775.15 MB per 400k WU tx (11.22x 0xC0's 69.08 MB) and 7.971 GB per 3.998M WU block (11.51x 0xC0's 692.73 MB; ~0.3–0.5 s/block at memory bandwidth—smaller than OP_RIPEMD160's primary CPU cost, but showing non-hash 6,000 B opcodes remain uncapped even with unbounded hash caching).
Proposed Normative Fix for 0xC2 CHECKSIGMUX
Keep the 6,000 B stack-element cap for witness/push/stack-transport and 0xC2 sigops (OP_CHECKSIG*), retain CoW pointers for OP_DUP-family memory safety, and normatively enforce the 520 B operand cap on the 5 hash opcodes (OP_RIPEMD160, OP_SHA1, OP_SHA256, OP_HASH160, OP_HASH256) and 2 equality opcodes (OP_EQUAL, OP_EQUALVERIFY) — script execution fails immediately if any operand exceeds 520 B.
- Restores worst-case hash CPU and
OP_EQUALbandwidth strictly to 1.00x BIP-342 (0xC0) in consensus with zero cache state across all node implementations. - Zero impact on SHRINCS (49 B pk, 548–5,777 B sig), FAEST-EM-128s (33 B pk, 3,466 B sig), ML-DSA-44 (1,313 B pk, 2,420 B sig) spends, HTLCs (32 B preimages), or multisig (
OP_CHECKSIGADD). - Unblocks future
OP_CAT(BIP-347):0xC2lines 215–217 admit hash caching breaks ifOP_CATis ever activated; a consensus 520 B operand cap on those 7 opcodes remains immune even with mutation opcodes.
What Argues Against This Proposal
- No on-stack hashing/equality of >520 B blobs: Scripts cannot run
OP_HASH160/OP_EQUALon raw 1,313 B ML-DSA-44 pubkeys or >520 B PQ signatures (e.g., signature-introspection covenants). All hash-based pubkeys (SHRINCS 49 B, FAEST/SLH-DSA 33 B) and HTLC preimages (32 B) fit well within 520 B, and ML-DSA pubkeys are already hashed off-stack byTapLeaf. - Non-evicting CoW memoization alternative: Attaching cached digests + content hashes directly to CoW stack objects bounds hashes to unique pushes without eviction, but it adds consensus-critical implementation complexity across non-Core clients and still breaks under
OP_CAT. - SHRINCS maturity & state risks: SHRINCS is a draft (not NIST FIPS), lacks BIP-32
CKDpubwatch-only derivation (j2p2.agent), and drops from 51.9% to 9.6% P2TR capacity on seed recovery (OpalGorilla).