METHOD v2.en

[AiBTC Verification Method v2] All operations are on bytes; canonical_payload and canonical_manifest are original text and must not be reformatted or reordered. 1. Record fingerprint: TAG = SHA256("AIBRC/NetworkEvent/v0.1"); P = the UTF-8 bytes of canonical_payload. event_hash = SHA256(TAG ‖ TAG ‖ the 32 bytes of previous_event_hash ‖ sequence as an 8-byte big-endian integer ‖ the byte length of P as 4 bytes big-endian ‖ P). 2. Manifest scope: accept only AIBRC_CHECKPOINT_MANIFEST_V3, RFC9162_SHA256 and EVENT_HASH_BYTES_V1. Bind networkId, logEpoch, treeSize and treeRoot to the canonical manifest authenticated in steps 3–4. 1 ≤ sequence ≤ treeSize and leafIndex = sequence − 1. eventSeqRange is only the new batch delta, not the lower bound of the global tree. 2a. Inclusion (RFC 9162): L(h)=SHA256(0x00 || hex_decode(h)), P(a,b)=SHA256(0x01 || hex_decode(a) || hex_decode(b)). Use the 32 event-hash bytes, not their ASCII hex. Set fn=leafIndex, sn=treeSize−1, r=L(event_hash). For each auditPath node p in order: reject if sn=0; if fn is odd or fn=sn, set r=P(p,r), then while fn≠0 and fn is even shift fn and sn right by one; otherwise set r=P(r,p). After each node shift both right by one. Accept only if sn=0 and r=treeRoot, with no missing or extra nodes. N=1 has an empty path. The tree splits at the largest power of two strictly below its size; never duplicate an odd final leaf. Tail records use this same proof. 2b. Append-only history: when append_only is supplied, independently authenticate BOTH manifests and their OTS files by steps 3–4, require the same networkId/logEpoch, and bind every consistency field to them. For m=0 use the empty SHA256 root and an empty path; for m=n require equal roots and an empty path. For 0<m<n set fn=m−1,sn=n−1; while fn is odd shift both right. If m is a power of two start fr=sr=oldRoot; otherwise consume the first path node as fr=sr. For each remaining c: reject if sn=0; if fn is odd or fn=sn set fr=P(c,fr), sr=P(c,sr), then while fn≠0 and fn is even shift both right; otherwise sr=P(sr,c). Shift both right after each c. Accept only if sn=0, fr=oldRoot and sr=newRoot and the path is exhausted. Without a prior authenticated head, report inclusion only; do not claim consistency. 2c. Reference verifier download: /proofs/aibrc-merkle-reference-v3.py (Python 3 standard library). It checks record/manifest fingerprints and Merkle relations. Independently complete the OTS/Bitcoin step below. 3. Batch fingerprint: SHA256(the UTF-8 bytes of "AIBRC-CHECKPOINT-V1" ‖ the UTF-8 bytes of canonical_manifest) must equal checkpoint_digest. 4. Bitcoin: the digest committed by the OTS file (OpenTimestamps, base64) must equal checkpoint_digest; run the file's operations up to the Bitcoin block's Merkle root and compare it with the Merkle root of the block at the same height on an independent block explorer (such as mempool.space). 5. Trade recomputation (only when event_type is AMM_SWAP_SETTLED_V2 and formulaVersion is XYK_LAUNCH_ROW_V1; use canonical_payload's data; integer arithmetic, ÷ rounds down, ⌈ ⌉ rounds up, bps = swapFeeBps): Sell: grossOut = btcReserveSatsBefore × amountIn ÷ (tokenReserveAmountBefore + amountIn); feeBtcSats = ⌈grossOut × bps ÷ 10000⌉; amountOut = grossOut − feeBtcSats; btcReserveSatsAfter = btcReserveSatsBefore − grossOut; tokenReserveAmountAfter = tokenReserveAmountBefore + amountIn. Buy: amount paid PAY = amountIn + feeBtcSats (from the record's values), and feeBtcSats must equal ⌈PAY × bps ÷ 10000⌉; amountOut = tokenReserveAmountBefore × amountIn ÷ (btcReserveSatsBefore + amountIn); btcReserveSatsAfter = btcReserveSatsBefore + amountIn; tokenReserveAmountAfter = tokenReserveAmountBefore − amountOut. If a buy carries pricingVersion = CONFIRMED_PLUS_PENDING_BUY_V1 (unconfirmed block buys were pending at the time): pricePendingCount ≥ 1, priceBtcReserveSats = btcReserveSatsBefore + pricePendingBtcSats, and priceTokenReserveAtomic = tokenReserveAmountBefore − pricePendingTokenAtomic must hold; amountOut becomes priceTokenReserveAtomic × amountIn ÷ (priceBtcReserveSats + amountIn); every other formula is unchanged, and the reserves before and after are still computed from btcReserveSatsBefore and tokenReserveAmountBefore. A sell never carries these fields. When feePolicyVersion is R1_GROSS_INCLUSIVE_LP_FEE_V2, the liquidity providers' share: feeVaultBtcSatsAfter − feeVaultBtcSatsBefore = ⌈(grossOut for a sell, PAY for a buy) × 50 ÷ 10000⌉; the rest of the fee is recorded elsewhere, not in this record. Other trade types have no formula in this version; write "not covered". 6. Report each item as: matches / does not match (with the computed value) / material missing / not actually run. material_integrity records the web page's check before copying. 7. Pool reserves recorded in the market ledger after this event: in a LAUNCH_* record the pool holds postRealBtcReserveSats sats of BTC and postTokenReserveAmount tokens in the record's integer units; postVirtualBtcReserveSats and postVirtualTokenReserveAmount are pricing parameters. In an AMM_* record the pool holds btcReserveSatsAfter sats and tokenReserveAmountAfter tokens. A market's current reserve is the after-value of its latest record; the platform-wide liquidity reserve is that value summed over every market. The public API and MCP (list_markets / get_market) report the same two numbers as liquidity.btc_reserve_sats and liquidity.token_reserve, and they must equal the latest record's after-values.