v1 (v3.0.0-rfc) · archived baseline · superseded
Part 2: Stage 0 Direct-on-L1 Bitcoin SPV Event Oracle & Stage 1A Bitcoin-L1-Canonical Authorization Domain
Showing word-highlighted redline changes from archived v0 (v2.5.0-rfc) to v1 (v3.0.0-rfc). For structured finding-by-finding rationale, see theChangelog.
| @@ -1,190 +1,153 @@ | |||
| 1 | - | # Part 2: Bitcoin Authorization Domain (`d_btc_asset`) & Adversarially-Bounded SPV Verifier | |
| 1 | + | # Part 2: Stage 0 Direct-on-L1 Bitcoin SPV Event Oracle & Stage 1A Bitcoin-L1-Canonical Authorization Domain | |
| 2 | 2 | ||
| 3 | - | **Document Class:** Normative Chain Specialization (`v2.5.0-rfc`, subject to Upstream Amendments `A-SPEC-1`, `A-SPEC-2`, `A-SPEC-6`, `A-BTC-1` in [`SPEC.md §6`](../SPEC.md#L110-L122)) | |
| 4 | - | **Target Domain:** `d_btc_asset` (`domainClass = AUTHORIZATION`, `purpose = ASSET`) | |
| 5 | - | **Shared Implementation Mandate:** Deterministic, panic-free Go package `vm/embedded/btcspv/` executed identically by `zenon-executor` and `SettlementContract` fraud adjudication (`OPTIMISTIC_BTC_SPV_V1`). | |
| 6 | - | **Numeric Oracle:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py). | |
| 3 | + | **Document Class:** Normative Bitcoin SPV Verification & L1 Authorization Domain Specification (`v1` / `v3.0.0-rfc` — Zero-Federation Phased Architecture; supersedes archived `v0` `v2.5.0-rfc`) | |
| 4 | + | **Philosophical Anchor:** Stage 0 implements Zenon's non-custodial verification thesis (`zenon-developer-commons`: `essays/Verify Bitcoin, Don't Bridge It.md` & `docs/specs/spv-event-oracle-spec.md`): **Event Validity only, zero custody authority**. Stage 1A moves canonical `zBTC` authorization, data availability, and forced exit directly onto **Bitcoin L1** so that `49%–100%` Zenon compromise cannot forge state or censor exits. | |
| 5 | + | **Consistency Checker:** [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py) | |
| 7 | 6 | ||
| 8 | 7 | --- | |
| 9 | 8 | ||
| 10 | - | ## 1. Domain Registration, `ChainBinding` & Parameters | |
| 9 | + | ## 1. Two-Layer Separation: Stage 0 Event Oracle vs Stage 1A Canonical L1 Domain | |
| 11 | 10 | ||
| 12 | - | > **Upstream Activation Blocker (`A-SPEC-1` / `A-SPEC-6`):** Requires Phase-2 ratification activating `inputSource = L1_RELAYED`, `input_kind` `6`/`7`, and reconciling `domainClass = AUTHORIZATION` & `finalityModel = CHALLENGE_WINDOW` / `PROOF_VERIFIED`. | |
| 11 | + | This specification strictly separates two orthogonal verification surfaces with **zero federated signers** anywhere: | |
| 13 | 12 | ||
| 14 | - | ```text | |
| 15 | - | DomainRecord { | |
| 16 | - | domainId = <assigned u32> | |
| 17 | - | domainClass = AUTHORIZATION // enum ordinal 1 (A-SPEC-6) | |
| 18 | - | runtimeKind = BTC_SPV_V2 // panic-free deterministic Go plugin | |
| 19 | - | stfSpecHash = SHA3-256(canonical(runtimeKind || chainBinding || claimPolicy || decimalsPolicy || profileConfig)) | |
| 20 | - | inputSource = L1_RELAYED // enum ordinal 1 (A-SPEC-1) | |
| 21 | - | execProfile = OPTIMISTIC // enum ordinal 1 | |
| 22 | - | foreignProfile = LIGHT_CLIENT // enum ordinal 2 | |
| 23 | - | proposerPolicy = RANDOM_BACKUP // upstream enum (0=SINGLE, 1=RANDOM_BACKUP, 2=STAKE_WEIGHTED) | |
| 24 | - | finalityModel = CHALLENGE_WINDOW // enum ordinal 1 | |
| 25 | - | status = PAUSED // 0=ACTIVE, 1=PAUSED (Shadow Mode: SubmitInput/SubmitBatch/Challenge/FinalizeBatch OPEN) | |
| 26 | - | } | |
| 13 | + | 1. **Stage 0 — Direct-on-L1 Bitcoin SPV Event Oracle (`vm/embedded/btcspv`):** | |
| 14 | + | - Runs deterministically inside an embedded Zenon contract (`BtcSpvOracleContract`), wrapped in mandatory panic recovery (`recover()`, zero `common.DealWithErr` calls — closing upstream issue `#239` / **B1**). | |
| 15 | + | - Proves **Event Validity ONLY**: cryptographic evidence that a Bitcoin transaction `txid` is included at depth `>= K_oracle` on the heaviest cumulative-PoW Bitcoin header chain. | |
| 16 | + | - **Hard Non-Custody Invariant:** Stage 0 SPV has **ZERO minting, burning, sweeping, or vault-spending authority**. It powers Bitcoin-verified receipts, proof-of-payment triggers, and non-custodial PTLC/HTLC atomic swaps (`spec/03 §1`). | |
| 17 | + | 2. **Stage 1A — Bitcoin-L1-Canonical Authorization Domain (`vk_STF` Rollup Circuit):** | |
| 18 | + | - For pooled, fungible `zBTC` (`Stage 1A`), **Zenon L1 does NOT authorize mints, burns, or exits**. | |
| 19 | + | - Instead, the immutable RISC-V / ZK Rollup State Transition Function ($\mathcal{F}$, compiled to `RV32IM` for `BitVMX-CPU` `n = 8` bisection — `spec/01`) scans **complete stripped Bitcoin blocks** directly on Bitcoin L1, deriving the entire canonical `zBTC` state root $R_h$ strictly from Bitcoin's heaviest PoW chain (`0-of-N` Zenon trust; `0%` ZNN market-cap coupling). | |
| 27 | 20 | ||
| 28 | - | ChainBinding { | |
| 29 | - | foreignChainId : ChainId // u16(0x0001) || bytes30(SHA3-256("BTC_MAINNET_V1" || btcGenesisHashBE)[0:30]) | |
| 30 | - | chainVerifierId : bytes32 // SHA3-256("BTC_SPV_VERIFIER_V2.4" || reproducibleBuildDigest) | |
| 31 | - | genesisAnchor : Bytes // BitcoinAnchor { blockHashBE, height, header(80B), cumWork, retargetStartHash, retargetStartTime, retargetHeight, mtpWindow[11] } | |
| 32 | - | releaseAdapterRef : Bytes // { CommitteeIdentityKey(32B), qGraphXOnly(32B), committeeSizeN(u16>=7), vaultTweakTag("zBTC/VaultTweak/v1"), recoveryTweakTag("zBTC/RecoveryTweak/v1"), provisionalTimeoutBlocks(u16=144), bucketDenoms(List<u64>), vkBitvmHash(32B), fixedReserveFeeSats(u64), minOperatorFeeSats(u64), maxPegOutFeeSats(u64) } | |
| 33 | - | enforcementSpecHash : bytes32 // SHA3-256(activated BTC-ENFORCEMENT-V1 bytes); MUST be non-zero | |
| 34 | - | finalityParams : Bytes // BitcoinFinalityParams below | |
| 35 | - | } | |
| 36 | - | ``` | |
| 21 | + | --- | |
| 37 | 22 | ||
| 38 | - | ### 1.1 `BitcoinFinalityParams` (Asserted in `scripts/verify_spec_bounds.py`) | |
| 23 | + | ## 2. Stage 0: Direct-on-L1 Bitcoin SPV Event Oracle (`vm/embedded/btcspv`) | |
| 39 | 24 | ||
| 25 | + | ### 2.1 `OracleChainConfig` & Finality Parameters | |
| 26 | + | ||
| 40 | 27 | ```text | |
| 41 | - | BitcoinFinalityParams := | |
| 42 | - | confirmationDepthK : u32 // Pilot: 14; K >= max(12, ceil(2 * AggregateInFlightMint_BTC / S(h))). Passes pre-2028 (12) & post-2028 (13). Pre-2032: Governance MUST migrate to K>=26 OR lower cap <= 5 BTC (K>=13<=14) | |
| 43 | - | minimumPostAnchorWork : u256 | |
| 44 | - | retainedReorgDepth : u32 // 144 blocks (stale HeaderNode pruning ONLY; ActiveChainByHeight NEVER pruned) | |
| 45 | - | maximumHeaderBatch : u32 // 2 headers/input | |
| 46 | - | maximumMerkleBranchDepth : u32 // 16 levels (65,536 txs/block) | |
| 47 | - | maximumDepositTxBytes : u32 // 4,096 B | |
| 48 | - | maximumRolloverTxBytes : u32 // 1,024 B (2-input RolloverTx) | |
| 49 | - | maximumFrontingTxBytes : u32 // 4,096 B | |
| 50 | - | maximumStreamChunkBytes : u32 // 8,192 B per streaming SHA-256 chunk (zero 3rd-party coinbase/spend caps) | |
| 51 | - | maximumProofBytes : u32 // 15,600 B (ABI <= 16,384 B) | |
| 52 | - | executionChallengeWindow : u64 // 172,800s (48h) + T_session 43,200s (12h) = 60h -> Poisson(360 * 1.10 [ASSUMED]) = 472 BTC blocks | |
| 53 | - | releaseTimeoutUnit : u8 // 0 = DEST_HEIGHT | |
| 54 | - | minTimeoutAboveFinalTip : u32 // 640 blocks | |
| 55 | - | maxTimeoutAboveFinalTip : u32 // 2,512 blocks | |
| 56 | - | releaseSubmissionGrace : u32 // 558 blocks (K(14) + 472 + 72 ≈ 93h) | |
| 57 | - | pendingTrapWindowBlocks : u32 // 230 blocks (72 escrow + K(14) + 144 margin before BTC_TRAP_TIMEOUT_HALT) | |
| 58 | - | futureTimeGuardSecs : u32 // 7,200s | |
| 59 | - | equalWorkTieBreak : u8 // 0 = LOWEST_BLOCK_HASH_BE | |
| 28 | + | OracleChainConfig { | |
| 29 | + | foreignChainId : bytes32 // u16(0x0001) || SHA3-256("BTC_MAINNET_SPV_V1" || btcGenesisHashBE)[0:30] | |
| 30 | + | genesisAnchor : Bytes // BitcoinAnchor { blockHashBE(32B), height(u64), header(80B), cumWork(u256), | |
| 31 | + | // retargetStartHash(32B), retargetStartTime(u32), retargetHeight(u64), mtpWindow[11](u32) } | |
| 32 | + | admissionDepthN : u32 // 6 blocks (provisional event admission; reversible on reorg) | |
| 33 | + | finalizationDepthK : u32 // 12 blocks (oracle event finalization depth) | |
| 34 | + | minimumPostAnchorWork : u256 // finalizationDepthK * blockWork(genesisAnchor.nBits) | |
| 35 | + | retainedReorgDepth : u32 // 144 blocks (stale HeaderNode pruning ONLY; ActiveChainByHeight NEVER pruned) | |
| 36 | + | maximumHeaderBatch : u32 // 2 headers per SubmitHeaderBatch call | |
| 37 | + | maximumMerkleDepth : u32 // 16 levels (65,536 txs/block) | |
| 38 | + | maximumStrippedTxBytes : u32 // 6,144 B (per-call Stage 0 proof cap; fits 3x inside pinned 2.1M Plasma floor) | |
| 39 | + | futureTimeGuardSecs : u32 // 7,200 s (Bitcoin consensus MAX_FUTURE_BLOCK_TIME) | |
| 40 | + | equalWorkTieBreak : u8 // 0 = LOWEST_BLOCK_HASH_BE (deterministic across all Zenon full nodes) | |
| 41 | + | } | |
| 60 | 42 | ``` | |
| 61 | 43 | ||
| 62 | - | ### 1.2 `ClaimPolicy` (`btc_asset_claim_policy_v1` — Exact 3 Capabilities) | |
| 63 | - | ||
| 64 | - | | `ClaimType` (0-based) | Name | `handlerId` | `Subject` | `Payload` | | |
| 65 | - | |---|---|---|---|---| | |
| 66 | - | | `0` | `FOREIGN_LOCK` | `SHA3-256("MINTED_LOCK_V1")` | 20B Zenon User Address (`[0]==0x00`) | 32B `ChainBindingHash ∈ RecognizedBindings` (`0x0E`) | | |
| 67 | - | | `1` | `FOREIGN_RELEASE` | `SHA3-256("MINTED_RELEASE_V1")` | 32B `outboxId` | 32B `po.ChainBindingHash ∈ RecognizedBindings` | | |
| 68 | - | | `2` | `FOREIGN_NON_DELIVERY` | `SHA3-256("MINTED_REFUND_V1")` | 32B `outboxId` | 32B `po.ChainBindingHash ∈ RecognizedBindings` | | |
| 44 | + | > **Testnet / Signet Scope Caveat:** On Bitcoin Signet (where validity rests in the Signet challenge signature) and Testnet4 (minimum-difficulty block exception), header-only PoW SPV does not resist an adversary. Stage 0 Signet SPV tests are **conformance-only**; full PoW security applies strictly on Bitcoin Mainnet. | |
| 69 | 45 | ||
| 70 | - | --- | |
| 46 | + | ### 2.2 Stage 0 Embedded ABI Methods, Exact Sizes & Pinned Plasma Floor (`B1`, `B2`) | |
| 71 | 47 | ||
| 72 | - | ## 2. Canonical Identifiers & Complete Field Definitions | |
| 48 | + | All 4 Stage 0 oracle methods are **panic-recovered (`B1`)**, require **zero federation signatures**, and stay strictly within the pinned **`MaxBasePlasmaInMomentum >= 2,100,000`** floor (`spec/05 §2.2`) and `dp.MaxContractBlocks = 40` per-Momentum contract-block cap (`origin/dev:dp/dp.go:259-264`). Base Plasma under `DynamicPlasmaSpork` equals `tier + 68 * (abiBytes - 4)` (`origin/dev:vm/plasma.go:185-200`): | |
| 73 | 49 | ||
| 74 | - | ```text | |
| 75 | - | BitcoinOutpointID = SHA3-256("BTC_OUTPOINT_V1" || canonical(foreignChainId) || rolloverTxidBE || u32BE(0)) | |
| 76 | - | BitcoinReleaseEventID = SHA3-256("BTC_RELEASE_V1" || canonical(foreignChainId) || frontingTxidBE || u32BE(paymentVout)) | |
| 77 | - | BitcoinNonDeliveryEventID = SHA3-256("NON_DELIVERY" || po.ChainBindingHash || outboxId || ActiveChainByHeight[timeoutHeight + 558].blockHashBE) | |
| 50 | + | | ABI Method | Send Plasma Tier | Exact Max Payload | Exact Max ABI (`32 B`-padded) | Exact Base Plasma (`QSR` @ floor `1,000`) | Max Storage Ops | Purpose | | |
| 51 | + | |---|---:|---:|---:|---:|---:|---| | |
| 52 | + | | `SubmitHeaderBatch(headers)` | `52,500` (Simple) | `160 B` (`2 × 80 B`) | `228 B` | `67,732` (`33 QSR`) | `<= 8` | Validate `1..2` mainnet headers, 2016-block `[302400, 4838400]`s retarget, MTP, update `ActiveChainByHeight`. | | |
| 53 | + | | `StepReorg()` | `52,500` (Simple) | `0 B` | `4 B` | `52,500` (`25 QSR`) | `<= 6` | Walk 1 incremental reorg step; emits deterministic reorg state transition if an admitted `< 12`-deep event is orphaned; flags `DeepReorgAlert = 1` if `ReorgSteps > 144`. | | |
| 54 | + | | `PruneStaleHeaders(hashes)` | `52,500` (Simple) | `64 B` (`2 × 32 B`) | `132 B` | `61,204` (`30 QSR`) | `<= 4` | Delete `1..2` stale `HeaderNode`s (`height < BestTip - 144 && height % 2016 != 0 && ReorgActive == 0`). | | |
| 55 | + | | `ProveTxInclusion(...)` | `73,500` (Heavy SPV) | `7,279 B` | `7,620 B` | `591,388` (`282 QSR`) | `<= 8` | Verify `>= N`-deep `strippedTx` (`<= 6,144 B`) + 1-/2-block coinbase midstate + Merkle inclusion → record `VerifiedEvent[txid]`. | | |
| 78 | 56 | ||
| 79 | - | BitcoinLockFinalityRef := | |
| 80 | - | rolloverBlockHashBE : bytes32 | |
| 81 | - | rolloverBlockHeight : u64 | |
| 82 | - | rolloverTxIndex : u32 | |
| 83 | - | rolloverOutpoint : bytes36 // rolloverTxidBE(32B) || u32BE(0) | |
| 84 | - | eligibleOperatorsBitmask : u64 // authenticated by CommitteeIdentityKey BIP-340 sig | |
| 85 | - | roundChainEpochId : u16 // < 4096 (R5-L9) | |
| 86 | - | takeTxidsSmtRoot : bytes32 // proof-format.md V1 SMT root of sorted released Take1/Take2 txids (R5-M1!) | |
| 87 | - | bestTipHashBE : bytes32 | |
| 88 | - | bestTipHeight : u64 | |
| 89 | - | bestTipChainWork : u256 | |
| 90 | - | ``` | |
| 57 | + | *Exact `ProveTxInclusion` ABI Derivation (Full `32 B`-Padded Accounting):* | |
| 58 | + | - Static head: `4 B` selector + `8 × 32 B` (`blockHeight`, `txIndex`, `totalCoinbaseBytes`, `sha256Midstate`, + 4 dynamic offsets) `= 260 B`. | |
| 59 | + | - Dynamic bodies (`32 B` length prefix + `32 B`-padded bytes): `strippedTx` (`32 + 6,144 = 6,176 B`) + `txBranch` (`32 + 16 × 32 = 544 B`) + `coinbaseTail` (`32 + 64 = 96 B` for `<= 63 B` tail) + `coinbaseBranch` (`32 + 16 × 32 = 544 B`) `= 7,360 B`. | |
| 60 | + | - Total ABI `= 260 + 7,360 = 7,620 B <= 16,384 B` (`MaxDataLength`). Base Plasma `= 73,500 + 68 × (7,620 - 4) = 591,388`. Up to **`3`** max-size `ProveTxInclusion` calls (`1,774,164 <= 2,100,000`) fit inside a single Momentum even at the pinned floor (`6` at default `4,200,000`). | |
| 91 | 61 | ||
| 92 | - | --- | |
| 62 | + | ### 2.3 Exact 1- and 2-Block Coinbase Midstate Proof (`CVE-2017-12842`) | |
| 93 | 63 | ||
| 94 | - | ## 3. Canonical Domain Inputs (17 Tags — Zero 3rd-Party Size Caps!) | |
| 64 | + | Every `ProveTxInclusion` call MUST verify: | |
| 65 | + | 1. `ChainMeta.ReorgActive == 0` and `ChainMeta.PostAnchorWork >= minimumPostAnchorWork`. | |
| 66 | + | 2. `ActiveChainByHeight[blockHeight]` exists and `BestTipHeight >= blockHeight + admissionDepthN - 1`. | |
| 67 | + | 3. `len(strippedTx) <= 6,144`, `len(strippedTx) != 64` (**CVE-2017-12842**), `txIndex != 0`, and no SegWit marker (`0x00 0x01`) in stripped bytes. | |
| 68 | + | 4. `doubleSHA256(strippedTx)` verifies against `merkleRootLE` via `txBranch` at `txIndex` with `len(txBranch) == len(coinbaseBranch) <= 16` and zero duplicate-sibling **CVE-2012-2459** padding. | |
| 69 | + | 5. **1- and 2-Block SHA-256 Coinbase Midstate Verification:** | |
| 70 | + | - Caller supplies `(sha256Midstate: bytes32, finalChunkTail: bytes, totalCoinbaseBytes: u32, coinbaseBranch: bytes32[])`. | |
| 71 | + | - **Normative Constraints:** | |
| 72 | + | - `totalCoinbaseBytes >= 65` (rejects `totalCoinbaseBytes == 64` leaf forgery and impossibly short transactions). | |
| 73 | + | - **`len(finalChunkTail) == totalCoinbaseBytes % 64`** (strictly `< 64`; rejects any mismatched or unaligned tail!). | |
| 74 | + | - **Exact Final SHA-256 Padding (`100%` of valid Bitcoin coinbase lengths, avoiding the `12.5%` single-compression rejection bug when `rem ∈ [56, 63]`):** | |
| 75 | + | Let `rem = totalCoinbaseBytes % 64` and `bitLen = u64BE(uint64(totalCoinbaseBytes) * 8)`: | |
| 76 | + | - **Case 1 (`rem < 56` — 1-block final padding):** Build single `64 B` block `B_1 = finalChunkTail[0:rem] || 0x80 || 0x00^(55 - rem) || bitLen(8B)`. Compute `innerHash = SHA256_Compress(sha256Midstate, B_1)`. | |
| 77 | + | - **Case 2 (`56 <= rem <= 63` — 2-block final padding):** Build `B_1 = finalChunkTail[0:rem] || 0x80 || 0x00^(63 - rem)` and `B_2 = 0x00^56 || bitLen(8B)`. Compute `state_1 = SHA256_Compress(sha256Midstate, B_1)`, then `innerHash = SHA256_Compress(state_1, B_2)`. | |
| 78 | + | - Compute `coinbaseTxid = SHA256(innerHash)` and verify `coinbaseBranch` at index `0` against `merkleRootLE` with `len(coinbaseBranch) == len(txBranch)`. | |
| 79 | + | - *Explicit Auditability Disclosure:* A midstate proof proves that Merkle index `0` is a valid non-64-byte leaf at the same tree depth as `txIndex` (completely closing CVE-2017-12842 interior-node forgery); it does **not** parse the prefix of the coinbase transaction itself. In Stage 1A below, full coinbase bytes are directly verified inside the stripped-block scanner to extract the BIP-141 witness commitment. | |
| 95 | 80 | ||
| 96 | - | | Tag | Name | Source | Max Payload | Max ABI | Typical 1-Tx Fast Challenge ABI (`sib=26`) | Worst-Case Depth-256 (`Multi-Tx`) | | |
| 97 | - | |---|---|---|---:|---:|---:|---:| | |
| 98 | - | | `0x00` | `BTC_HEADER_BATCH` (`1..2` headers) | `SubmitInput` | `197 B` | `324 B` | `7,140 B` | `8,676 B` / proof | | |
| 99 | - | | `0x01` | `BTC_REORG_STEP` (1 step) | `SubmitInput` | `1 B` | `132 B` | `6,340 B` | `8,676 B` / proof | | |
| 100 | - | | `0x02` | `BTC_PRUNE_STEP` (`1..2` stale `HeaderNode`s) | `SubmitInput` | `65 B` | `196 B` | `4,388 B` | `8,676 B` / proof | | |
| 101 | - | | `0x03` | `PEGOUT_CREATED` (`input_kind = 7`) | `RequestPegOut` | `190 B` | *(internal)* | `3,108 B` | `8,676 B` / proof | | |
| 102 | - | | `0x04` | `BTC_TX_STREAM_CHUNK` (`<= 8 KiB` SHA-256 chunk) | `SubmitInput` | `8,234 B` | `8,356 B` | `3,300 B` | `8,676 B` / proof | | |
| 103 | - | | `0x05` | `BTC_LOCK_PROOF` (`Dep` + 2-in `Rol` + 2 streams + `CommSig` + `takeSmtRoot` + `takeBlobHash`) | `SubmitInput` | `7,633 B` | `7,748 B` | `10,180 B` | `8,676 B` / proof | | |
| 104 | - | | `0x06` | `BTC_RELEASE_PROOF` (`Fronting` + stream; decoupled from vault trap — **R6-M3**) | `SubmitInput` | `5,242 B` | `5,348 B` | `10,212 B` | `8,676 B` / proof | | |
| 105 | - | | `0x07` | `BTC_NON_DELIVERY_PROOF` (`outboxId`) | `SubmitInput` | `33 B` | `164 B` | `6,212 B` | `8,676 B` / proof | | |
| 106 | - | | `0x08` | `BTC_VAULT_SPEND_PROOF` (SMT absence/inclusion across `ACTIVE`/`RELEASED`/`QUARANTINED` — **R6-L5**) | `SubmitInput` | `2,142 B` | `2,244 B` | `7,396 B` | `8,676 B` / proof | | |
| 107 | - | | `0x09` | `BTC_OPERATOR_SLASH_PROOF` (streamed `BondOut` burn) | `SubmitInput` | `1,183 B` | `1,284 B` | `8,292 B` | `8,676 B` / proof | | |
| 108 | - | | `0x0A` | `PEGOUT_SLOT_CLAIMED` (`kind=7`, single-authority + anti-censorship — **R6-M4/M5**) | `ClaimFrontingSlot` | `48 B` | *(internal)* | `3,300 B` | `8,676 B` / proof | | |
| 109 | - | | `0x0B` | `OPERATOR_ROUND_REGISTERED` (`CommSig` + exact epoch expiry equality — **R6-L6**) | `RegisterOperatorRound` | `125 B` | `228 B` | `3,108 B` | `8,676 B` / proof | | |
| 110 | - | | `0x0C` | `BTC_VAULT_RECOVERY_PROOF` (`T1\|T2` → `QUARANTINED`, 10 keys incl. inserts — **S6-5**) | `SubmitInput` | `1,219 B` | `1,348 B` | `11,300 B` | `8,676 B` / proof | | |
| 111 | - | | `0x0D` | **`VAULT_GRAPH_EPOCH_ADDED`** (`u16` epoch + `takeBlobHash` + `CommSig`, `ACTIVE`/`QUARANTINED`/`RELEASED` — **R6-M2/L2**) | `SubmitInput` | `175 B` | `292 B` | `5,124 B` | `8,676 B` / proof | | |
| 112 | - | | `0x0E` | `GOVERNANCE_ADD_BINDING` (`kind=7`, Gov-only `RecognizedBindings`) | `GovernanceContract` | `33 B` | *(internal)* | `3,108 B` | `8,676 B` / proof | | |
| 113 | - | | `0x0F` | `BTC_TRAP_TIMEOUT_HALT` (`PENDING_TRAP` expired `> 230` blks → `Halted`) | `SubmitInput` | `37 B` | `164 B` | `3,204 B` | `8,676 B` / proof | | |
| 114 | - | | `0x10` | **`BTC_ROUND_RETIRED`** (permissionless SPV of `RoundRetireTx`, 7 keys — **S6-5**) | `SubmitInput` | `1,147 B` | `1,252 B` | `8,292 B` | `8,676 B` / proof | | |
| 81 | + | ### 2.4 Stage 0 Oracle Storage Layout (`BtcSpvOracleContract`) | |
| 115 | 82 | ||
| 116 | - | *(Every byte count above is verified verbatim by [`scripts/verify_spec_bounds.py`](../scripts/verify_spec_bounds.py); all 17 tags fall back to bounded Multi-Tx `UploadWitnessProof` if SMT grinding pushes any path past `12 KiB`, bounded by design up to `sib_count = 256` subject to Gate G-9.)* | |
| 83 | + | | Prefix | Key | Value | Pruning Policy | | |
| 84 | + | |---|---|---|---| | |
| 85 | + | | `0x20` | singleton | `ChainMeta` (`BestTipHash`, `BestTipHeight`, `BestTipWork`, `PostAnchorWork`, `ReorgActive`, `DeepReorgAlert`) | Never pruned | | |
| 86 | + | | `0x21` | `blockHashBE(32B)` | `HeaderNode` (`160 B`, incl. `mtpWindow[11]`) | Pruned via `PruneStaleHeaders` when `< BestTip - 144 && height % 2016 != 0 && ReorgActive == 0` | | |
| 87 | + | | `0x22` | `u64BE(height)` | `ActiveChainByHeight` (`68 B`: `blockHashBE \|\| merkleRootLE \|\| blockTime`) | **NEVER PRUNED** | | |
| 88 | + | | `0x23` | `txid(32B)` | `VerifiedEvent` (`blockHeight`, `blockHashBE`, `txIndex`, `finalized: bool`) | Never pruned | | |
| 117 | 89 | ||
| 118 | 90 | --- | |
| 119 | 91 | ||
| 120 | - | ## 4. Deterministic, Panic-Free `BitcoinChainVerifier` (`vm/embedded/btcspv`) | |
| 92 | + | ## 3. Stage 1A: Bitcoin-L1-Canonical Authorization Domain (`0%` Zenon Trust) | |
| 121 | 93 | ||
| 122 | - | ### 4.1 Header Validation, Never-Pruned Merkle+Time Index & Reorg/Prune Rules | |
| 94 | + | For pooled, fungible `zBTC`, **Bitcoin L1 is the sole canonical ordering, data-availability, and forced-inclusion layer**. Zenon Pillars act strictly as **untrusted feeless soft-preconfirmation sequencers** (`spec/03 §2`, `spec/04 §2`). Even if **49%–100% of Zenon Pillars are Byzantine**, they cannot fork `zBTC`, mint 1 unbacked satoshi, or censor Bob's or Mike's exit. | |
| 123 | 95 | ||
| 124 | - | - **Idempotent Duplicate No-Op**: Re-submitting an already-present valid input returns `stepError = 2` (refundable up to a global cap of `<= 16` duplicate refunds per batch). Malformed/invalid inputs set `stepError = 1`. | |
| 125 | - | - **`BTC_HEADER_BATCH` (`0x00`)**: Exact Bitcoin mainnet `SetCompact`, 2016-block `[302400, 4838400]`s retarget, embedded `mtpWindow[11]`, `futureTimeGuardSecs = 7,200`, `LOWEST_BLOCK_HASH_BE`, incremental reorg. Writes **`ActiveChainByHeight[height] = blockHashBE(32B) || merkleRootLE(32B) || blockTime(u32BE, 4B)` (68 B)** — **NEVER PRUNED**. | |
| 126 | - | - **`BTC_REORG_STEP` (`0x01`)**: Walks 1 step/input (`<= 5` keys), updates `ActiveChainByHeight[h]`, sets `Halted = 1` on any orphaned `AdmittedEventBlocks[h]` or `ReorgSteps > 144`. | |
| 127 | - | - **`BTC_PRUNE_STEP` (`0x02`)**: Rejects while `ReorgActive == 1`; deletes ONLY stale `HeaderNode`s at `height < BestTipHeight - 144 && height % 2016 != 0`. | |
| 96 | + | ### 3.1 Canonical Bitcoin L1 Tag Schema (`OP_RETURN "ZBTX"` `<= 80 B` + Taproot Witness) | |
| 128 | 97 | ||
| 129 | - | ### 4.2 Streaming SHA-256 Transaction Verifier (`BTC_TX_STREAM_CHUNK`, `0x04`) | |
| 98 | + | All Stage 1A protocol events are tagged on Bitcoin L1 with a `4 B` magic prefix `"ZBTX"` (`0x5a 0x42 0x54 0x58`) and `1 B` `tag` inside an `OP_RETURN` output (`<= 80 B` standardness limit). Bulk payloads (`certBlob`, mutated SMT leaves, `π_batch`, signed forced transfers) sit inside the spending transaction's Taproot script-path witness, bound by SHA-256 commitment in the `OP_RETURN` and verified against the block's BIP-141 coinbase witness commitment. | |
| 130 | 99 | ||
| 131 | - | Starts strictly from standard SHA-256 IV, enforces ordered 64 B-aligned chunks (`<= 8,192 B`), rejects SegWit marker `0x00 0x01`, verifies `totalBytes != 64` and zero trailing bytes, latches `txidLE`, `isCoinbase`, `matchedOutpoint`, and `opReturnBurnMatched` into `TxStreamState` (`175 B`). Small coinbases `<= 1,024 B` MAY pass inline (`mode = 0`) OR streamed (`mode = 1`). | |
| 100 | + | | Tag | Name | `OP_RETURN` Layout & Exact Size | Taproot Witness / Additional Outputs | Purpose | | |
| 101 | + | |---|---|---|---|---| | |
| 102 | + | | `0x00` | `DEPOSIT` | `"ZBTX"(4) \|\| 0x00(1) \|\| recipientAcctHash(32) \|\| vaultParamsHash(32)` = **`69 B`** | Input witness carries acyclic `OP_DROP` `certBlob` (`104 B <= 520 B` BIP-342 push limit) + `<pk_depositor> OP_CHECKSIG`; outputs create `{0.50, 0.25, 0.25}` BTC deleted-key vaults (`spec/01 §2.2`, zero hash cycle — `txid_dep` is fixed before presigning). | Register `K`-deep multi-tier deposit vaults (`vaultId = txid_dep : vout`) and credit `recipientAcctHash` in the Rollup SMT. | | |
| 103 | + | | `0x01` | `FORCED_EXIT` | `"ZBTX"(4) \|\| 0x01(1) \|\| exitCommitHash(32)` = **`37 B`** | Witness carries `(acctId, nonce, grossSats, maxOpFeeSats, destScriptPubKey, cancelPubKey, sig_user)`; additional output creates the **`(2M+1)`-leaf `ExitSlotUTXO`** (`546` sat dust anchor, `spec/01 §5`, `spec/03 §2.4`). | Uncensorable L1 exit for Bob (`0.50 BTC`) or Mike (`0.25 BTC`), bypassing 49%–100% Zenon censorship & Plasma spikes. | | |
| 104 | + | | `0x02` | `BATCH_DA` | `"ZBTX"(4) \|\| 0x02(1) \|\| batchCommitHash(32)` = **`37 B`** | Witness carries `prevRoot(32B) \|\| newRoot(32B) \|\| mutatedLeaves[]` (**`16 B`** existing `{acctId(4), balanceSats(8), nonce(4)}` / **`48 B`** new `{acctId(4), pubkey(32), balanceSats(8), nonce(4)}`) `\|\| π_batch` (`~256 B` Groth16 or `~15–40 KB` transparent STARK/IPA). | Anchor feeless Zenon-sequenced transfers onto Bitcoin L1 with **100% self-contained state-diff DA** (zero Zenon node needed to reconstruct SMT!). | | |
| 105 | + | | `0x03` | `FORCED_TRANSFER` | `"ZBTX"(4) \|\| 0x03(1) \|\| txCommitHash(32)` = **`37 B`** | Witness carries signed `110 B` rollup transfer (or `RollupHTLC`/`RollupPTLC` op). | Uncensorable L1 transfer fallback if Zenon censors or Dynamic Plasma spikes. | | |
| 106 | + | | `0x04` | `CHALLENGE_CLAIM` | `"ZBTX"(4) \|\| 0x04(1) \|\| kickoffTxid(32) \|\| verifierAcctId(4)` = **`41 B`** | Emitted on every `ChallengeTx_{r,i}` opened in simultaneous window `[0, 144]` (`spec/01 §4`). | Registers honest challenger eligibility for atomic `0.55 BTC` `B_zbtc` split (`>= 0.0917 BTC` each) upon `Stake_r` slash. | | |
| 107 | + | | `0x05` | `FRONT_CLAIM` | `"ZBTX"(4) \|\| 0x05(1) \|\| exitId(32) \|\| operatorId(4)` = **`41 B`** | Emitted when operator $O_j$ spends `ExitSlotUTXO` paying `destScriptPubKey` `>= grossSats - maxOpFeeSats` in `vout[0]`. | Credits `ReimbursementCredit[O_j] += grossSats` (or triggers `0.01 BTC` grief slash + refund if `vout[0]` fails payment!). | | |
| 108 | + | | `0x06` | `EXIT_FEE_BUMP` | `"ZBTX"(4) \|\| 0x06(1) \|\| exitId(32) \|\| newMaxOpFeeSats(8)` = **`45 B`** | Witness carries user signature over `(exitId, newMaxOpFeeSats)` where `newMaxOpFeeSats > oldMaxOpFeeSats`. | Lets Bob/Mike raise fronting incentive during L1 fee spikes without re-queuing. | | |
| 109 | + | | `0x07` | `RELEASE_ASSIGNMENT` | `"ZBTX"(4) \|\| 0x07(1) \|\| vaultId(32) \|\| operatorId(4)` = **`41 B`** | Witness carries explicit `O_j` signature voluntarily releasing an already-assigned vault (vault assignment itself is **deterministic FIFO inside $\mathcal{F}$** once `ReimbursementCredit[O_j] >= D_d`; zero passive-timeout slash, `spec/01 §6`). | Optional `O_j`-signed voluntary release returning `Vaults[vaultId]` to `UNASSIGNED` and restoring `ReimbursementCredit[O_j] += D_d`. | | |
| 132 | 110 | ||
| 133 | - | ### 4.3 Hardened Transaction & Claim Verification Rules (`R6-M2..M5`, `R6-L2`, `R6-L5`, `R6-L6`) | |
| 111 | + | ### 3.2 Complete Stripped-Block Scan & BIP-141 Witness Binding | |
| 134 | 112 | ||
| 135 | - | Every proof checks `ActiveChainByHeight[blockHeight]`, `BestTipHeight >= blockHeight + K - 1`, `len != 64`, `txIndex != 0`, valid coinbase, CVE-2012-2459, and `len(txBranch) == len(coinbaseBranch)`. | |
| 113 | + | Inside the `RV32IM` Rollup verifier $\mathcal{F}$ (executed optimistically off-chain and disprovable via `BitVMX-CPU` `n = 8` bisection on any disputed single instruction): | |
| 114 | + | 1. **Complete Stripped Block Verification (`<= 1,000,000 B` Bitcoin consensus stripped-block cap):** For every confirmed block $h$ in the canonical range `[h_prev + 1, h_tip - K + 1]`, the prover feeds the **complete stripped block** (`tx_0 .. tx_{m-1}`) into $\mathcal{F}$. $\mathcal{F}$ computes every `txid_i = doubleSHA256(stripped_tx_i)`, reconstructs the full transaction Merkle root, and asserts equality with `header[h].merkleRoot`. **No transaction in block $h$ can ever be omitted or censored by a malicious prover.** | |
| 115 | + | 2. **BIP-141 Single-Branch Witness Inclusion:** For each stripped transaction $tx_i$ carrying an `OP_RETURN "ZBTX"` output requiring witness data (`0x00`, `0x01`, `0x02`, `0x03`, `0x06`, `0x07`), $\mathcal{F}$ parses the full `tx_0` coinbase outputs to extract the unique BIP-141 witness commitment `SHA256d(witnessRoot || witnessNonce)` (verifying `tx_0` is syntactically a coinbase with `vin[0].prevout == 0x00^32 : 0xffffffff`), verifies the single `wtxid_i` Merkle branch against `witnessRoot`, and checks `SHA256(witnessPayload) == opReturnCommitHash` (or verifies the `O_j` witness signature for `0x07`). | |
| 116 | + | 3. **Deterministic Skip on Invalid `0x02 BATCH_DA`:** Because `0x02` is permissionless, anyone can post a malformed `0x02` commitment on Bitcoin L1. If a `0x02` transaction fails witness parsing, `prevRoot != R_cur`, or `Verify(π_batch) == false`, $\mathcal{F}$ **deterministically skips** that `0x02` tx without halting state progression! | |
| 136 | 117 | ||
| 137 | - | 1. **`PEGOUT_CREATED` (`0x03`, `kind=7`)**: Writes `PegOutState[outboxId]` (`190 B`, `slotOperatorId = 0`, `lastLapsedOperatorId = 0`). | |
| 138 | - | 2. **`PEGOUT_SLOT_CLAIMED` (`0x0A`, `kind=7` — Single Authority & Anti-Censorship, Closing `R6-M4` & `R6-M5`)**: If `po.SlotOperatorId != 0 && (ChainMeta.BestTipHeight < po.SlotExpiryBtcHeight || inputMomentumTs < po.SlotExpiryBtcTs)`, **IGNORE (`stepError = 2`)** — NEVER overwrite an unexpired slot! If an old slot HAS expired (`BestTipHeight >= po.SlotExpiryBtcHeight && inputMomentumTs >= po.SlotExpiryBtcTs`), records `po.LastLapsedOperatorId = po.SlotOperatorId` and rejects consecutive re-claim (`newOpId == po.LastLapsedOperatorId` when another eligible op exists). Otherwise writes `po.SlotOperatorId = newOpId`, `po.SlotExpiryBtcHeight = ChainMeta.BestTipHeight + 24`, `po.SlotExpiryBtcTs = slotClaimZenonTs + 14_400`. | |
| 139 | - | 3. **`OPERATOR_ROUND_REGISTERED` (`0x0B` — Exact Epoch Alignment, Closing `R6-L6`)**: Requires `epoch := epoch(roundId) < 4096`, **`anchorExpiryTs == finalityEpochStartTs(epoch) + 58 days`** (exact equality!), and `anchorCutoffTs == anchorExpiryTs - 12 days`; verifies 64 B `CommitteeIdentityKey` sig over `(cfg.ChainBindingHash || opId || roundId || bondOutpoint || anchorCutoffTs || anchorExpiryTs)`; writes `OperatorBondRecord` (`52 B`). | |
| 140 | - | 4. **`GOVERNANCE_ADD_BINDING` (`0x0E`, `kind=7`, Governance-only)**: Writes `RecognizedBindings[chainBindingHash] = 1`. | |
| 141 | - | 5. **`BTC_LOCK_PROOF` (`0x05`) → `FOREIGN_LOCK`**: Proves `DepositTx` + mandatory 2-input `RolloverTx`, BIP-68/112 Leaf A, `Q_vault_d` from `releaseAdapterRef.qGraphXOnly`, `epochId < 4096`, BOTH replay keys absent, and 64 B `CommitteeIdentityKey` sig over `(cfg.ChainBindingHash || rolloverOutpoint || eligibleBitmask || epochId || takeTxidsSmtRoot || takeTxidsBlobHash)` (where `takeTxidsBlobHash` commits to the published sorted Take-txid leaf list — `R6-L5`). Writes multi-epoch `TrackedVaultRecord{ACTIVE, 0, activeEpochs=[{epochId, takeTxidsSmtRoot}]}` (`78 B`), `AdmittedEventBlocks[h_rol]`, and emits `FOREIGN_LOCK`. | |
| 142 | - | 6. **`BTC_RELEASE_PROOF` (`0x06` — Decoupled From Vault Status, Closing `R6-M3`)**: Loads `po := PegOutState[outboxId]` and `tv := TrackedVaultRecord[po.AssignedVaultOutpoint]`. **NEVER rejects a valid fronting proof merely because `tv.status` transitioned to `PENDING_TRAP` or `RECOVERED`!** Verifies `RecognizedBindings[po.ChainBindingHash] == 1`, `ResolutionSeenByOutboxId[outboxId]` absent, `FrontingOutpointUsed` absent, `h_front < po.TimeoutHeight`, `BestTipHeight <= po.TimeoutHeight + ReleaseSubmissionGrace + K`, exact payment + `"ZBTC_FNT"` tag, and domain-authoritative slot exclusivity (`h_front < po.SlotExpiryBtcHeight || ActiveChainByHeight[h_front].blockTime <= po.SlotExpiryBtcTs ⇒ operatorId == po.SlotOperatorId`). Transitions `tv.status = RELEASED` **iff** `tv.status == ACTIVE` (preserving `PENDING_TRAP`/`RECOVERED` so Settlement re-points `PegOutRecord` cleanly!), marks `ResolutionSeenByOutboxId[outboxId]`, and emits `FOREIGN_RELEASE(operatorId)`. | |
| 143 | - | 7. **`BTC_NON_DELIVERY_PROOF` (`0x07`) → `FOREIGN_NON_DELIVERY`**: Requires `ResolutionSeenByOutboxId[outboxId]` absent, `checkpointH = po.TimeoutHeight + 558`, `BestTipHeight >= checkpointH + K - 1`, emits `FOREIGN_NON_DELIVERY`. | |
| 144 | - | 8. **`BTC_VAULT_SPEND_PROOF` (`0x08` — Verifier-Decided SMT Inclusion vs All-Epoch Absence Across ALL Live Statuses, Closing `R5-M1` & `R6-L5`)**: | |
| 145 | - | - Proves finalized streamed tx `spendTxid` spent `vaultOutpoint` (`h_spend`) while `tv := TrackedVaultRecord[vaultOutpoint]` has `tv.status ∈ {ACTIVE, RELEASED, QUARANTINED}`: | |
| 146 | - | - **If `tv.status == QUARANTINED`**: ZERO valid spends exist prior to re-graphing (`0x0D`) ⇒ **immediate `ChainMeta.Halted = 1`**! | |
| 147 | - | - **If `tv.status ∈ {ACTIVE, RELEASED}` — Branch A (Registered Take)**: Valid `proof-format.md` V1 SMT **INCLUSION** proof that `SHA3-256(spendTxid)` is present in `e.takeTxidsSmtRoot` for ANY active epoch `e ∈ tv.activeEpochs`: if `tv.status == ACTIVE` → transitions `tv.status = PENDING_TRAP`, `tv.pendingTrapSpendHeight = h_spend` (NO halt!); if `tv.status == RELEASED` → valid reimbursement (no-op) if `spendTxid` belongs to `ReimbursementOperator`, else `PENDING_TRAP`! | |
| 148 | - | - **Branch B (Raw Unauthorized Sweep on `ACTIVE` OR `RELEASED` → Immediate `Halted = 1`)**: Proof **MUST supply valid `proof-format.md` V1 SMT ABSENCE proofs (`VerifyAbsenceByPath`) proving `SHA3-256(spendTxid)` is ABSENT from `e.takeTxidsSmtRoot` for EVERY active epoch `e ∈ tv.activeEpochs`** (constructible by anyone from the published `takeTxidsBlobHash` leaf DA!) → sets `ChainMeta.Halted = 1`! | |
| 149 | - | - **Branch C (Invalid/Omitted Proof)**: If NEITHER Branch A NOR Branch B validates, **REJECT (`stepError = 1`)**! | |
| 150 | - | 9. **`BTC_TRAP_TIMEOUT_HALT` (`0x0F`)**: If `tv.status == PENDING_TRAP && BestTipHeight >= tv.pendingTrapSpendHeight + 230` → sets `ChainMeta.Halted = 1`. | |
| 151 | - | 10. **`BTC_OPERATOR_SLASH_PROOF` (`0x09`)**: Verifies streamed tx spent `OperatorBondOutpoints[opId || roundId]` with `opReturnBurnMatched == 1` → sets `OperatorSlashed[opId] = 1`. | |
| 152 | - | 11. **`BTC_VAULT_RECOVERY_PROOF` (`0x0C`)**: Verifies streamed `WrongDepositDisproveTx^{T1|T2}` spent `OperatorBondOutpoints[opId || roundId]` (`opReturnBurnMatched == 1`) AND created `Out 0 = recoveryOutpoint` paying `99,899,000` sats to `Q_rec_d` while `tv.status ∈ {ACTIVE, PENDING_TRAP}` → sets `OperatorSlashed[opId] = 1`, `tv.status = RECOVERED`, inserts `TrackedVaultRecord[recoveryOutpoint] = {QUARANTINED, 0, activeEpochs=[]}`, and stores **`RecoveredVaultMap[oldOutpoint] = {recoveryOutpoint, offendingOperatorId: opId, offendingRoundId: roundId}` (`44 B`)**! | |
| 153 | - | 12. **`VAULT_GRAPH_EPOCH_ADDED` (`0x0D` — Strict Multi-Gen Update for `ACTIVE`, `QUARANTINED`, AND `RELEASED`, Closing `R6-M2` & `R6-L2`)**: Verifies `epochId (u16) < 4096`, `newBitmask != 0`, and 64 B `CommitteeIdentityKey` sig over `(cfg.ChainBindingHash || vaultOutpoint || newBitmask || u16BE(epochId) || newTakeTxidsSmtRoot || takeTxidsBlobHash)` while `tv.status ∈ {ACTIVE, QUARANTINED, RELEASED}`! First prunes any expired epoch `e'` whose `finalityEpochStartTs(e') + 58d < ChainMeta.BestTipBlockTime`. **STRICTLY REJECTS (`stepError = 1`) if `epochId` is ALREADY present in `tv.activeEpochs` (zero overwriting!) OR if `len(tv.activeEpochs) >= 2` (hard 2-epoch cap!)**. Appends `{epochId, newTakeTxidsSmtRoot}`, transitions `QUARANTINED → ACTIVE` (leaving `ACTIVE`/`RELEASED` unchanged), and writes `RegraphedVaultEpoch[vaultOutpoint || u16BE(epochId)]` (`0x10`)! | |
| 154 | - | 13. **`BTC_ROUND_RETIRED` (`0x10`)**: Proves finalized streamed `RoundRetireTx_{m,l,r}` (or `RoundRetireTx_{m,l,init}`) spent `OperatorBondOutpoints[opId || roundId]` (or `GenesisBond`) paying `3.6990 BTC` to `<pk_m>` (no `OP_RETURN` burn) → sets **`LaneRetired[opId || u16BE(epochId) || laneIndex] = 1`** (`0x11`). | |
| 118 | + | ### 3.3 Canonical Intra-Block Ordering (Eliminating 49%–100% Zenon Forks) | |
| 155 | 119 | ||
| 120 | + | Within each `K`-deep Bitcoin block $h$, $\mathcal{F}$ transitions $R_{h-1} \to R_h$ in strict deterministic order: | |
| 121 | + | 1. **Pass 1 — Deposits (`0x00 DEPOSIT`):** Process in Bitcoin block transaction-index order `i = 1..m-1`. Verify acyclic `certBlob` (`104 B`), valid `N`-of-`N` setup cohort binding, valid `{0.50, 0.25, 0.25}` BTC vault outputs, and `totalTVL + D_d <= Cap_TVL`. Credit `Accounts[recipientAcctHash].balanceSats += D_d`. | |
| 122 | + | 2. **Pass 2 — First Valid Sequenced Batch (`0x02 BATCH_DA`):** Scan block $h$ in tx-index order and apply **AT MOST ONE** valid `0x02` batch whose `prevRoot == R_after_pass_1` and whose `π_batch` verifies against the complete mutated SMT leaf list. **Any competing `0x02` batch (e.g., from a 49% Zenon fork!) automatically fails `prevRoot` matching and is deterministically ignored.** | |
| 123 | + | 3. **Pass 3 — Mandatory L1 Forced Inclusion (`0x03`, `0x01`, `0x06`):** Apply EVERY valid `0x03 FORCED_TRANSFER`, `0x01 FORCED_EXIT`, and `0x06 EXIT_FEE_BUMP` in tx-index order. Because these execute directly from Bitcoin L1, **100% hostile Zenon Pillars cannot delay or censor a single forced transfer or exit by even 1 Bitcoin block**. | |
| 124 | + | 4. **Pass 4 — Settlement, Deterministic FIFO Assignment & Slashing Events (`0x04`, `0x05`, `0x07`, `ExitSlotUTXO` spends, `Stake_r` slashes, `BurnBondTx_{r,k}`):** Process all `ExitSlotUTXO` spends (universal spend-or-refund rule, `spec/03 §2.4`), deterministic FIFO oldest-eligible-vault assignment whenever `ReimbursementCredit[O_j] >= D_d` (filtered by `opBitmask`), optional `O_j`-signed `0x07 RELEASE_ASSIGNMENT`, `ChallengeTx_{r,i}` (`0x04`), `DisproveTx`/`TimeoutSlashTx` dual-input slashes (`0.55 BTC` `B_zbtc` split across remaining challengers), and `BurnBondTx_{r,k}` Lamport equivocation slashes (`D_d` burned from `B_zbtc` + `0.05 BTC` bounty). | |
| 125 | + | ||
| 156 | 126 | --- | |
| 157 | 127 | ||
| 158 | - | ## 5. Verifier State Layout (Domain L2 SMT — Field-Derived Sizes) | |
| 128 | + | ## 4. Launch-Time PoW Anchor, Retargeting & Halving-Indexed TVL-Scaled `K` | |
| 159 | 129 | ||
| 160 | - | | Prefix | Key | Value (Field-Derived in Oracle) | Pruning Policy | | |
| 161 | - | |---|---|---|---| | |
| 162 | - | | `0x01` | singleton | `ChainMeta` (`238 B`) | Never pruned | | |
| 163 | - | | `0x02` | `blockHashBE(32B)` | `HeaderNode` (`160 B`) | Pruned when `height < BestTip - 144 && height % 2016 != 0 && ReorgActive == 0` | | |
| 164 | - | | `0x03` | `u64BE(height)` | `blockHashBE(32B) \|\| merkleRootLE(32B) \|\| blockTime(4B)` (`68 B`) | **NEVER PRUNED** | | |
| 165 | - | | `0x04` | `BitcoinOutpointID(32B)` | `u64BE(rolloverHeight)` | Never pruned | | |
| 166 | - | | `0x05` | `outboxId(32B)` | `ResolutionRecord` (`37 B`) | Never pruned | | |
| 167 | - | | `0x06` | `u64BE(height)` | `admittedBlockHashBE(32B)` | Never pruned | | |
| 168 | - | | `0x07` | `outboxId(32B)` | `PegOutState` (`190 B`, incl. `lastLapsedOperatorId` — **R6-M5**) | Never pruned | | |
| 169 | - | | `0x08` | `vaultOutpoint(36B)` | `TrackedVaultRecord` (`78 B`: status, `pendingTrapSpendHeight`, up to 2 `{epochId, takeTxidsSmtRoot}`) | Never pruned | | |
| 170 | - | | `0x09` | `frontingTxidBE \|\| vout` | `u8(1)` | Never pruned | | |
| 171 | - | | `0x0A` | `depositOutpoint(36B)` | `u8(1)` (`ProcessedProvisionalDeposit`) | Never pruned | | |
| 172 | - | | `0x0B` | `streamId(32B)` | `TxStreamState` (`175 B`) | Prunable after `144` blocks once consumed | | |
| 173 | - | | `0x0C` | `u32BE(operatorId)` | `u8(1)` (`OperatorSlashed`) | Never pruned | | |
| 174 | - | | `0x0D` | `u32BE(opId) \|\| u32BE(roundId)` | `OperatorBondRecord` (`52 B`: `bondOutpoint(36) \|\| anchorCutoffTs(8) \|\| anchorExpiryTs(8)`) | Never pruned | | |
| 175 | - | | `0x0E` | `chainBindingHash(32B)` | `u8(1)` (`RecognizedBindings`, Governance-only) | Never pruned | | |
| 176 | - | | `0x0F` | `oldOutpoint(36B)` | `RecoveredVaultRecord` (`44 B`: `recoveryOutpoint(36) \|\| opId(4) \|\| roundId(4)`) | Never pruned | | |
| 177 | - | | `0x10` | `vaultOutpoint(36B) \|\| u16BE(epochId)` | `RegraphedVaultEpoch` (`40 B`: `bitmask(8) \|\| takeTxidsSmtRoot(32)`) | Never pruned | | |
| 178 | - | | `0x11` | `u32BE(opId) \|\| u16BE(epochId) \|\| u8(lane)` | `u8(1)` (`LaneRetired` — **R5-M2**) | Never pruned | | |
| 130 | + | Because Bitcoin L1 scripts without covenants cannot inspect arbitrary future chain tips directly, each finite `BitVMX` `StakeChain` lane `(j, l)` (`R = 64` rounds, active horizon `<= ~1.5` years) verifies Bitcoin PoW inside $\mathcal{F}$ anchored at lane launch (`t = 0`, **before** `Q_lane_{j,l}` deletion — zero pre-broadcast hash cycle!): | |
| 179 | 131 | ||
| 132 | + | 1. **Launch-Time Lane Anchor `(h_lane_init, H_init, D_init)`:** Pins an **already-confirmed** Bitcoin mainnet block at lane creation, together with its 2,016-block retarget-period start header and `mtpWindow[11]`. | |
| 133 | + | 2. **Full 2,016-Block Retargeting & Difficulty Floor:** $\mathcal{F}$ validates every 80-byte Bitcoin header from `h_lane_init` to `h_tip` with exact mainnet `SetCompact`, `[302400, 4838400]`s 2,016-block retarget clamping, MTP monotonicity, and a normative difficulty-drop floor **`D(h) >= 0.50 * D(h_lane_init)`**. | |
| 134 | + | - *Explicit Difficulty-Growth Disclosure:* If mainnet difficulty grows `> 2×` during a finite lane's active lifetime, the effective private-fork difficulty ratio `α_diff = D(h_lane_init) / D_current` tightens proportionally (e.g., at `3×` growth, `α_diff = 0.33`, increasing required `K` by `1.5×`). Operators periodically retire old lanes (`RetireStakeTx` at `1,440` blocks) and launch fresh lanes re-anchored to current `D(h_lane_init)`. | |
| 135 | + | 3. **Halving-Indexed TVL-Scaled `K` Private-Fork Inequality:** To make a private PoW fork forging a fake `K`-deep state strictly unprofitable against honest mining opportunity cost, protocol TVL caps MUST satisfy: | |
| 136 | + | $$0.50 \times K \times \text{Subsidy}(\text{era}) > \text{Cap}_{\text{TVL}}$$ | |
| 137 | + | ||
| 138 | + | | Deployment Stage | `Cap_TVL` | `K` (2024–2028, `3.125 BTC` Subsidy) | `0.50 × K × Subsidy` | `K` (2028–2032, `1.5625 BTC` Subsidy) | `K` (2032–2036, `0.78125 BTC` Subsidy) | | |
| 139 | + | |---|---:|---:|---:|---:|---:| | |
| 140 | + | | **Stage 1A Pilot (`M = 3`)** | `<= 10 BTC` | **`14`** (`~2.3h`) | `21.875 BTC > 10` | `14` (`10.94 > 10`) | `28` (`10.94 > 10`) | | |
| 141 | + | | **Stage 1A Expanded (`M = 5`)** | `<= 15 BTC` | **`14`** (`~2.3h`) | `21.875 BTC > 15` | `20` (`15.63 > 15`) | `40` (`15.63 > 15`) | | |
| 142 | + | | **Stage 2 Scaled (`M = 10–20`)** | `<= 50 BTC` | **`36`** (`~6.0h`) | `56.250 BTC > 50` | `66` (`51.56 > 50`) | `130` (`50.78 > 50`) | | |
| 143 | + | | **Stage 2 High-Cap (`M = 20+`)** | `<= 200 BTC` | **`144`** (`~24h`) | `225.000 BTC > 200` | `260` (`203.13 > 200`) | `516` (`201.56 > 200`) | | |
| 144 | + | ||
| 180 | 145 | --- | |
| 181 | 146 | ||
| 182 | - | ## 6. Mandatory SPV Conformance Test Vectors (29 Vectors) | |
| 147 | + | ## 5. Mandatory SPV & Authorization Domain Conformance Test Vectors | |
| 183 | 148 | ||
| 184 | - | Vectors 1–24 from v2.3 PLUS: | |
| 185 | - | 25. **Verifier-Decided SMT Spend & Multi-Generation Rotation (`R5-M1`, `R5-H3`, `R6-L5`)**: Reject `BTC_VAULT_SPEND_PROOF` omitting both inclusion and all-epoch SMT absence proofs; verify rotated gen-`g+1` Take on an `ACTIVE` vault transitions to `PENDING_TRAP`; verify raw sweep with valid all-epoch SMT absence proofs halts immediately on BOTH `ACTIVE` AND `RELEASED` vaults, and ANY spend of a `QUARANTINED` vault halts immediately! | |
| 186 | - | 26. **Single-Authority Anti-Censorship Fronting Slot & Lane Retirement (`R6-M4`, `R6-M5`, `R5-M2`)**: Verify second `PEGOUT_SLOT_CLAIMED` during live slot is ignored (`stepError = 2`); verify consecutive re-claim by `lastLapsedOperatorId` is rejected; verify `BTC_ROUND_RETIRED` sets `LaneRetired = 1`. | |
| 187 | - | 27. **Decoupled `BTC_RELEASE_PROOF` on Trapped Vault (`R6-M3`)**: Verify valid `BTC_RELEASE_PROOF` is ADMITTED (`FOREIGN_RELEASE`) even after another operator's substituting `Take1` transitioned `TrackedVaultRecord` to `PENDING_TRAP` or `RECOVERED` (without overwriting `PENDING_TRAP`/`RECOVERED`). | |
| 188 | - | 28. **Strict `0x0D` Multi-Gen Guards (`R6-M2`, `R6-L2`)**: Verify `0x0D` succeeds on `ACTIVE`, `QUARANTINED`, AND un-claimed `RELEASED` vaults; verify `0x0D` REJECTS duplicate `epochId` AND REJECTS adding a 3rd unexpired epoch. | |
| 189 | - | 29. **Exact `0x0B` Epoch-Start Alignment (`R6-L6`)**: Verify `OPERATOR_ROUND_REGISTERED` REJECTS any `anchorExpiryTs != finalityEpochStartTs(epoch) + 58 days`. | |
| 149 | + | 1. **Stage 0 Header & Merkle Suite:** All 24 Bitcoin header, 2,016-block retarget (`[302400, 4838400]`s), MTP, `futureTimeGuardSecs = 7,200`, `LOWEST_BLOCK_HASH_BE` tie-break, `CVE-2012-2459`, and `CVE-2017-12842` (`len == 64` rejection) vectors. | |
| 150 | + | 2. **1- and 2-Block Coinbase Midstate Suite:** Valid coinbase proofs for BOTH `totalCoinbaseBytes % 64 ∈ [0, 55]` (1-block) AND `totalCoinbaseBytes % 64 ∈ [56, 63]` (2-block — e.g. `120 B`, `127 B`, `250 B`), plus rejection of `len(finalChunkTail) != totalCoinbaseBytes % 64` and `totalCoinbaseBytes == 64`. | |
| 151 | + | 3. **Panic-Free & Plasma-Floor Fuzz Gate (`B1`, `B2`):** Malformed ABI inputs across all 4 Stage 0 oracle methods MUST return deterministic errors (zero panics, zero FIFO sequencer stalls), and exact ABI sizing of `ProveTxInclusion` (`7,620 B`, `591,388` Plasma) fits `>= 3×` inside the `2,100,000` floor and `<= 40` contract blocks/Momentum. | |
| 152 | + | 4. **Stage 1A Stripped-Block & Tag-Ordering Suite:** Deterministic skip of malformed `0x02 BATCH_DA`, rejection of competing second `0x02` batch (49% Zenon fork simulation), mandatory inclusion of `0x03`/`0x01` even when all Zenon sequencers censor, and halving-indexed `K` PoW boundary enforcement across `2024–2036`. | |
| 190 | 153 | ||
Document Class: Normative Bitcoin SPV Verification & L1 Authorization Domain Specification (v1 / v3.0.0-rfc — Zero-Federation Phased Architecture; supersedes archived v0 v2.5.0-rfc)
Philosophical Anchor: Stage 0 implements Zenon's non-custodial verification thesis (zenon-developer-commons: essays/Verify Bitcoin, Don't Bridge It.md & docs/specs/spv-event-oracle-spec.md): Event Validity only, zero custody authority. Stage 1A moves canonical zBTC authorization, data availability, and forced exit directly onto Bitcoin L1 so that 49%–100% Zenon compromise cannot forge state or censor exits.
Consistency Checker: scripts/verify_spec_bounds.py
1. Two-Layer Separation: Stage 0 Event Oracle vs Stage 1A Canonical L1 Domain
This specification strictly separates two orthogonal verification surfaces with zero federated signers anywhere:
- Stage 0 — Direct-on-L1 Bitcoin SPV Event Oracle (
vm/embedded/btcspv):- Runs deterministically inside an embedded Zenon contract (
BtcSpvOracleContract), wrapped in mandatory panic recovery (recover(), zerocommon.DealWithErrcalls — closing upstream issue#239/ B1). - Proves Event Validity ONLY: cryptographic evidence that a Bitcoin transaction
txidis included at depth>= K_oracleon the heaviest cumulative-PoW Bitcoin header chain. - Hard Non-Custody Invariant: Stage 0 SPV has ZERO minting, burning, sweeping, or vault-spending authority. It powers Bitcoin-verified receipts, proof-of-payment triggers, and non-custodial PTLC/HTLC atomic swaps (
spec/03 §1).
- Runs deterministically inside an embedded Zenon contract (
- Stage 1A — Bitcoin-L1-Canonical Authorization Domain (
vk_STFRollup Circuit):- For pooled, fungible
zBTC(Stage 1A), Zenon L1 does NOT authorize mints, burns, or exits. - Instead, the immutable RISC-V / ZK Rollup State Transition Function ($\mathcal{F}$, compiled to
RV32IMforBitVMX-CPUn = 8bisection —spec/01) scans complete stripped Bitcoin blocks directly on Bitcoin L1, deriving the entire canonicalzBTCstate root $R_h$ strictly from Bitcoin's heaviest PoW chain (0-of-NZenon trust;0%ZNN market-cap coupling).
- For pooled, fungible
2. Stage 0: Direct-on-L1 Bitcoin SPV Event Oracle (vm/embedded/btcspv)
2.1 OracleChainConfig & Finality Parameters
OracleChainConfig {
foreignChainId : bytes32 // u16(0x0001) || SHA3-256("BTC_MAINNET_SPV_V1" || btcGenesisHashBE)[0:30]
genesisAnchor : Bytes // BitcoinAnchor { blockHashBE(32B), height(u64), header(80B), cumWork(u256),
// retargetStartHash(32B), retargetStartTime(u32), retargetHeight(u64), mtpWindow[11](u32) }
admissionDepthN : u32 // 6 blocks (provisional event admission; reversible on reorg)
finalizationDepthK : u32 // 12 blocks (oracle event finalization depth)
minimumPostAnchorWork : u256 // finalizationDepthK * blockWork(genesisAnchor.nBits)
retainedReorgDepth : u32 // 144 blocks (stale HeaderNode pruning ONLY; ActiveChainByHeight NEVER pruned)
maximumHeaderBatch : u32 // 2 headers per SubmitHeaderBatch call
maximumMerkleDepth : u32 // 16 levels (65,536 txs/block)
maximumStrippedTxBytes : u32 // 6,144 B (per-call Stage 0 proof cap; fits 3x inside pinned 2.1M Plasma floor)
futureTimeGuardSecs : u32 // 7,200 s (Bitcoin consensus MAX_FUTURE_BLOCK_TIME)
equalWorkTieBreak : u8 // 0 = LOWEST_BLOCK_HASH_BE (deterministic across all Zenon full nodes)
}
Testnet / Signet Scope Caveat: On Bitcoin Signet (where validity rests in the Signet challenge signature) and Testnet4 (minimum-difficulty block exception), header-only PoW SPV does not resist an adversary. Stage 0 Signet SPV tests are conformance-only; full PoW security applies strictly on Bitcoin Mainnet.
2.2 Stage 0 Embedded ABI Methods, Exact Sizes & Pinned Plasma Floor (B1, B2)
All 4 Stage 0 oracle methods are panic-recovered (B1), require zero federation signatures, and stay strictly within the pinned MaxBasePlasmaInMomentum >= 2,100,000 floor (spec/05 §2.2) and dp.MaxContractBlocks = 40 per-Momentum contract-block cap (origin/dev:dp/dp.go:259-264). Base Plasma under DynamicPlasmaSpork equals tier + 68 * (abiBytes - 4) (origin/dev:vm/plasma.go:185-200):
| ABI Method | Send Plasma Tier | Exact Max Payload | Exact Max ABI (32 B-padded) | Exact Base Plasma (QSR @ floor 1,000) | Max Storage Ops | Purpose |
|---|---|---|---|---|---|---|
SubmitHeaderBatch(headers) | 52,500 (Simple) | 160 B (2 × 80 B) | 228 B | 67,732 (33 QSR) | <= 8 | Validate 1..2 mainnet headers, 2016-block [302400, 4838400]s retarget, MTP, update ActiveChainByHeight. |
StepReorg() | 52,500 (Simple) | 0 B | 4 B | 52,500 (25 QSR) | <= 6 | Walk 1 incremental reorg step; emits deterministic reorg state transition if an admitted < 12-deep event is orphaned; flags DeepReorgAlert = 1 if ReorgSteps > 144. |
PruneStaleHeaders(hashes) | 52,500 (Simple) | 64 B (2 × 32 B) | 132 B | 61,204 (30 QSR) | <= 4 | Delete 1..2 stale HeaderNodes (height < BestTip - 144 && height % 2016 != 0 && ReorgActive == 0). |
ProveTxInclusion(...) | 73,500 (Heavy SPV) | 7,279 B | 7,620 B | 591,388 (282 QSR) | <= 8 | Verify >= N-deep strippedTx (<= 6,144 B) + 1-/2-block coinbase midstate + Merkle inclusion → record VerifiedEvent[txid]. |
Exact ProveTxInclusion ABI Derivation (Full 32 B-Padded Accounting):
- Static head:
4 Bselector +8 × 32 B(blockHeight,txIndex,totalCoinbaseBytes,sha256Midstate, + 4 dynamic offsets)= 260 B. - Dynamic bodies (
32 Blength prefix +32 B-padded bytes):strippedTx(32 + 6,144 = 6,176 B) +txBranch(32 + 16 × 32 = 544 B) +coinbaseTail(32 + 64 = 96 Bfor<= 63 Btail) +coinbaseBranch(32 + 16 × 32 = 544 B)= 7,360 B. - Total ABI
= 260 + 7,360 = 7,620 B <= 16,384 B(MaxDataLength). Base Plasma= 73,500 + 68 × (7,620 - 4) = 591,388. Up to3max-sizeProveTxInclusioncalls (1,774,164 <= 2,100,000) fit inside a single Momentum even at the pinned floor (6at default4,200,000).
2.3 Exact 1- and 2-Block Coinbase Midstate Proof (CVE-2017-12842)
Every ProveTxInclusion call MUST verify:
ChainMeta.ReorgActive == 0andChainMeta.PostAnchorWork >= minimumPostAnchorWork.ActiveChainByHeight[blockHeight]exists andBestTipHeight >= blockHeight + admissionDepthN - 1.len(strippedTx) <= 6,144,len(strippedTx) != 64(CVE-2017-12842),txIndex != 0, and no SegWit marker (0x00 0x01) in stripped bytes.doubleSHA256(strippedTx)verifies againstmerkleRootLEviatxBranchattxIndexwithlen(txBranch) == len(coinbaseBranch) <= 16and zero duplicate-sibling CVE-2012-2459 padding.- 1- and 2-Block SHA-256 Coinbase Midstate Verification:
- Caller supplies
(sha256Midstate: bytes32, finalChunkTail: bytes, totalCoinbaseBytes: u32, coinbaseBranch: bytes32[]). - Normative Constraints:
totalCoinbaseBytes >= 65(rejectstotalCoinbaseBytes == 64leaf forgery and impossibly short transactions).len(finalChunkTail) == totalCoinbaseBytes % 64(strictly< 64; rejects any mismatched or unaligned tail!).
- Exact Final SHA-256 Padding (
100%of valid Bitcoin coinbase lengths, avoiding the12.5%single-compression rejection bug whenrem ∈ [56, 63]): Letrem = totalCoinbaseBytes % 64andbitLen = u64BE(uint64(totalCoinbaseBytes) * 8):- Case 1 (
rem < 56— 1-block final padding): Build single64 BblockB_1 = finalChunkTail[0:rem] || 0x80 || 0x00^(55 - rem) || bitLen(8B). ComputeinnerHash = SHA256_Compress(sha256Midstate, B_1). - Case 2 (
56 <= rem <= 63— 2-block final padding): BuildB_1 = finalChunkTail[0:rem] || 0x80 || 0x00^(63 - rem)andB_2 = 0x00^56 || bitLen(8B). Computestate_1 = SHA256_Compress(sha256Midstate, B_1), theninnerHash = SHA256_Compress(state_1, B_2).
- Case 1 (
- Compute
coinbaseTxid = SHA256(innerHash)and verifycoinbaseBranchat index0againstmerkleRootLEwithlen(coinbaseBranch) == len(txBranch). - Explicit Auditability Disclosure: A midstate proof proves that Merkle index
0is a valid non-64-byte leaf at the same tree depth astxIndex(completely closing CVE-2017-12842 interior-node forgery); it does not parse the prefix of the coinbase transaction itself. In Stage 1A below, full coinbase bytes are directly verified inside the stripped-block scanner to extract the BIP-141 witness commitment.
- Caller supplies
2.4 Stage 0 Oracle Storage Layout (BtcSpvOracleContract)
| Prefix | Key | Value | Pruning Policy |
|---|---|---|---|
0x20 | singleton | ChainMeta (BestTipHash, BestTipHeight, BestTipWork, PostAnchorWork, ReorgActive, DeepReorgAlert) | Never pruned |
0x21 | blockHashBE(32B) | HeaderNode (160 B, incl. mtpWindow[11]) | Pruned via PruneStaleHeaders when < BestTip - 144 && height % 2016 != 0 && ReorgActive == 0 |
0x22 | u64BE(height) | ActiveChainByHeight (68 B: blockHashBE || merkleRootLE || blockTime) | NEVER PRUNED |
0x23 | txid(32B) | VerifiedEvent (blockHeight, blockHashBE, txIndex, finalized: bool) | Never pruned |
3. Stage 1A: Bitcoin-L1-Canonical Authorization Domain (0% Zenon Trust)
For pooled, fungible zBTC, Bitcoin L1 is the sole canonical ordering, data-availability, and forced-inclusion layer. Zenon Pillars act strictly as untrusted feeless soft-preconfirmation sequencers (spec/03 §2, spec/04 §2). Even if 49%–100% of Zenon Pillars are Byzantine, they cannot fork zBTC, mint 1 unbacked satoshi, or censor Bob's or Mike's exit.
3.1 Canonical Bitcoin L1 Tag Schema (OP_RETURN "ZBTX" <= 80 B + Taproot Witness)
All Stage 1A protocol events are tagged on Bitcoin L1 with a 4 B magic prefix "ZBTX" (0x5a 0x42 0x54 0x58) and 1 B tag inside an OP_RETURN output (<= 80 B standardness limit). Bulk payloads (certBlob, mutated SMT leaves, π_batch, signed forced transfers) sit inside the spending transaction's Taproot script-path witness, bound by SHA-256 commitment in the OP_RETURN and verified against the block's BIP-141 coinbase witness commitment.
| Tag | Name | OP_RETURN Layout & Exact Size | Taproot Witness / Additional Outputs | Purpose |
|---|---|---|---|---|
0x00 | DEPOSIT | "ZBTX"(4) || 0x00(1) || recipientAcctHash(32) || vaultParamsHash(32) = 69 B | Input witness carries acyclic OP_DROP certBlob (104 B <= 520 B BIP-342 push limit) + <pk_depositor> OP_CHECKSIG; outputs create {0.50, 0.25, 0.25} BTC deleted-key vaults (spec/01 §2.2, zero hash cycle — txid_dep is fixed before presigning). | Register K-deep multi-tier deposit vaults (vaultId = txid_dep : vout) and credit recipientAcctHash in the Rollup SMT. |
0x01 | FORCED_EXIT | "ZBTX"(4) || 0x01(1) || exitCommitHash(32) = 37 B | Witness carries (acctId, nonce, grossSats, maxOpFeeSats, destScriptPubKey, cancelPubKey, sig_user); additional output creates the (2M+1)-leaf ExitSlotUTXO (546 sat dust anchor, spec/01 §5, spec/03 §2.4). | Uncensorable L1 exit for Bob (0.50 BTC) or Mike (0.25 BTC), bypassing 49%–100% Zenon censorship & Plasma spikes. |
0x02 | BATCH_DA | "ZBTX"(4) || 0x02(1) || batchCommitHash(32) = 37 B | Witness carries prevRoot(32B) || newRoot(32B) || mutatedLeaves[] (16 B existing {acctId(4), balanceSats(8), nonce(4)} / 48 B new {acctId(4), pubkey(32), balanceSats(8), nonce(4)}) || π_batch (~256 B Groth16 or ~15–40 KB transparent STARK/IPA). | Anchor feeless Zenon-sequenced transfers onto Bitcoin L1 with 100% self-contained state-diff DA (zero Zenon node needed to reconstruct SMT!). |
0x03 | FORCED_TRANSFER | "ZBTX"(4) || 0x03(1) || txCommitHash(32) = 37 B | Witness carries signed 110 B rollup transfer (or RollupHTLC/RollupPTLC op). | Uncensorable L1 transfer fallback if Zenon censors or Dynamic Plasma spikes. |
0x04 | CHALLENGE_CLAIM | "ZBTX"(4) || 0x04(1) || kickoffTxid(32) || verifierAcctId(4) = 41 B | Emitted on every ChallengeTx_{r,i} opened in simultaneous window [0, 144] (spec/01 §4). | Registers honest challenger eligibility for atomic 0.55 BTC B_zbtc split (>= 0.0917 BTC each) upon Stake_r slash. |
0x05 | FRONT_CLAIM | "ZBTX"(4) || 0x05(1) || exitId(32) || operatorId(4) = 41 B | Emitted when operator $O_j$ spends ExitSlotUTXO paying destScriptPubKey >= grossSats - maxOpFeeSats in vout[0]. | Credits ReimbursementCredit[O_j] += grossSats (or triggers 0.01 BTC grief slash + refund if vout[0] fails payment!). |
0x06 | EXIT_FEE_BUMP | "ZBTX"(4) || 0x06(1) || exitId(32) || newMaxOpFeeSats(8) = 45 B | Witness carries user signature over (exitId, newMaxOpFeeSats) where newMaxOpFeeSats > oldMaxOpFeeSats. | Lets Bob/Mike raise fronting incentive during L1 fee spikes without re-queuing. |
0x07 | RELEASE_ASSIGNMENT | "ZBTX"(4) || 0x07(1) || vaultId(32) || operatorId(4) = 41 B | Witness carries explicit O_j signature voluntarily releasing an already-assigned vault (vault assignment itself is deterministic FIFO inside $\mathcal{F}$ once ReimbursementCredit[O_j] >= D_d; zero passive-timeout slash, spec/01 §6). | Optional O_j-signed voluntary release returning Vaults[vaultId] to UNASSIGNED and restoring ReimbursementCredit[O_j] += D_d. |
3.2 Complete Stripped-Block Scan & BIP-141 Witness Binding
Inside the RV32IM Rollup verifier $\mathcal{F}$ (executed optimistically off-chain and disprovable via BitVMX-CPU n = 8 bisection on any disputed single instruction):
- Complete Stripped Block Verification (
<= 1,000,000 BBitcoin consensus stripped-block cap): For every confirmed block $h$ in the canonical range[h_prev + 1, h_tip - K + 1], the prover feeds the complete stripped block (tx_0 .. tx_{m-1}) into $\mathcal{F}$. $\mathcal{F}$ computes everytxid_i = doubleSHA256(stripped_tx_i), reconstructs the full transaction Merkle root, and asserts equality withheader[h].merkleRoot. No transaction in block $h$ can ever be omitted or censored by a malicious prover. - BIP-141 Single-Branch Witness Inclusion: For each stripped transaction $tx_i$ carrying an
OP_RETURN "ZBTX"output requiring witness data (0x00,0x01,0x02,0x03,0x06,0x07), $\mathcal{F}$ parses the fulltx_0coinbase outputs to extract the unique BIP-141 witness commitmentSHA256d(witnessRoot || witnessNonce)(verifyingtx_0is syntactically a coinbase withvin[0].prevout == 0x00^32 : 0xffffffff), verifies the singlewtxid_iMerkle branch againstwitnessRoot, and checksSHA256(witnessPayload) == opReturnCommitHash(or verifies theO_jwitness signature for0x07). - Deterministic Skip on Invalid
0x02 BATCH_DA: Because0x02is permissionless, anyone can post a malformed0x02commitment on Bitcoin L1. If a0x02transaction fails witness parsing,prevRoot != R_cur, orVerify(π_batch) == false, $\mathcal{F}$ deterministically skips that0x02tx without halting state progression!
3.3 Canonical Intra-Block Ordering (Eliminating 49%–100% Zenon Forks)
Within each K-deep Bitcoin block $h$, $\mathcal{F}$ transitions $R_{h-1} \to R_h$ in strict deterministic order:
- Pass 1 — Deposits (
0x00 DEPOSIT): Process in Bitcoin block transaction-index orderi = 1..m-1. Verify acycliccertBlob(104 B), validN-of-Nsetup cohort binding, valid{0.50, 0.25, 0.25}BTC vault outputs, andtotalTVL + D_d <= Cap_TVL. CreditAccounts[recipientAcctHash].balanceSats += D_d. - Pass 2 — First Valid Sequenced Batch (
0x02 BATCH_DA): Scan block $h$ in tx-index order and apply AT MOST ONE valid0x02batch whoseprevRoot == R_after_pass_1and whoseπ_batchverifies against the complete mutated SMT leaf list. Any competing0x02batch (e.g., from a 49% Zenon fork!) automatically failsprevRootmatching and is deterministically ignored. - Pass 3 — Mandatory L1 Forced Inclusion (
0x03,0x01,0x06): Apply EVERY valid0x03 FORCED_TRANSFER,0x01 FORCED_EXIT, and0x06 EXIT_FEE_BUMPin tx-index order. Because these execute directly from Bitcoin L1, 100% hostile Zenon Pillars cannot delay or censor a single forced transfer or exit by even 1 Bitcoin block. - Pass 4 — Settlement, Deterministic FIFO Assignment & Slashing Events (
0x04,0x05,0x07,ExitSlotUTXOspends,Stake_rslashes,BurnBondTx_{r,k}): Process allExitSlotUTXOspends (universal spend-or-refund rule,spec/03 §2.4), deterministic FIFO oldest-eligible-vault assignment wheneverReimbursementCredit[O_j] >= D_d(filtered byopBitmask), optionalO_j-signed0x07 RELEASE_ASSIGNMENT,ChallengeTx_{r,i}(0x04),DisproveTx/TimeoutSlashTxdual-input slashes (0.55 BTCB_zbtcsplit across remaining challengers), andBurnBondTx_{r,k}Lamport equivocation slashes (D_dburned fromB_zbtc+0.05 BTCbounty).
4. Launch-Time PoW Anchor, Retargeting & Halving-Indexed TVL-Scaled K
Because Bitcoin L1 scripts without covenants cannot inspect arbitrary future chain tips directly, each finite BitVMX StakeChain lane (j, l) (R = 64 rounds, active horizon <= ~1.5 years) verifies Bitcoin PoW inside $\mathcal{F}$ anchored at lane launch (t = 0, before Q_lane_{j,l} deletion — zero pre-broadcast hash cycle!):
- Launch-Time Lane Anchor
(h_lane_init, H_init, D_init): Pins an already-confirmed Bitcoin mainnet block at lane creation, together with its 2,016-block retarget-period start header andmtpWindow[11]. - Full 2,016-Block Retargeting & Difficulty Floor: $\mathcal{F}$ validates every 80-byte Bitcoin header from
h_lane_inittoh_tipwith exact mainnetSetCompact,[302400, 4838400]s 2,016-block retarget clamping, MTP monotonicity, and a normative difficulty-drop floorD(h) >= 0.50 * D(h_lane_init).- Explicit Difficulty-Growth Disclosure: If mainnet difficulty grows
> 2×during a finite lane's active lifetime, the effective private-fork difficulty ratioα_diff = D(h_lane_init) / D_currenttightens proportionally (e.g., at3×growth,α_diff = 0.33, increasing requiredKby1.5×). Operators periodically retire old lanes (RetireStakeTxat1,440blocks) and launch fresh lanes re-anchored to currentD(h_lane_init).
- Explicit Difficulty-Growth Disclosure: If mainnet difficulty grows
- Halving-Indexed TVL-Scaled
KPrivate-Fork Inequality: To make a private PoW fork forging a fakeK-deep state strictly unprofitable against honest mining opportunity cost, protocol TVL caps MUST satisfy: $$0.50 \times K \times \text{Subsidy}(\text{era}) > \text{Cap}_{\text{TVL}}$$
| Deployment Stage | Cap_TVL | K (2024–2028, 3.125 BTC Subsidy) | 0.50 × K × Subsidy | K (2028–2032, 1.5625 BTC Subsidy) | K (2032–2036, 0.78125 BTC Subsidy) |
|---|---|---|---|---|---|
Stage 1A Pilot (M = 3) | <= 10 BTC | 14 (~2.3h) | 21.875 BTC > 10 | 14 (10.94 > 10) | 28 (10.94 > 10) |
Stage 1A Expanded (M = 5) | <= 15 BTC | 14 (~2.3h) | 21.875 BTC > 15 | 20 (15.63 > 15) | 40 (15.63 > 15) |
Stage 2 Scaled (M = 10–20) | <= 50 BTC | 36 (~6.0h) | 56.250 BTC > 50 | 66 (51.56 > 50) | 130 (50.78 > 50) |
Stage 2 High-Cap (M = 20+) | <= 200 BTC | 144 (~24h) | 225.000 BTC > 200 | 260 (203.13 > 200) | 516 (201.56 > 200) |
5. Mandatory SPV & Authorization Domain Conformance Test Vectors
- Stage 0 Header & Merkle Suite: All 24 Bitcoin header, 2,016-block retarget (
[302400, 4838400]s), MTP,futureTimeGuardSecs = 7,200,LOWEST_BLOCK_HASH_BEtie-break,CVE-2012-2459, andCVE-2017-12842(len == 64rejection) vectors. - 1- and 2-Block Coinbase Midstate Suite: Valid coinbase proofs for BOTH
totalCoinbaseBytes % 64 ∈ [0, 55](1-block) ANDtotalCoinbaseBytes % 64 ∈ [56, 63](2-block — e.g.120 B,127 B,250 B), plus rejection oflen(finalChunkTail) != totalCoinbaseBytes % 64andtotalCoinbaseBytes == 64. - Panic-Free & Plasma-Floor Fuzz Gate (
B1,B2): Malformed ABI inputs across all 4 Stage 0 oracle methods MUST return deterministic errors (zero panics, zero FIFO sequencer stalls), and exact ABI sizing ofProveTxInclusion(7,620 B,591,388Plasma) fits>= 3×inside the2,100,000floor and<= 40contract blocks/Momentum. - Stage 1A Stripped-Block & Tag-Ordering Suite: Deterministic skip of malformed
0x02 BATCH_DA, rejection of competing second0x02batch (49% Zenon fork simulation), mandatory inclusion of0x03/0x01even when all Zenon sequencers censor, and halving-indexedKPoW boundary enforcement across2024–2036.
Attack this spec & submit feedback
This is a Public RFC updated to v2 (v3.1.0-rfc) in response to Consolidated Hostile Review R8 (redlining against archived v1 / v3.0.0-rfc). Humans and AI review agents are invited to run python3 -I scripts/verify_spec_bounds.py, inspect the v1 → v2 changelog & redlines, file findings, or open pull requests.