@mikeargento/bitgraph-verify 1.13.1 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,247 @@
1
+ // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
+ /**
3
+ * A ceiling in TIME for a BitGraph, carried beside the proof, never inside it.
4
+ *
5
+ * Every BitGraph already has a floor in time (the Ethereum block fused in at
6
+ * slot allocation, `commit.slotAnchor`) and a ceiling in POSITION (the
7
+ * anchors that follow it in the chain). This adds the one thing a record
8
+ * cannot supply for itself: something outside the operator's control that
9
+ * depends on the record. After a commit, a writer puts a Merkle root over
10
+ * record hashes into a Base transaction. The block that includes it proves
11
+ * every record under that root existed by the block's timestamp.
12
+ *
13
+ * The sidecar (`bitgraph-ceiling/1`) is unsigned and trusted for nothing. Every
14
+ * value it states is recomputed here from bytes bound to a hash:
15
+ *
16
+ * proof ─computeProofHash→ leaf ─merklePath→ root
17
+ * root == payload.root, payload == tx.data, tx signed by the writer
18
+ * tx ─MPT proof→ header.transactionsRoot, keccak(header) == blockHash
19
+ * blockTimestamp read from the header, not from the sidecar's own field
20
+ *
21
+ * What stays OUTSIDE this function, and is reported, not assumed:
22
+ * - whether that header is really a Base block (check it against any Base
23
+ * RPC; see checkCeilingOnline), and
24
+ * - who the writer is (the caller names the address it trusts; BitGraph
25
+ * publishes its own on bitgraph.ing).
26
+ */
27
+ import { sha256 } from "@noble/hashes/sha256";
28
+ import { verifyProofIntegrity, createVerificationContext } from "./verifier.js";
29
+ import { computeProofHash } from "./proof-hash.js";
30
+ import { merkleLeafHash, merkleRootFromPath } from "./fuse-merkle.js";
31
+ import { base64ToBytes } from "./fuse.js";
32
+ import { bytesEqual, bytesToHex, decodeEip1559, decodeHeader, hexToBytes, keccak256, mptVerify, txTrieKey, } from "./ceiling-evm.js";
33
+ export const CEILING_VERSION = "bitgraph-ceiling/1";
34
+ export const CEILING_MAGIC = "BGC1";
35
+ export const CEILING_PAYLOAD_BYTES = 84;
36
+ export function encodeCeilingPayload(p) {
37
+ if (p.root.length !== 32 || p.prev.length !== 32)
38
+ throw new TypeError("root and prev are 32 bytes");
39
+ const out = new Uint8Array(CEILING_PAYLOAD_BYTES);
40
+ out.set(new TextEncoder().encode(CEILING_MAGIC), 0);
41
+ out.set(p.root, 4);
42
+ out.set(p.prev, 36);
43
+ const view = new DataView(out.buffer);
44
+ view.setBigUint64(68, p.firstPos);
45
+ view.setBigUint64(76, p.lastPos);
46
+ return out;
47
+ }
48
+ export function decodeCeilingPayload(bytes) {
49
+ if (bytes.length !== CEILING_PAYLOAD_BYTES)
50
+ throw new TypeError(`payload is ${bytes.length} bytes, expected ${CEILING_PAYLOAD_BYTES}`);
51
+ const magic = new TextDecoder().decode(bytes.slice(0, 4));
52
+ if (magic !== CEILING_MAGIC)
53
+ throw new TypeError(`payload magic is ${JSON.stringify(magic)}, expected ${CEILING_MAGIC}`);
54
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
55
+ return {
56
+ root: bytes.slice(4, 36),
57
+ prev: bytes.slice(36, 68),
58
+ firstPos: view.getBigUint64(68),
59
+ lastPos: view.getBigUint64(76),
60
+ };
61
+ }
62
+ /** SHA-256 of a payload: the next payload's `prev`, so the anchors chain. */
63
+ export function ceilingPayloadHash(payload) {
64
+ return sha256(payload);
65
+ }
66
+ /** The leaf hash of one record: SHA256(0x00 || proofHash bytes). */
67
+ export function ceilingLeaf(proofHashB64) {
68
+ const raw = base64ToBytes(proofHashB64);
69
+ if (!raw || raw.length !== 32)
70
+ throw new TypeError("proofHash must decode to 32 bytes");
71
+ return merkleLeafHash(raw);
72
+ }
73
+ function hhmmss(unix) {
74
+ return new Date(unix * 1000).toISOString().slice(11, 19);
75
+ }
76
+ export function ceilingLabel(status, blockNumber, blockTimestamp) {
77
+ const at = `Base block ${blockNumber.toLocaleString("en-US")} at ${hhmmss(blockTimestamp)} UTC`;
78
+ if (status === "safe" || status === "finalized")
79
+ return `Ceiling: ${at}, settled on Ethereum.`;
80
+ return `Ceiling: ${at}. Relies on Base's sequencer until settled on Ethereum.`;
81
+ }
82
+ /**
83
+ * Check a ceiling sidecar against its proof, offline. Every check runs and
84
+ * is reported; the first failure is the `reason`.
85
+ */
86
+ export async function verifyCeiling(proof, sidecar, opts) {
87
+ const checks = [];
88
+ const fail = (name, detail) => {
89
+ checks.push({ name, ok: false, detail });
90
+ return { ok: false, reason: `${name}: ${detail}`, checks, headerCheckedAgainstChain: false };
91
+ };
92
+ const pass = (name, detail) => checks.push(detail === undefined ? { name, ok: true } : { name, ok: true, detail });
93
+ if (sidecar?.version !== CEILING_VERSION)
94
+ return fail("format", `not a ${CEILING_VERSION} sidecar`);
95
+ // 0. The proof itself. The leaf covers the signed-body SUBSET (proofHash);
96
+ // the signature covers the rest, so an altered actor/policy fails here.
97
+ if (!opts.proofAlreadyVerified) {
98
+ const v = await verifyProofIntegrity({
99
+ proof,
100
+ context: createVerificationContext(),
101
+ ...(opts.trustAnchors ? { trustAnchors: opts.trustAnchors } : {}),
102
+ });
103
+ if (!v.valid)
104
+ return fail("proof", `the proof does not verify (${v.reason ?? "invalid"})`);
105
+ pass("proof", "signature valid");
106
+ }
107
+ // 1. The record is under the root.
108
+ let proofHash;
109
+ try {
110
+ proofHash = computeProofHash(proof);
111
+ }
112
+ catch (e) {
113
+ return fail("record", `cannot hash the proof (${e.message})`);
114
+ }
115
+ if (proofHash !== sidecar.proofHash)
116
+ return fail("record", "this sidecar belongs to a different proof");
117
+ let computedRoot;
118
+ try {
119
+ computedRoot = merkleRootFromPath(ceilingLeaf(proofHash), sidecar.leafIndex, sidecar.leafCount, sidecar.merklePath.map(hexToBytes));
120
+ }
121
+ catch {
122
+ computedRoot = null;
123
+ }
124
+ if (!computedRoot)
125
+ return fail("merkle", "the path does not fit the leaf index and tree size");
126
+ if (bytesToHex(computedRoot) !== sidecar.root.toLowerCase())
127
+ return fail("merkle", "the leaf and path do not reach the root");
128
+ pass("merkle", `leaf ${sidecar.leafIndex} of ${sidecar.leafCount} reaches the root`);
129
+ if (sidecar.status === "pending" || !sidecar.anchor) {
130
+ return { ok: false, reason: "ceiling pending: no transaction included yet", checks, status: "pending", headerCheckedAgainstChain: false };
131
+ }
132
+ const a = sidecar.anchor;
133
+ // 2. The payload carries that root.
134
+ let payloadBytes;
135
+ try {
136
+ payloadBytes = hexToBytes(a.payload);
137
+ const p = decodeCeilingPayload(payloadBytes);
138
+ if (bytesToHex(p.root) !== sidecar.root.toLowerCase())
139
+ return fail("payload", "the payload's root is not this sidecar's root");
140
+ pass("payload", `${CEILING_MAGIC}, positions ${p.firstPos}-${p.lastPos}`);
141
+ }
142
+ catch (e) {
143
+ return fail("payload", e.message);
144
+ }
145
+ // 3. The transaction: signed by the writer, to itself, carrying the payload.
146
+ let rawTx;
147
+ try {
148
+ rawTx = hexToBytes(a.rawTx);
149
+ const tx = decodeEip1559(rawTx);
150
+ const writer = opts.writerAddress.toLowerCase();
151
+ if (tx.from !== writer)
152
+ return fail("sender", `the transaction was signed by ${tx.from}, not the declared writer ${writer}`);
153
+ if (tx.to !== writer)
154
+ return fail("sender", `the transaction is addressed to ${tx.to ?? "a contract creation"}, not to the writer`);
155
+ if (tx.chainId !== BigInt(opts.chainId))
156
+ return fail("chain", `the transaction is for chain ${tx.chainId}, expected ${opts.chainId}`);
157
+ if (a.chainId !== opts.chainId)
158
+ return fail("chain", `the sidecar names chain ${a.chainId}, expected ${opts.chainId}`);
159
+ if (!bytesEqual(tx.data, payloadBytes))
160
+ return fail("payload", "the transaction's data is not the payload");
161
+ if (tx.hash !== a.txHash.toLowerCase())
162
+ return fail("transaction", "the raw transaction does not hash to txHash");
163
+ pass("sender", `signed by ${tx.from}`);
164
+ }
165
+ catch (e) {
166
+ return fail("transaction", e.message);
167
+ }
168
+ // 4. The transaction is in the block, and the block is this header.
169
+ let header;
170
+ try {
171
+ header = decodeHeader(hexToBytes(a.blockHeader));
172
+ }
173
+ catch (e) {
174
+ return fail("header", e.message);
175
+ }
176
+ if (header.hash !== a.blockHash.toLowerCase())
177
+ return fail("header", "the header does not hash to blockHash");
178
+ if (header.number !== a.blockNumber)
179
+ return fail("header", `the header is block ${header.number}, the sidecar says ${a.blockNumber}`);
180
+ if (header.timestamp !== a.blockTimestamp)
181
+ return fail("header", `the header's timestamp is ${header.timestamp}, the sidecar says ${a.blockTimestamp}`);
182
+ const inBlock = mptVerify(hexToBytes(header.transactionsRoot), txTrieKey(a.txIndex), a.txInclusionProof.map(hexToBytes));
183
+ if (!inBlock || !bytesEqual(inBlock, rawTx))
184
+ return fail("inclusion", "the transaction is not in this block");
185
+ pass("inclusion", `transaction ${a.txIndex} of block ${header.number}`);
186
+ // 5. The window. The floor is the proof's own signed slotAnchor.
187
+ const slotAnchor = proof.commit.slotAnchor;
188
+ let floor = null;
189
+ if (slotAnchor) {
190
+ floor = { blockNumber: slotAnchor.blockNumber, blockHash: slotAnchor.blockHash, blockTimestamp: null };
191
+ const w = sidecar.floor;
192
+ if (w && w.blockHeader) {
193
+ try {
194
+ const fh = decodeHeader(hexToBytes(w.blockHeader));
195
+ if (fh.hash === slotAnchor.blockHash.toLowerCase() && fh.number === slotAnchor.blockNumber) {
196
+ floor.blockTimestamp = fh.timestamp;
197
+ pass("floor", `Ethereum block ${fh.number}, header checked against the signed hash`);
198
+ }
199
+ else {
200
+ checks.push({ name: "floor", ok: false, detail: "the carried floor header does not match the proof's signed slotAnchor; ignored" });
201
+ }
202
+ }
203
+ catch {
204
+ checks.push({ name: "floor", ok: false, detail: "the carried floor header does not decode; ignored" });
205
+ }
206
+ }
207
+ }
208
+ const width = floor?.blockTimestamp != null ? header.timestamp - floor.blockTimestamp : null;
209
+ const status = sidecar.status;
210
+ return {
211
+ ok: true,
212
+ checks,
213
+ status,
214
+ window: {
215
+ floor: floor ?? { blockNumber: 0, blockHash: "", blockTimestamp: null },
216
+ ceiling: { chainId: a.chainId, blockNumber: header.number, blockHash: header.hash, blockTimestamp: header.timestamp },
217
+ widthSeconds: width,
218
+ },
219
+ label: ceilingLabel(status, header.number, header.timestamp),
220
+ headerCheckedAgainstChain: false,
221
+ };
222
+ }
223
+ /**
224
+ * Ask a Base node whether the sidecar's block is on the chain. Returns a
225
+ * finding, never throws. Online is the only way to learn canonicality.
226
+ *
227
+ * The package makes no network calls of its own (the audit's zero-network
228
+ * guarantee covers it), so the caller supplies the one lookup:
229
+ * `getBlockHash(n)` returns the chain's hash at height n, or null.
230
+ */
231
+ export async function checkCeilingOnline(sidecar, getBlockHash) {
232
+ if (!sidecar.anchor)
233
+ return { onChain: null, detail: "no anchor to check" };
234
+ try {
235
+ const hash = (await getBlockHash(sidecar.anchor.blockNumber))?.toLowerCase();
236
+ if (!hash)
237
+ return { onChain: null, detail: "the RPC did not return that block" };
238
+ if (hash === sidecar.anchor.blockHash.toLowerCase())
239
+ return { onChain: true, detail: `block ${sidecar.anchor.blockNumber} matches the chain` };
240
+ return { onChain: false, detail: `the chain's block ${sidecar.anchor.blockNumber} is ${hash}, not this header` };
241
+ }
242
+ catch (e) {
243
+ return { onChain: null, detail: `header not checked against chain (${e.message})` };
244
+ }
245
+ }
246
+ export { keccak256 as ceilingKeccak256 };
247
+ //# sourceMappingURL=ceiling.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ceiling.js","sourceRoot":"","sources":["../src/ceiling.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,UAAU,E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export type { CarrierWitness, CarrierProof, CarrierFloor, CarrierCeiling, CarrierPayload, CarrierParse, WitnessCheck, CarrierBounds, } from "./carrier.js";
26
26
  export { verifyCarrier } from "./carrier-verify.js";
27
27
  export type { CarrierVerifyResult } from "./carrier-verify.js";
28
+ export { CEILING_VERSION, CEILING_MAGIC, CEILING_PAYLOAD_BYTES, encodeCeilingPayload, decodeCeilingPayload, ceilingPayloadHash, ceilingLeaf, ceilingLabel, verifyCeiling, checkCeilingOnline, } from "./ceiling.js";
29
+ export type { CeilingSidecar, CeilingStatus, CeilingPayload, CeilingCheck, CeilingVerifyResult, CeilingVerifyOptions } from "./ceiling.js";
30
+ export { rlpEncode, rlpDecode, decodeHeader, decodeEip1559, mptVerify, txTrieKey, keccak256, hexToBytes as evmHexToBytes, bytesToHex as evmBytesToHex } from "./ceiling-evm.js";
31
+ export { txTrieProof } from "./ceiling-trie.js";
32
+ export type { RlpItem, DecodedHeader, DecodedTx } from "./ceiling-evm.js";
28
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,KAAK,UAAU,EACf,KAAK,UAAU,GAChB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC7G,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE7F,OAAO,EAAE,gBAAgB,EAAE,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AAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EACzF,UAAU,IAAI,aAAa,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
package/dist/index.js CHANGED
@@ -24,4 +24,8 @@ export { ENCODING_BASE64URL, isCarryEncoding, findCommitment, inlineAttribution
24
24
  /* bitgraph-carrier/1: the file that carries its own proof (2026-09-24). */
25
25
  export { CARRIER_MAGIC, CARRIER_OVERHEAD, MAX_CARRIER_PAYLOAD, CARRIER_VERSION, encodeCarrierBlock, buildCarrier, parseCarrier, completeCarrier, anchorIdentity, checkFloorBinding, checkCeilingBinding, anchorMessageBytes, decodeRlpTop, verifyWitnessHeader, carrierBounds, innerDigestMatches, sameDigest, b64ToBytes, bytesToB64, } from "./carrier.js";
26
26
  export { verifyCarrier } from "./carrier-verify.js";
27
+ // Ceiling in time on Base (bitgraph-ceiling/1): a sidecar beside the proof, never inside it.
28
+ export { CEILING_VERSION, CEILING_MAGIC, CEILING_PAYLOAD_BYTES, encodeCeilingPayload, decodeCeilingPayload, ceilingPayloadHash, ceilingLeaf, ceilingLabel, verifyCeiling, checkCeilingOnline, } from "./ceiling.js";
29
+ export { rlpEncode, rlpDecode, decodeHeader, decodeEip1559, mptVerify, txTrieKey, keccak256, hexToBytes as evmHexToBytes, bytesToHex as evmBytesToHex } from "./ceiling-evm.js";
30
+ export { txTrieProof } from "./ceiling-trie.js";
27
31
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;GAMG;AAEH,OAAO,EACL,uBAAuB,EACvB,YAA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kBAAkB,GAClC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EACzF,UAAU,IAAI,aAAa,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeargento/bitgraph-verify",
3
- "version": "1.13.1",
3
+ "version": "1.14.0",
4
4
  "description": "Offline verification of BitGraph proofs. Permissionless by design.",
5
5
  "keywords": [
6
6
  "bitgraph",
@@ -38,6 +38,7 @@
38
38
  "node": ">=20"
39
39
  },
40
40
  "dependencies": {
41
+ "@noble/curves": "^2.3.0",
41
42
  "@noble/ed25519": "^2.1.0",
42
43
  "@noble/hashes": "^1.4.0"
43
44
  },
@@ -0,0 +1,281 @@
1
+ /**
2
+ * bitgraph-ceiling/1: the offline verifier against a synthetic Base block
3
+ * built here from scratch (a real production proof, a transaction signed with
4
+ * a throwaway key, a header whose transactionsRoot is the rebuilt trie), and
5
+ * every adversarial case the build prompt lists. Nothing touches a network.
6
+ */
7
+
8
+ import { test } from "node:test";
9
+ import * as assert from "node:assert/strict";
10
+ import { readFileSync } from "node:fs";
11
+ import { secp256k1 } from "@noble/curves/secp256k1.js";
12
+ import { sha256 } from "@noble/hashes/sha256";
13
+ import { computeProofHash } from "../proof-hash.js";
14
+ import { MerkleTree, merkleLeafHash } from "../fuse-merkle.js";
15
+ import {
16
+ CEILING_VERSION, ceilingLeaf, ceilingPayloadHash, decodeCeilingPayload, encodeCeilingPayload, verifyCeiling,
17
+ type CeilingSidecar,
18
+ } from "../ceiling.js";
19
+ import { bytesToHex, hexToBytes, keccak256, rlpDecode, rlpEncode, decodeEip1559, type RlpItem } from "../ceiling-evm.js";
20
+ import { txTrieProof } from "../ceiling-trie.js";
21
+ import type { BitGraphProof } from "../types.js";
22
+
23
+ const fix = (dir: string, name: string): string => readFileSync(new URL(`../../src/__tests__/fixtures/${dir}/${name}`, import.meta.url), "utf8");
24
+ const proof = JSON.parse(fix("carrier", "demo2.proof.json")) as BitGraphProof;
25
+ const floorHeader = fix("ceiling", "floor-26037892.header.hex").trim();
26
+ const CHAIN = 84532;
27
+
28
+ function u(n: bigint | number): Uint8Array {
29
+ let h = BigInt(n).toString(16);
30
+ if (h === "0") return new Uint8Array(0);
31
+ if (h.length % 2) h = "0" + h;
32
+ return hexToBytes(h);
33
+ }
34
+
35
+ function addressOf(priv: Uint8Array): string {
36
+ return bytesToHex(keccak256(secp256k1.getPublicKey(priv, false).slice(1)).slice(12));
37
+ }
38
+
39
+ function signTx(priv: Uint8Array, opts: { to: string; data: Uint8Array; chainId?: number; nonce?: number }): Uint8Array {
40
+ const fields: RlpItem[] = [
41
+ u(opts.chainId ?? CHAIN), u(opts.nonce ?? 0), u(1_000_000), u(2_000_000_000), u(30_000),
42
+ hexToBytes(opts.to), u(0), opts.data, [],
43
+ ];
44
+ const hash = keccak256(new Uint8Array([0x02, ...rlpEncode(fields)]));
45
+ const sig = secp256k1.sign(hash, priv, { prehash: false, format: "recovered" });
46
+ const rec = sig[0]!;
47
+ const r = BigInt(bytesToHex(sig.slice(1, 33)));
48
+ const s = BigInt(bytesToHex(sig.slice(33, 65)));
49
+ return new Uint8Array([0x02, ...rlpEncode([...fields, u(rec), u(r), u(s)])]);
50
+ }
51
+
52
+ function header(txRoot: Uint8Array, number: number, timestamp: number): Uint8Array {
53
+ const z32 = new Uint8Array(32);
54
+ return rlpEncode([
55
+ z32, z32, new Uint8Array(20), z32, txRoot, z32, new Uint8Array(256), u(0), u(number), u(30_000_000),
56
+ u(21_000), u(timestamp), new Uint8Array(0), z32, new Uint8Array(8), u(1000),
57
+ ]);
58
+ }
59
+
60
+ interface World { sidecar: CeilingSidecar; writer: string; priv: Uint8Array }
61
+
62
+ /** Build a complete, valid world; `tweak` edits the ingredients before anything is hashed. */
63
+ function build(tweak: { data?: (p: Uint8Array) => Uint8Array; signer?: Uint8Array; to?: string; chainId?: number } = {}): World {
64
+ const priv = secp256k1.utils.randomSecretKey();
65
+ const writer = addressOf(priv);
66
+ const proofHash = computeProofHash(proof);
67
+ const others = [1, 2, 3, 4].map((i) => merkleLeafHash(sha256(new Uint8Array([i]))));
68
+ const leaves = [others[0]!, others[1]!, ceilingLeaf(proofHash), others[2]!, others[3]!];
69
+ const tree = new MerkleTree(leaves);
70
+ let payload = encodeCeilingPayload({ root: tree.root, prev: new Uint8Array(32), firstPos: 2870n, lastPos: 2880n });
71
+ if (tweak.data) payload = tweak.data(payload);
72
+ const raw = signTx(tweak.signer ?? priv, { to: tweak.to ?? writer, data: payload, ...(tweak.chainId ? { chainId: tweak.chainId } : {}) });
73
+ const block = [hexToBytes("0x7e0102"), hexToBytes("0x02c0ffee"), raw, hexToBytes("0x01aabbcc")];
74
+ const txIndex = 2;
75
+ const { root: txRoot, proof: inclusion } = txTrieProof(block, txIndex);
76
+ const ts = 1_790_000_000;
77
+ const hdr = header(txRoot, 30_000_000, ts);
78
+ const fh = rlpDecode(hexToBytes(floorHeader)) as Uint8Array[];
79
+ const floorTs = Number(BigInt(bytesToHex(fh[11]!)));
80
+ const sidecar: CeilingSidecar = {
81
+ version: CEILING_VERSION,
82
+ proofHash,
83
+ leafIndex: 2,
84
+ leafCount: 5,
85
+ merklePath: tree.path(2).map(bytesToHex),
86
+ root: bytesToHex(tree.root),
87
+ anchor: {
88
+ chainId: CHAIN,
89
+ writer,
90
+ txHash: bytesToHex(keccak256(raw)),
91
+ rawTx: bytesToHex(raw),
92
+ payload: bytesToHex(payload),
93
+ blockNumber: 30_000_000,
94
+ blockHash: bytesToHex(keccak256(hdr)),
95
+ blockTimestamp: ts,
96
+ blockHeader: bytesToHex(hdr),
97
+ txIndex,
98
+ txInclusionProof: inclusion.map(bytesToHex),
99
+ },
100
+ status: "included",
101
+ statusObserved: { included: "2026-09-29T00:00:00.000Z", safe: null, finalized: null },
102
+ floor: { blockNumber: 26037892, blockHash: proof.commit.slotAnchor!.blockHash, blockTimestamp: floorTs, blockHeader: floorHeader },
103
+ settlement: null,
104
+ };
105
+ return { sidecar, writer, priv };
106
+ }
107
+
108
+ const clone = <T>(x: T): T => JSON.parse(JSON.stringify(x)) as T;
109
+
110
+ test("payload round-trips and chains", () => {
111
+ const root = sha256(new Uint8Array([1]));
112
+ const p = encodeCeilingPayload({ root, prev: new Uint8Array(32), firstPos: 7n, lastPos: 2n ** 63n });
113
+ assert.equal(p.length, 84);
114
+ assert.equal(new TextDecoder().decode(p.slice(0, 4)), "BGC1");
115
+ const d = decodeCeilingPayload(p);
116
+ assert.deepEqual(d.root, root);
117
+ assert.equal(d.lastPos, 2n ** 63n);
118
+ assert.equal(ceilingPayloadHash(p).length, 32);
119
+ });
120
+
121
+ test("a single-record batch's root is its leaf hash", () => {
122
+ const leaf = ceilingLeaf(computeProofHash(proof));
123
+ assert.deepEqual(new MerkleTree([leaf]).root, leaf);
124
+ });
125
+
126
+ test("tx decoder recovers the signer", () => {
127
+ const priv = secp256k1.utils.randomSecretKey();
128
+ const raw = signTx(priv, { to: addressOf(priv), data: new Uint8Array(84) });
129
+ assert.equal(decodeEip1559(raw).from, addressOf(priv));
130
+ });
131
+
132
+ test("a valid sidecar verifies and reports the window", async () => {
133
+ const { sidecar, writer } = build();
134
+ const r = await verifyCeiling(proof, sidecar, { writerAddress: writer, chainId: CHAIN });
135
+ assert.equal(r.ok, true, r.reason);
136
+ assert.equal(r.window!.ceiling.blockNumber, 30_000_000);
137
+ assert.equal(r.window!.floor.blockNumber, 26037892);
138
+ assert.ok(r.window!.floor.blockTimestamp! > 0);
139
+ assert.equal(r.window!.widthSeconds, 1_790_000_000 - r.window!.floor.blockTimestamp!);
140
+ assert.match(r.label!, /Relies on Base's sequencer until settled on Ethereum\.$/);
141
+ assert.equal(r.headerCheckedAgainstChain, false);
142
+ });
143
+
144
+ test("at safe the label says settled", async () => {
145
+ const { sidecar, writer } = build();
146
+ sidecar.status = "safe";
147
+ const r = await verifyCeiling(proof, sidecar, { writerAddress: writer, chainId: CHAIN });
148
+ assert.match(r.label!, /settled on Ethereum\.$/);
149
+ assert.doesNotMatch(r.label!, /Relies/);
150
+ });
151
+
152
+ test("pending says pending, never a ceiling", async () => {
153
+ const { sidecar, writer } = build();
154
+ sidecar.status = "pending";
155
+ sidecar.anchor = null;
156
+ const r = await verifyCeiling(proof, sidecar, { writerAddress: writer, chainId: CHAIN });
157
+ assert.equal(r.ok, false);
158
+ assert.match(r.reason!, /ceiling pending/);
159
+ assert.equal(r.window, undefined);
160
+ });
161
+
162
+ // ── adversarial fixtures ──
163
+
164
+ const rejects = async (name: string, mk: () => { sidecar: CeilingSidecar; writer: string; p?: BitGraphProof }, re: RegExp) =>
165
+ test(`rejects: ${name}`, async () => {
166
+ const { sidecar, writer, p } = mk();
167
+ const r = await verifyCeiling(p ?? proof, sidecar, { writerAddress: writer, chainId: CHAIN });
168
+ assert.equal(r.ok, false, `accepted: ${name}`);
169
+ assert.match(r.reason!, re);
170
+ });
171
+
172
+ await rejects("wrong sender", () => {
173
+ const other = secp256k1.utils.randomSecretKey();
174
+ const w = build({ signer: other });
175
+ return { sidecar: w.sidecar, writer: w.writer };
176
+ }, /^sender: .*not the declared writer/);
177
+
178
+ await rejects("declared writer is someone else", () => {
179
+ const w = build();
180
+ return { sidecar: w.sidecar, writer: "0x" + "11".repeat(20) };
181
+ }, /^sender:/);
182
+
183
+ await rejects("not addressed to the writer", () => {
184
+ const w = build({ to: "0x" + "22".repeat(20) });
185
+ return { sidecar: w.sidecar, writer: w.writer };
186
+ }, /^sender: .*addressed to/);
187
+
188
+ await rejects("altered root (sidecar)", () => {
189
+ const w = build();
190
+ const s = clone(w.sidecar);
191
+ s.root = "0x" + "ab".repeat(32);
192
+ return { sidecar: s, writer: w.writer };
193
+ }, /^merkle:/);
194
+
195
+ await rejects("altered root (payload, re-signed by the writer)", () => {
196
+ const w = build({ data: (p) => { const q = p.slice(); q[10] = q[10]! ^ 1; return q; } });
197
+ return { sidecar: w.sidecar, writer: w.writer };
198
+ }, /^payload: .*root/);
199
+
200
+ await rejects("leaf not in the tree", () => {
201
+ const w = build();
202
+ const s = clone(w.sidecar);
203
+ s.leafIndex = 3;
204
+ return { sidecar: s, writer: w.writer };
205
+ }, /^merkle:/);
206
+
207
+ await rejects("tampered block header", () => {
208
+ const w = build();
209
+ const s = clone(w.sidecar);
210
+ const h = hexToBytes(s.anchor!.blockHeader);
211
+ h[h.length - 3] = h[h.length - 3]! ^ 1;
212
+ s.anchor!.blockHeader = bytesToHex(h);
213
+ return { sidecar: s, writer: w.writer };
214
+ }, /^header:/);
215
+
216
+ await rejects("tampered timestamp (sidecar field)", () => {
217
+ const w = build();
218
+ const s = clone(w.sidecar);
219
+ s.anchor!.blockTimestamp -= 3600;
220
+ return { sidecar: s, writer: w.writer };
221
+ }, /^header: .*timestamp/);
222
+
223
+ await rejects("transaction not in the block", () => {
224
+ const w = build();
225
+ const s = clone(w.sidecar);
226
+ s.anchor!.txIndex = 1;
227
+ return { sidecar: s, writer: w.writer };
228
+ }, /^inclusion:/);
229
+
230
+ await rejects("inclusion proof from another block", () => {
231
+ const w1 = build();
232
+ const w2 = build();
233
+ const s = clone(w1.sidecar);
234
+ s.anchor!.txInclusionProof = w2.sidecar.anchor!.txInclusionProof;
235
+ return { sidecar: s, writer: w1.writer };
236
+ }, /^inclusion:/);
237
+
238
+ await rejects("wrong magic", () => {
239
+ const w = build({ data: (p) => { const q = p.slice(); q.set(new TextEncoder().encode("BGC2"), 0); return q; } });
240
+ return { sidecar: w.sidecar, writer: w.writer };
241
+ }, /^payload: .*magic/);
242
+
243
+ await rejects("sidecar belonging to a different proof", () => {
244
+ const w = build();
245
+ const other = clone(proof);
246
+ other.commit.counter = "9999";
247
+ return { sidecar: w.sidecar, writer: w.writer, p: other };
248
+ }, /^(proof|record):/);
249
+
250
+ await rejects("wrong chain", () => {
251
+ const w = build({ chainId: 8453 });
252
+ return { sidecar: w.sidecar, writer: w.writer };
253
+ }, /^chain:/);
254
+
255
+ test("a rebuilt header with a moved timestamp passes offline and says it was not checked against the chain", async () => {
256
+ const w = build();
257
+ const s = clone(w.sidecar);
258
+ const f = rlpDecode(hexToBytes(s.anchor!.blockHeader)) as Uint8Array[];
259
+ // A fabricated header must still commit to the real transactionsRoot to pass;
260
+ // moving the timestamp changes the hash, which only a Base RPC can refute.
261
+ f[11] = u(1_700_000_000);
262
+ const h = rlpEncode(f);
263
+ s.anchor!.blockHeader = bytesToHex(h);
264
+ s.anchor!.blockHash = bytesToHex(keccak256(h));
265
+ s.anchor!.blockTimestamp = 1_700_000_000;
266
+ const r = await verifyCeiling(proof, s, { writerAddress: w.writer, chainId: CHAIN });
267
+ assert.equal(r.ok, true);
268
+ assert.equal(r.headerCheckedAgainstChain, false);
269
+ });
270
+
271
+ test("a floor header that is not the proof's signed floor is ignored, not trusted", async () => {
272
+ const w = build();
273
+ const s = clone(w.sidecar);
274
+ const f = rlpDecode(hexToBytes(s.floor!.blockHeader)) as Uint8Array[];
275
+ f[11] = u(1);
276
+ s.floor!.blockHeader = bytesToHex(rlpEncode(f));
277
+ const r = await verifyCeiling(proof, s, { writerAddress: w.writer, chainId: CHAIN });
278
+ assert.equal(r.ok, true);
279
+ assert.equal(r.window!.floor.blockTimestamp, null);
280
+ assert.equal(r.window!.widthSeconds, null);
281
+ });
@@ -0,0 +1 @@
1
+ 0xf90288a0f396f38b1017e090d170aaae44f3a255e5f586a440255efb580ef3dea39fc412a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d4934794fb74767c1ce1aada0a0e114441173b57f8c1571ba02cfc5dc7610c9e12d65abced5530205512f445b0099fc91e417b6c41f9e8dd37a0d01f738cc5ae57069b70b1f3165f5dbbc9d4cb7c88515c5ba2cba48891889f02a0ae9906da1f31c01741b24d1a27b0d2acab04d466accb7d17a83977df3e2501e3b90100fba35df1e43d35bb3e731cb7edf55b7bf7fc38da3cd39bd11edbb7724e315db6f8db23b4ea5e6b1ce3b4f3c39a76c1bd43afef2eef53ee9377a3f3a5ed7c7dbbfe8c8baa27df3ba8e8a95f1dd975d775fbbda5097bf4cfebbddbb97faf761c464ff7fcffe75e4b10d9a2fc40c60bb967bbb3dc3bffd0dede16c375fe07ff5df7df79bffb51e6e16e737d7f2b27374afec82dbcb177abefdca5f9fcd9fc3c7e66af2339ebfebbf6cb3b5900d1bf29dee8ad6cb1052faca88f9167575b2fc55f75cefd3f523e7ee8f37d6dfdfa9173af963a9ee8c7abdb6d74cde5dbb772e0eb5fecfded59bfa8a9168b47fabfc53fffdbf5bdfb3e1efdf6f68f1cbbf592abcdbd8084018d4e8484039386c78401bba2f7846ab359db9a457572656b612028657572656b616275696c6465722e78797a29a0c79fe3fe0de9fbca2e79871c8eb8d40fd7bba7549d9f3790ef9903123e0d57f48800000000000000008438057934a0c03a275fe36467e27558380e7184b479e72ef8490845fc1047d631aef3d479d983120000840c7c2ecfa073e10c3eab2714b9e8ea3da8aedb142a611e49f9c0b6255bdd89c59c8af35637a0e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855