@mikeargento/bitgraph-verify 1.16.0 → 1.17.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.
Files changed (52) hide show
  1. package/README.md +24 -3
  2. package/dist/__tests__/carrier2.test.js +1 -1
  3. package/dist/__tests__/carrier2.test.js.map +1 -1
  4. package/dist/carrier-assemble.d.ts +12 -2
  5. package/dist/carrier-assemble.d.ts.map +1 -1
  6. package/dist/carrier-assemble.js +14 -3
  7. package/dist/carrier-assemble.js.map +1 -1
  8. package/dist/carrier-verify.d.ts +5 -2
  9. package/dist/carrier-verify.d.ts.map +1 -1
  10. package/dist/carrier-verify.js +110 -43
  11. package/dist/carrier-verify.js.map +1 -1
  12. package/dist/carrier.d.ts +44 -11
  13. package/dist/carrier.d.ts.map +1 -1
  14. package/dist/carrier.js +74 -16
  15. package/dist/carrier.js.map +1 -1
  16. package/dist/ceiling.d.ts +82 -3
  17. package/dist/ceiling.d.ts.map +1 -1
  18. package/dist/ceiling.js +137 -20
  19. package/dist/ceiling.js.map +1 -1
  20. package/dist/export.d.ts +10 -0
  21. package/dist/export.d.ts.map +1 -1
  22. package/dist/export.js +89 -30
  23. package/dist/export.js.map +1 -1
  24. package/dist/fuse.d.ts +43 -11
  25. package/dist/fuse.d.ts.map +1 -1
  26. package/dist/fuse.js +85 -18
  27. package/dist/fuse.js.map +1 -1
  28. package/dist/index.d.ts +9 -3
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +7 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/measurements.d.ts.map +1 -1
  33. package/dist/measurements.js +1 -0
  34. package/dist/measurements.js.map +1 -1
  35. package/dist/tree.d.ts +15 -3
  36. package/dist/tree.d.ts.map +1 -1
  37. package/dist/tree.js +41 -12
  38. package/dist/tree.js.map +1 -1
  39. package/dist/types.d.ts +21 -0
  40. package/dist/types.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/__tests__/carrier2.test.ts +1 -1
  43. package/src/carrier-assemble.ts +21 -3
  44. package/src/carrier-verify.ts +107 -45
  45. package/src/carrier.ts +91 -25
  46. package/src/ceiling.ts +150 -24
  47. package/src/export.ts +94 -31
  48. package/src/fuse.ts +114 -23
  49. package/src/index.ts +18 -2
  50. package/src/measurements.ts +1 -0
  51. package/src/tree.ts +42 -10
  52. package/src/types.ts +22 -0
@@ -1,21 +1,25 @@
1
1
  // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
2
 
3
3
  /**
4
- * verifyCarrier — the offline read path for a BitGraphed file (bitgraph-carrier/1
5
- * or /2), one result per claim, each saying what it rests on.
4
+ * verifyCarrier: the offline read path for a BitGraphed file (bitgraph-carrier/1,
5
+ * /2 or /3), one result per claim, each saying what it rests on.
6
6
  *
7
7
  * Given the file and nothing else, it strips the block by structure and checks:
8
8
  *
9
9
  * the bytes SHA-256 of the committed bytes is the digest the proof names
10
10
  * the proof Ed25519 signature, the position record and its bindings, the
11
- * fused commitment rebuilt (bitgraph-fuse/1 or /2), proofHash
11
+ * fused commitment rebuilt (bitgraph-fuse/1, /2 or /3), proofHash
12
12
  * the attestation ES384 signature, the certificate chain to the AWS Nitro root
13
13
  * (641A0321…), validity at the document's own instant, PCR0 against
14
14
  * the proof's measurement, user_data against the signed body; and,
15
15
  * on a v2 block, the openssl-checkable witness against the document
16
- * the floor the anchor proof named by the signed slotAnchor, verified over its
17
- * own message, matched by identity; its Ethereum header recomputed
18
- * the ceilings in position: the next anchor, same checks; in time (v2): the Base
16
+ * the floor v1, v2: the anchor proof named by the signed slotAnchor, verified over
17
+ * its own message, matched by identity; its Ethereum header recomputed.
18
+ * v3: the Base header, checked against the signed slotFloor (hash,
19
+ * number, time, Base mainnet's schedule). Either way the floor's time
20
+ * is a bound only when no later than the attestation document.
21
+ * the ceilings in position (v1, v2): the next anchor, same checks; v3 has none, its
22
+ * order is the chain of proof hashes; in time (v2, v3): the Base
19
23
  * sidecar's whole chain of custody (verifyCeiling); settled (v2): the
20
24
  * Ethereum block that committed the batch data (verifySettlementPointer)
21
25
  * the pins what the file declares it was made under, against the verifier's own
@@ -37,10 +41,11 @@
37
41
 
38
42
  import { verify, verifyProofIntegrity, createVerificationContext } from "./verifier.js";
39
43
  import { verifyFuse } from "./fuse-verify.js";
40
- import { readFuseAttribution } from "./fuse.js";
44
+ import { readFuseAttribution, signedFloorOf, type SignedFloor } from "./fuse.js";
41
45
  import { computeProofHash, computeSignedBodyHash } from "./proof-hash.js";
42
46
  import { verifyNitroAttestation, witnessMatchesAttestation, awsNitroRootSha256, type AttestationWitness } from "./nitro.js";
43
- import { baseTimeIsBound, verifyCeiling, checkCeilingOnline, type CeilingSidecar } from "./ceiling.js";
47
+ import { baseTimeIsBound, checkFloorHeader, floorTimeIsBound, verifyCeiling, checkCeilingOnline, type CeilingSidecar } from "./ceiling.js";
48
+ import { hexToBytes as evmHex } from "./ceiling-evm.js";
44
49
  import { PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
45
50
  import { verifySettlementPointer, checkSettlementOnline, BASE_MAINNET_SETTLEMENT_PINS, type SettlementPointer, type SettlementPins } from "./settlement.js";
46
51
  import type { BitGraphProof } from "./types.js";
@@ -99,14 +104,17 @@ export interface CarrierVerifyResult {
99
104
  verdict: "TRUE" | "FALSE" | "UNDETERMINED";
100
105
  /** Why the Base block's time is not stated as a bound, when it is not (see baseTimeIsBound). */
101
106
  baseTimeWithheld?: string | null;
107
+ /** Why the floor block's time is not stated as a bound, when it is not: it is stamped after the attestation document (see floorTimeIsBound). */
108
+ floorTimeWithheld?: string | null;
102
109
  /** "ok" | "none" | "corrupt" — whether the bytes carried a readable block at all. */
103
110
  carrier: "ok" | "none" | "corrupt";
104
- version: 1 | 2 | null;
111
+ version: 1 | 2 | 3 | null;
105
112
  /** Every failed or undetermined check, in the order met. Empty on a clean TRUE. */
106
113
  reasons: string[];
107
114
  /** Stated only when the block was readable. notAfter null = NOT FETCHED, in those words. */
108
115
  bounds: CarrierBounds | null;
109
- ceiling: "present" | "unfetched" | null;
116
+ /** The ceiling in position: "none" on v3, where none exists (order is the chain of proof hashes). */
117
+ ceiling: "present" | "unfetched" | "none" | null;
110
118
  claims: CarrierClaim[];
111
119
  /** Plain language, written from the claims. */
112
120
  reading: string;
@@ -159,7 +167,7 @@ export async function verifyCarrierPayload(payload: CarrierPayload, inner: Uint8
159
167
  } catch (e) {
160
168
  const detail = `a part of this proof block is malformed: ${e instanceof Error ? e.message : String(e)}`;
161
169
  add("wellformed", "Every part of the proof block is well formed", "FALSE", "", detail);
162
- let version: 1 | 2 | null = null;
170
+ let version: 1 | 2 | 3 | null = null;
163
171
  try { version = carrierVersionOf(payload); } catch { /* unreadable */ }
164
172
  const ceilingStatus = (payload as { ceiling?: { status?: unknown } } | null)?.ceiling?.status;
165
173
  return {
@@ -169,7 +177,7 @@ export async function verifyCarrierPayload(payload: CarrierPayload, inner: Uint8
169
177
  version,
170
178
  reasons: claims.filter((c) => c.result === "FALSE").map((c) => `${c.name}: ${c.detail}`),
171
179
  bounds: null,
172
- ceiling: ceilingStatus === "present" || ceilingStatus === "unfetched" ? ceilingStatus : null,
180
+ ceiling: ceilingStatus === "present" || ceilingStatus === "unfetched" || ceilingStatus === "none" ? ceilingStatus : null,
173
181
  claims,
174
182
  reading: `This file does not verify: ${detail}. Nothing here is a verdict on what the bytes say, only that the evidence does not hold together.`,
175
183
  payload,
@@ -214,7 +222,7 @@ async function verifyCarrierPayloadChecks(
214
222
  add("proof.hash", "The ledger's proofHash is this proof's", ok ? "TRUE" : "FALSE", "SHA-256", ok ? "recomputed over the signed-body subset and equal" : "the proofHash field is not the hash of this proof's signed-body subset");
215
223
  }
216
224
 
217
- // 3. Fused: the commitment inside the bytes, rebuilt from the signed record (fuse/2: and the signed floor block).
225
+ // 3. Fused: the commitment inside the bytes, rebuilt from the signed record (fuse/2 and fuse/3: and the signed floor block).
218
226
  const marker = readFuseAttribution(proof);
219
227
  if (marker !== null && inner === null) {
220
228
  add("proof.fused", "The bytes carry the position commitment", "NOT_CARRIED", "", `the file is not in hand; its bytes carry a bitgraph-fuse/${marker.version ?? 1} commitment to check`);
@@ -222,8 +230,8 @@ async function verifyCarrierPayloadChecks(
222
230
  const f = await verifyFuse({ proof, bytes: inner });
223
231
  const good = f.category === "FUSED_DIRECT" || f.category === "CARRIED_INLINE";
224
232
  add("proof.fused", "The bytes carry the position commitment", good ? "TRUE" : "FALSE",
225
- marker.version === 2 ? "SHA-256 over the signed position record, its nonce and the signed floor block hash" : "SHA-256 over the signed position record and its nonce",
226
- good ? `${f.category}: ${marker.version === 2 ? "the commitment binds the floor block, so the bytes could not have been finished before that block existed" : "the commitment was made from the position record before the bytes were finished"}` : `${f.category}${f.reason ? `: ${f.reason}` : ""}`);
233
+ (marker.version ?? 1) >= 2 ? "SHA-256 over the signed position record, its nonce and the signed floor block hash" : "SHA-256 over the signed position record and its nonce",
234
+ good ? `${f.category}: ${(marker.version ?? 1) >= 2 ? "the commitment binds the floor block, so the bytes could not have been finished before that block existed" : "the commitment was made from the position record before the bytes were finished"}` : `${f.category}${f.reason ? `: ${f.reason}` : ""}`);
227
235
  } else {
228
236
  add("proof.fused", "The bytes carry the position commitment", "NOT_CARRIED", "", "an ordinary recording: the position was taken after the bytes existed, and no commitment is inside them");
229
237
  }
@@ -268,7 +276,7 @@ async function verifyCarrierPayloadChecks(
268
276
  ? usingDefault && pub ? `PCR0 ${measured.slice(0, 16)}… is BitGraph's published ${pub.version} image (since ${pub.since})` : `PCR0 ${measured.slice(0, 16)}… is on the verifier's list`
269
277
  : usingDefault ? `PCR0 ${measured.slice(0, 16)}… is not an image BitGraph published, so this proof is not BitGraph's` : `PCR0 ${measured.slice(0, 16)}… is not on the verifier's list`);
270
278
  }
271
- if (version === 2 && payload.attestation) {
279
+ if (version >= 2 && payload.attestation) {
272
280
  const w = witnessMatchesAttestation(payload.attestation as unknown as AttestationWitness, att.reportB64);
273
281
  add("attestation.witness", "The openssl witness is what the document decodes to", w.ok ? "TRUE" : "FALSE", "recomputed from the attestation document", w.detail);
274
282
  }
@@ -276,21 +284,60 @@ async function verifyCarrierPayloadChecks(
276
284
  add("attestation.signature", "AWS hardware signed the attestation", "NOT_CARRIED", "", "the proof carries no aws-nitro attestation");
277
285
  }
278
286
 
279
- // 5. The floor: the anchor proof verifies over its own signed message, and
280
- // it is the anchor the enclave fixed at allocation, matched by identity.
281
- const floorMsg = anchorMessageBytes(payload.floor.anchor);
282
- if (floorMsg.error !== null) add("floor.anchor", "The floor anchor is a genuine anchor proof", "FALSE", "", `floor anchor: ${floorMsg.error}`);
283
- else {
284
- const floorResult = await verify({ proof: payload.floor.anchor as unknown as BitGraphProof, bytes: floorMsg.bytes, context: createVerificationContext() });
285
- add("floor.anchor", "The floor anchor is a genuine anchor proof", floorResult.valid ? "TRUE" : "FALSE", "Ed25519", floorResult.valid ? "the anchor proof verifies over its own signed block-hash message, under the same key" : `the floor anchor proof does not verify: ${floorResult.reason ?? "unspecified"}`);
287
+ // 5. The floor. One floor per proof (signedFloorOf); a proof that signs two is ambiguous and floors nothing.
288
+ let signed: SignedFloor | null = null;
289
+ let ambiguous: string | null = null;
290
+ try {
291
+ signed = signedFloorOf(proof);
292
+ } catch (e) {
293
+ ambiguous = (e as Error).message;
294
+ }
295
+ let floorTs: number | null = null;
296
+ let floorChain: "ethereum" | "base" = "ethereum";
297
+ if (payload.floor.basis === "base-header") {
298
+ // v3: the Base header itself, checked against the signed slotFloor. No anchor proof stands under it.
299
+ floorChain = "base";
300
+ const header = payload.floor.header;
301
+ let raw: Uint8Array | null = null;
302
+ try { raw = evmHex(header); } catch { raw = null; }
303
+ const fh = ambiguous !== null || signed === null || raw === null ? null : checkFloorHeader(signed, raw, "base");
304
+ const why = ambiguous ?? (signed === null ? "the proof signs no floor block (commit.slotFloor)" : raw === null ? "the floor header is not hex" : fh && !fh.ok ? fh.reason : "");
305
+ add("floor.binding", "The floor is the Base block the enclave fixed for this position", fh?.ok ? "TRUE" : "FALSE", "the proof's signed commit.slotFloor",
306
+ fh?.ok ? "the header's block number, hash and time equal the signed slotFloor, on Base mainnet's schedule" : why);
307
+ if (fh?.ok) {
308
+ floorTs = fh.header.timestamp;
309
+ add("floor.header", "The floor block's header is the one with that hash", "TRUE", `Base block ${fh.header.number}, header as given`, `keccak-256 of the header equals the signed block hash; its time is ${iso(fh.header.timestamp)}`);
310
+ } else {
311
+ add("floor.header", "The floor block's header is the one with that hash", "FALSE", "", `floor header: ${why}`);
312
+ }
313
+ } else {
314
+ // v1, v2: the anchor proof verifies over its own signed message, and it
315
+ // is the anchor the enclave fixed at allocation, matched by identity.
316
+ const floorMsg = anchorMessageBytes(payload.floor.anchor);
317
+ if (floorMsg.error !== null) add("floor.anchor", "The floor anchor is a genuine anchor proof", "FALSE", "", `floor anchor: ${floorMsg.error}`);
318
+ else {
319
+ const floorResult = await verify({ proof: payload.floor.anchor as unknown as BitGraphProof, bytes: floorMsg.bytes, context: createVerificationContext() });
320
+ add("floor.anchor", "The floor anchor is a genuine anchor proof", floorResult.valid ? "TRUE" : "FALSE", "Ed25519", floorResult.valid ? "the anchor proof verifies over its own signed block-hash message, under the same key" : `the floor anchor proof does not verify: ${floorResult.reason ?? "unspecified"}`);
321
+ }
322
+ const floorBind = ambiguous !== null ? [ambiguous]
323
+ : signed?.chain === "base" ? ["the proof signs a Base floor (commit.slotFloor), and this block carries an Ethereum anchor as its floor"]
324
+ : checkFloorBinding(payload.proof, payload.floor);
325
+ add("floor.binding", "The floor is the anchor the enclave fixed for this position", floorBind.length === 0 ? "TRUE" : "FALSE", "the proof's signed commit.slotAnchor", floorBind.length === 0 ? "the anchor's counter, block number and block hash equal the signed slotAnchor" : floorBind.join("; "));
326
+ const floorWitness = verifyWitnessHeader(payload.floor.witness);
327
+ floorTs = floorWitness.ok ? floorWitness.timestamp : null;
328
+ add("floor.header", "The floor block's header is the one with that hash", floorWitness.ok ? "TRUE" : "FALSE", `Ethereum block ${payload.floor.witness.blockNumber}, header as given`, floorWitness.ok ? `keccak-256 of the header equals the signed block hash; its time is ${iso(floorWitness.timestamp)}` : `floor witness: ${floorWitness.error}`);
329
+ }
330
+ // The floor's time is a bound only when it is no later than the attestation document (review, 2026-10-06).
331
+ let floorTimeWithheld: string | null = null;
332
+ if (floorTs !== null) {
333
+ const bound = floorTimeIsBound(floorTs, attestedAtMs);
334
+ if (!bound.ok) floorTimeWithheld = bound.reason;
286
335
  }
287
- const floorBind = checkFloorBinding(payload.proof, payload.floor);
288
- add("floor.binding", "The floor is the anchor the enclave fixed for this position", floorBind.length === 0 ? "TRUE" : "FALSE", "the proof's signed commit.slotAnchor", floorBind.length === 0 ? "the anchor's counter, block number and block hash equal the signed slotAnchor" : floorBind.join("; "));
289
- const floorWitness = verifyWitnessHeader(payload.floor.witness);
290
- add("floor.header", "The floor block's header is the one with that hash", floorWitness.ok ? "TRUE" : "FALSE", `Ethereum block ${payload.floor.witness.blockNumber}, header as given`, floorWitness.ok ? `keccak-256 of the header equals the signed block hash; its time is ${iso(floorWitness.timestamp)}` : `floor witness: ${floorWitness.error}`);
291
336
 
292
- // 6. The ceiling in position, only when the carrier claims one.
293
- if (payload.ceiling.status === "present") {
337
+ // 6. The ceiling in position: v1 and v2 when the carrier claims one; v3 has none.
338
+ if (payload.ceiling.status === "none") {
339
+ add("ceiling.position", "A closing anchor follows the record", "NOT_CARRIED", "", "none exists for a Base-floor BitGraph: anchors ended with the cutover, and its order among BitGraphs is the chain of proof hashes");
340
+ } else if (payload.ceiling.status === "present") {
294
341
  const ceilMsg = anchorMessageBytes(payload.ceiling.anchor);
295
342
  if (ceilMsg.error !== null) add("ceiling.position.anchor", "The closing anchor is a genuine anchor proof", "FALSE", "", `ceiling anchor: ${ceilMsg.error}`);
296
343
  else {
@@ -305,11 +352,11 @@ async function verifyCarrierPayloadChecks(
305
352
  add("ceiling.position.binding", "The record was committed before the closing anchor", "NOT_CARRIED", "", "closing anchor not fetched: the floor stands on its own");
306
353
  }
307
354
 
308
- // 7. v2: the ceiling in time, the Base block the record existed by.
355
+ // 7. v2 and v3: the ceiling in time, the Base block the record existed by.
309
356
  let ceilingTime: { blockNumber: number; blockHash: string; blockTimestamp: number; status: string } | null = null;
310
357
  let baseTimeWithheld: string | null = null;
311
358
  let sidecar: CeilingSidecar | null = null;
312
- if (version === 2) {
359
+ if (version >= 2) {
313
360
  const ct = payload.ceilingInTime;
314
361
  if (ct && ct.status === "present") {
315
362
  sidecar = ct.sidecar as unknown as CeilingSidecar;
@@ -320,11 +367,11 @@ async function verifyCarrierPayloadChecks(
320
367
  add("ceiling.time.payload", "The transaction carries that root", r(byName("payload")), "the 84-byte BGC1 payload", byName("payload")?.detail ?? c.reason ?? "not reached");
321
368
  add("ceiling.time.sender", "The transaction was signed by the ceiling writer", r(byName("sender")), `secp256k1; the writer pin ${pinnedWriter.slice(0, 8)}…`, byName("sender")?.detail ?? c.reason ?? "not reached");
322
369
  add("ceiling.time.inclusion", "The transaction is in the Base block", r(byName("inclusion")), `Merkle-Patricia proof; Base block ${sidecar.anchor?.blockNumber ?? "?"}, header as given`, byName("inclusion")?.detail ?? c.reason ?? "not reached");
323
- add("ceiling.time.floor", "The floor header the ceiling carries is the signed floor", r(byName("floor")), "the proof's signed commit.slotAnchor", byName("floor")?.detail ?? "the sidecar carries no floor header");
370
+ add("ceiling.time.floor", "The floor header the ceiling carries is the signed floor", r(byName("floor")), floorChain === "base" ? "the proof's signed commit.slotFloor" : "the proof's signed commit.slotAnchor", byName("floor")?.detail ?? "the sidecar carries no floor header");
324
371
  const win = c.ok ? c.window?.ceiling : undefined;
325
372
  if (win) {
326
373
  // The inclusion holds either way; a stamp that cannot be a bound is withheld as a time.
327
- const stamp = baseTimeIsBound(win.blockTimestamp, { floorTimestampSec: floorWitness.timestamp ?? c.window?.floor.blockTimestamp ?? null, attestedAtMs });
374
+ const stamp = baseTimeIsBound(win.blockTimestamp, { floorTimestampSec: floorTs ?? c.window?.floor.blockTimestamp ?? null, attestedAtMs });
328
375
  if (stamp.ok) ceilingTime = { blockNumber: win.blockNumber, blockHash: win.blockHash, blockTimestamp: win.blockTimestamp, status: c.status ?? "included" };
329
376
  else baseTimeWithheld = stamp.reason;
330
377
  }
@@ -334,7 +381,7 @@ async function verifyCarrierPayloadChecks(
334
381
  add("ceiling.time.record", "The record existed by a Base block", "NOT_CARRIED", "", ct?.status === "unfetched" ? "the ceiling in time was not fetched when this file was made" : "no ceiling in time is stated");
335
382
  }
336
383
 
337
- // 8. v2: settlement on Ethereum, when carried.
384
+ // 8. v2 and v3: settlement on Ethereum, when carried.
338
385
  const st = payload.settlement;
339
386
  if (st && st.status === "present") {
340
387
  const pointer = st.pointer as unknown as SettlementPointer;
@@ -362,12 +409,21 @@ async function verifyCarrierPayloadChecks(
362
409
  }
363
410
  }
364
411
 
365
- // 10. Confirmed: the block hashes against nodes the caller named.
412
+ // 10. Confirmed: the block hashes against nodes the caller named. The floor
413
+ // is asked of its own chain, by height: the chain's block at N must be
414
+ // the one the header hashes to.
366
415
  const lk = opts.lookups;
416
+ const nb = carrierBounds(payload).notBefore;
417
+ const floorAsk = floorChain === "base" ? lk?.baseBlockHash : lk?.ethereumBlockHash;
418
+ const floorChainName = floorChain === "base" ? "Base" : "Ethereum";
419
+ if (floorAsk) {
420
+ const h = (await safe(() => floorAsk(nb.blockNumber)))?.toLowerCase();
421
+ const ok = h === nb.blockHash;
422
+ add("confirmed.floor", `The floor block is ${floorChainName}'s own`, h ? (ok ? "TRUE" : "FALSE") : "UNDETERMINED", `the ${floorChainName} node the caller named`, h ? (ok ? `${floorChainName} block ${nb.blockNumber} matches the node` : `the node's block ${nb.blockNumber} is ${h}, not this header`) : "the node did not answer", "confirmed");
423
+ } else {
424
+ add("confirmed.floor", `The floor block is ${floorChainName}'s own`, "UNDETERMINED", "", `no ${floorChainName} node given: the header is taken as the one matching its hash; confirm block ${nb.blockNumber} against any node or explorer`, "confirmed");
425
+ }
367
426
  if (lk?.ethereumBlockHash) {
368
- const h = (await safe(() => lk.ethereumBlockHash!(payload.floor.witness.blockNumber)))?.toLowerCase();
369
- const ok = h === payload.floor.witness.blockHash.toLowerCase();
370
- add("confirmed.floor", "The floor block is Ethereum's own", h ? (ok ? "TRUE" : "FALSE") : "UNDETERMINED", "the Ethereum node the caller named", h ? (ok ? `Ethereum block ${payload.floor.witness.blockNumber} matches the node` : `the node's block ${payload.floor.witness.blockNumber} is ${h}, not this header`) : "the node did not answer", "confirmed");
371
427
  const pc = payload.ceiling;
372
428
  if (pc.status === "present") {
373
429
  const h2 = (await safe(() => lk.ethereumBlockHash!(pc.witness.blockNumber)))?.toLowerCase();
@@ -379,8 +435,6 @@ async function verifyCarrierPayloadChecks(
379
435
  const r = await checkSettlementOnline(st.pointer as unknown as SettlementPointer, lk.ethereumBlockHash);
380
436
  add("confirmed.settlement", "The settling Ethereum block is Ethereum's own", r.ok ? "TRUE" : "FALSE", "the Ethereum node the caller named", r.detail, "confirmed");
381
437
  }
382
- } else {
383
- add("confirmed.floor", "The floor block is Ethereum's own", "UNDETERMINED", "", "no Ethereum node given: the header is taken as the one matching its hash; confirm block " + payload.floor.witness.blockNumber + " against any node or explorer", "confirmed");
384
438
  }
385
439
  if (sidecar) {
386
440
  if (lk?.baseBlockHash) {
@@ -400,16 +454,19 @@ async function verifyCarrierPayloadChecks(
400
454
  const bounds = carrierBounds(payload);
401
455
  // The ceiling in time reaches callers only as verified here, and only when its stamp is a bound.
402
456
  bounds.existedBy = ceilingTime ? { chain: "base", blockNumber: ceilingTime.blockNumber, blockHash: ceilingTime.blockHash, timestamp: ceilingTime.blockTimestamp } : null;
457
+ // So does the floor's time: from a verified header, and only when it is a bound.
458
+ bounds.notBefore.timestamp = floorTimeWithheld === null ? floorTs : null;
403
459
  return {
404
460
  verdict,
405
461
  baseTimeWithheld,
462
+ floorTimeWithheld,
406
463
  carrier: "ok",
407
464
  version,
408
465
  reasons,
409
466
  bounds,
410
467
  ceiling: payload.ceiling.status,
411
468
  claims,
412
- reading: writeReading(verdict, claims, bounds, proof, ceilingTime, floorWitness.timestamp, baseTimeWithheld),
469
+ reading: writeReading(verdict, claims, bounds, proof, ceilingTime, bounds.notBefore.timestamp, baseTimeWithheld, floorTimeWithheld),
413
470
  payload,
414
471
  inner,
415
472
  };
@@ -435,6 +492,7 @@ function writeReading(
435
492
  ceilingTime: { blockNumber: number; blockHash: string; blockTimestamp: number } | null,
436
493
  floorTs: number | null,
437
494
  baseTimeWithheld: string | null = null,
495
+ floorTimeWithheld: string | null = null,
438
496
  ): string {
439
497
  const get = (id: string) => claims.find((c) => c.id === id);
440
498
  if (verdict === "FALSE") {
@@ -444,10 +502,13 @@ function writeReading(
444
502
  const position = proof.commit?.counter ?? "?";
445
503
  const epoch = (proof.commit?.epochId ?? "").replace(/=+$/, "").slice(0, 8);
446
504
  const fused = get("proof.fused");
447
- const after = floorTs !== null ? `Recorded after Ethereum block ${bounds.notBefore.blockNumber} (${iso(floorTs)})` : `Recorded after Ethereum block ${bounds.notBefore.blockNumber}`;
505
+ const floorChain = bounds.notBefore.chain === "base" ? "Base" : "Ethereum";
506
+ const after = floorTs !== null ? `Recorded after ${floorChain} block ${bounds.notBefore.blockNumber} (${iso(floorTs)})` : `Recorded after ${floorChain} block ${bounds.notBefore.blockNumber}`;
448
507
  const by = ceilingTime ? `, and existed by Base block ${ceilingTime.blockNumber} (${iso(ceilingTime.blockTimestamp)})` : "";
449
508
  const settled = bounds.settledBy ? `, whose batch data Ethereum committed in block ${bounds.settledBy.blockNumber} (${iso(bounds.settledBy.timestamp)})` : "";
450
- const before = bounds.notAfter ? `; committed before the anchoring of Ethereum block ${bounds.notAfter.blockNumber}, a bound in position` : "";
509
+ const before = bounds.notAfter
510
+ ? `; committed before the anchoring of Ethereum block ${bounds.notAfter.blockNumber}, a bound in position`
511
+ : get("ceiling.position") ? "; its order among BitGraphs is the chain of proof hashes" : "";
451
512
  const digest = get("bytes.digest");
452
513
  // Two floors (SPEC 8.6): every record has the record floor; only bytes that
453
514
  // carry the commitment have the content floor. Without it, the bytes
@@ -460,7 +521,7 @@ function writeReading(
460
521
  const att = get("attestation.root");
461
522
  const rests: string[] = ["SHA-256", "Ed25519"];
462
523
  if (att?.result === "TRUE") rests.push(`the AWS Nitro root (${awsNitroRootSha256().slice(0, 8)}…)`);
463
- rests.push(`Ethereum block ${bounds.notBefore.blockNumber}`);
524
+ rests.push(`${floorChain} block ${bounds.notBefore.blockNumber}`);
464
525
  if (ceilingTime) rests.push(`Base block ${ceilingTime.blockNumber}`);
465
526
  if (bounds.settledBy) rests.push(`Ethereum block ${bounds.settledBy.blockNumber}`);
466
527
  const confirmed = claims.filter((c) => c.level === "confirmed");
@@ -470,7 +531,8 @@ function writeReading(
470
531
  : "Offline, the blocks are taken from their headers, each of which hashes to the hash the evidence names; confirm them against any node or explorer to remove that reliance.";
471
532
  const pins = get("attestation.pins");
472
533
  const pinLine = pins?.result === "TRUE" ? ` ${pins.detail.replace(/^PCR0 [0-9a-f]+… is /, "The enclave image is ")}.` : pins?.result === "UNDETERMINED" ? ` ${pins.detail}.` : !pins ? " The proof carries no attestation, so which enclave image signed it is not established." : "";
473
- const withheld = baseTimeWithheld ? ` The record is in a Base block, but its time is not used as a bound: ${baseTimeWithheld}.` : "";
534
+ const withheld = (floorTimeWithheld ? ` The floor block's time is not used as a bound: ${floorTimeWithheld}.` : "")
535
+ + (baseTimeWithheld ? ` The record is in a Base block, but its time is not used as a bound: ${baseTimeWithheld}.` : "");
474
536
  const lead = verdict === "UNDETERMINED" ? "Not judged in full. " : "";
475
537
  return `${lead}${subject} ${after}${by}${settled}${before}. Position ${position} of epoch ${epoch}…. Rests on: ${rests.join(", ")}. ${tail}${withheld}${pinLine}`;
476
538
  }
package/src/carrier.ts CHANGED
@@ -41,6 +41,17 @@
41
41
  * never reads as authority. A reader that knows only v1 reports an unknown
42
42
  * version (UNDETERMINED), never a verdict.
43
43
  *
44
+ * bitgraph-carrier/3 (2026-10-06, enclave v10) is /2 for a proof whose floor
45
+ * is a Base block (`commit.slotFloor`). The floor is that block's header
46
+ * itself, `{ status: "present", basis: "base-header", header }`, checked
47
+ * against the signed floor (hash, number and time, on Base mainnet's
48
+ * schedule); there is no anchor proof under it. There is no ceiling in
49
+ * POSITION either: anchors ended with the cutover, and the order among
50
+ * BitGraphs is the chain of proof hashes, so the block states
51
+ * `{ status: "none", basis: "hash-chain" }`, a fact, not a pending part.
52
+ * Everything else (ceiling in time, settlement, pins, attestation witness) is
53
+ * /2's. Ethereum-floor proofs keep travelling as /1 and /2.
54
+ *
44
55
  * ⚠️ TWO BYTE-IDENTICAL COPIES OF THIS FILE EXIST, on purpose:
45
56
  * packages/verify/src/carrier.ts (canonical, published with the package)
46
57
  * website/src/lib/carrier.ts (the site cannot import unpublished code)
@@ -63,7 +74,8 @@ export const MAX_CARRIER_PAYLOAD = 8 * 1024 * 1024;
63
74
 
64
75
  export const CARRIER_VERSION = "bitgraph-carrier/1";
65
76
  export const CARRIER_VERSION_2 = "bitgraph-carrier/2";
66
- export type CarrierVersion = typeof CARRIER_VERSION | typeof CARRIER_VERSION_2;
77
+ export const CARRIER_VERSION_3 = "bitgraph-carrier/3";
78
+ export type CarrierVersion = typeof CARRIER_VERSION | typeof CARRIER_VERSION_2 | typeof CARRIER_VERSION_3;
67
79
  /** The sidecar and pointer formats a v2 block carries; their shapes are checked by their own modules. */
68
80
  export const CEILING_SIDECAR_VERSION = "bitgraph-ceiling/1";
69
81
  export const SETTLEMENT_POINTER_VERSION = "bitgraph-settlement/1";
@@ -83,12 +95,24 @@ export type CarrierProof = Record<string, unknown>;
83
95
 
84
96
  export interface CarrierFloor {
85
97
  status: "present";
98
+ basis?: never;
86
99
  /** The anchor proof named by the carried proof's signed `commit.slotAnchor`. */
87
100
  anchor: CarrierProof;
88
101
  witness: CarrierWitness;
89
102
  }
90
103
 
104
+ /** v3: the Base block the carried proof signs as `commit.slotFloor`, as its raw header (0x hex RLP). No anchor proof stands under it. */
105
+ export interface CarrierBaseFloor {
106
+ status: "present";
107
+ basis: "base-header";
108
+ header: string;
109
+ anchor?: never;
110
+ witness?: never;
111
+ }
112
+
91
113
  export type CarrierCeiling =
114
+ /** v3: no ceiling in position exists; order among BitGraphs is the chain of proof hashes. */
115
+ | { status: "none"; basis: "hash-chain" }
92
116
  | {
93
117
  status: "unfetched";
94
118
  /** Set when a completion looked and nothing had landed yet, so "never looked" and "not yet" read apart. */
@@ -124,16 +148,17 @@ export interface CarrierPayload {
124
148
  carrier: CarrierVersion;
125
149
  /** The bitgraph/1 proof exactly as the commit returned it. */
126
150
  proof: CarrierProof;
127
- floor: CarrierFloor;
128
- /** The ceiling in position: the next anchor in the chain. Every proof ever made has one. */
151
+ /** v1 and v2: the Ethereum anchor proof and its header. v3: the Base header. */
152
+ floor: CarrierFloor | CarrierBaseFloor;
153
+ /** The ceiling in position: the next anchor in the chain (v1, v2), or on v3 the statement that there is none. */
129
154
  ceiling: CarrierCeiling;
130
- /** v2 only. Required on a v2 block, so absence reads as a corrupt block, never as "no ceiling". */
155
+ /** v2 and v3. Required there, so absence reads as a corrupt block, never as "no ceiling". */
131
156
  ceilingInTime?: CarrierCeilingInTime;
132
- /** v2 only, optional. */
157
+ /** v2 and v3, optional. */
133
158
  settlement?: CarrierSettlement;
134
- /** v2 only, optional. */
159
+ /** v2 and v3, optional. */
135
160
  pins?: CarrierPins;
136
- /** v2 only, optional: the proof's attestation as aws-nitro-witness/1 evidence. */
161
+ /** v2 and v3, optional: the proof's attestation as aws-nitro-witness/1 evidence. */
137
162
  attestation?: Record<string, unknown>;
138
163
  }
139
164
 
@@ -231,19 +256,29 @@ export function buildCarrier(inner: Uint8Array, payload: CarrierPayload): Uint8A
231
256
  function payloadShapeError(p: unknown): string | null {
232
257
  const o = record(p);
233
258
  if (o === null) return "payload is not an object";
234
- const v2 = o["carrier"] === CARRIER_VERSION_2;
259
+ const v3 = o["carrier"] === CARRIER_VERSION_3;
260
+ const v2 = o["carrier"] === CARRIER_VERSION_2 || v3;
235
261
  if (o["carrier"] !== CARRIER_VERSION && !v2) return `unknown carrier version ${JSON.stringify(o["carrier"])}`;
236
262
  if (record(o["proof"]) === null) return "payload carries no proof object";
237
263
  const floor = record(o["floor"]);
238
264
  if (floor === null || floor["status"] !== "present") return "floor must be present: a floorless carrier is not a not-before";
239
- if (record(floor["anchor"]) === null) return "floor carries no anchor proof";
240
- const fw = record(floor["witness"]);
241
- if (fw === null || typeof fw["headerRlpHex"] !== "string" || typeof fw["blockNumber"] !== "number" || typeof fw["blockHash"] !== "string") {
242
- return "floor carries no readable block-header witness";
243
- }
244
265
  const ceil = record(o["ceiling"]);
245
266
  if (ceil === null) return "ceiling is missing: absence must be a stated fact, not a missing key";
246
- if (ceil["status"] !== "unfetched") {
267
+ if (v3) {
268
+ // v3: the floor is a Base header, and no ceiling in position exists.
269
+ if (floor["basis"] !== "base-header") return `a ${CARRIER_VERSION_3} floor must be a Base header (basis "base-header"), got ${JSON.stringify(floor["basis"])}`;
270
+ if (typeof floor["header"] !== "string" || baseHeaderFields(floor["header"]) === null) return "floor carries no readable Base block header";
271
+ if (floor["anchor"] !== undefined || floor["witness"] !== undefined) return `a ${CARRIER_VERSION_3} floor carries no anchor proof`;
272
+ if (ceil["status"] !== "none" || ceil["basis"] !== "hash-chain") return `a ${CARRIER_VERSION_3} block states no ceiling in position ({ status: "none", basis: "hash-chain" })`;
273
+ } else {
274
+ if (floor["basis"] !== undefined) return `unknown floor basis ${JSON.stringify(floor["basis"])} on ${String(o["carrier"])}`;
275
+ if (record(floor["anchor"]) === null) return "floor carries no anchor proof";
276
+ const fw = record(floor["witness"]);
277
+ if (fw === null || typeof fw["headerRlpHex"] !== "string" || typeof fw["blockNumber"] !== "number" || typeof fw["blockHash"] !== "string") {
278
+ return "floor carries no readable block-header witness";
279
+ }
280
+ }
281
+ if (!v3 && ceil["status"] !== "unfetched") {
247
282
  if (ceil["status"] !== "present") return `ceiling status must be "unfetched" or "present", got ${JSON.stringify(ceil["status"])}`;
248
283
  if (ceil["basis"] !== "counter-order") return `unknown ceiling basis ${JSON.stringify(ceil["basis"])}`;
249
284
  if (record(ceil["anchor"]) === null) return "ceiling carries no anchor proof";
@@ -253,7 +288,7 @@ function payloadShapeError(p: unknown): string | null {
253
288
  }
254
289
  }
255
290
  if (!v2) return null;
256
- // v2: the ceiling in time is stated either way; settlement, pins and the attestation witness are optional.
291
+ // v2 and v3: the ceiling in time is stated either way; settlement, pins and the attestation witness are optional.
257
292
  const ct = record(o["ceilingInTime"]);
258
293
  if (ct === null) return "ceilingInTime is missing: a v2 block states the ceiling in time or that it was not fetched";
259
294
  if (ct["status"] === "present") {
@@ -276,9 +311,9 @@ function payloadShapeError(p: unknown): string | null {
276
311
  return null;
277
312
  }
278
313
 
279
- /** 1 or 2, from a parsed payload. */
280
- export function carrierVersionOf(payload: CarrierPayload): 1 | 2 {
281
- return payload.carrier === CARRIER_VERSION_2 ? 2 : 1;
314
+ /** 1, 2 or 3, from a parsed payload. */
315
+ export function carrierVersionOf(payload: CarrierPayload): 1 | 2 | 3 {
316
+ return payload.carrier === CARRIER_VERSION_3 ? 3 : payload.carrier === CARRIER_VERSION_2 ? 2 : 1;
282
317
  }
283
318
 
284
319
  export function parseCarrier(bytes: Uint8Array): CarrierParse {
@@ -315,6 +350,7 @@ export function completeCarrier(
315
350
  const p = parseCarrier(bytes);
316
351
  if (p.kind !== "carrier") return { changed: false, bytes, error: p.kind === "none" ? "not a carrier" : `corrupt block: ${p.reason}` };
317
352
  const cur = p.payload.ceiling;
353
+ if (cur.status === "none") return { changed: false, bytes, error: `a ${CARRIER_VERSION_3} block has no ceiling in position: its order is the chain of proof hashes` };
318
354
  if (cur.status === "present") {
319
355
  if (ceiling === null) return { changed: false, bytes };
320
356
  const a = record(record(cur.anchor)?.["commit"]);
@@ -346,7 +382,7 @@ export function completeCarrierInTime(
346
382
  ): { changed: boolean; bytes: Uint8Array; error?: string } {
347
383
  const p = parseCarrier(bytes);
348
384
  if (p.kind !== "carrier") return { changed: false, bytes, error: p.kind === "none" ? "not a carrier" : `corrupt block: ${p.reason}` };
349
- if (carrierVersionOf(p.payload) !== 2) return { changed: false, bytes, error: "a bitgraph-carrier/1 block has no ceiling in time; rebuild the file as carrier/2" };
385
+ if (carrierVersionOf(p.payload) === 1) return { changed: false, bytes, error: "a bitgraph-carrier/1 block has no ceiling in time; rebuild the file as carrier/2" };
350
386
  const cur = p.payload.ceilingInTime;
351
387
  if (cur && cur.status === "present") {
352
388
  if (sidecar === null) return { changed: false, bytes };
@@ -380,7 +416,7 @@ export function completeCarrierSettlement(
380
416
  ): { changed: boolean; bytes: Uint8Array; error?: string } {
381
417
  const p = parseCarrier(bytes);
382
418
  if (p.kind !== "carrier") return { changed: false, bytes, error: p.kind === "none" ? "not a carrier" : `corrupt block: ${p.reason}` };
383
- if (carrierVersionOf(p.payload) !== 2) return { changed: false, bytes, error: "a bitgraph-carrier/1 block has no settlement; rebuild the file as carrier/2" };
419
+ if (carrierVersionOf(p.payload) === 1) return { changed: false, bytes, error: "a bitgraph-carrier/1 block has no settlement; rebuild the file as carrier/2" };
384
420
  const cur = p.payload.settlement;
385
421
  if (cur && cur.status === "present") {
386
422
  const a = record(cur.pointer["l1"]), b = record(pointer["l1"]);
@@ -583,11 +619,33 @@ export function verifyWitnessHeader(w: CarrierWitness): WitnessCheck {
583
619
  return { ok: true, error: null, timestamp: rlpNumber(items[11]!) };
584
620
  }
585
621
 
622
+ /**
623
+ * v3: the block a Base header names, read from its bytes: keccak-256 is its
624
+ * hash, items 8 and 11 its number and time. Null when it is not a readable
625
+ * header. Says nothing about whether it is the signed floor: verifyCarrier
626
+ * checks that against the proof.
627
+ */
628
+ export function baseHeaderFields(headerHex: string): { blockNumber: number; blockHash: string; timestamp: number } | null {
629
+ const raw = typeof headerHex === "string" ? hexToBytes(headerHex) : null;
630
+ if (raw === null || raw.length === 0) return null;
631
+ const items = decodeRlpTop(raw);
632
+ if (items === null || items.length < 12) return null;
633
+ const blockNumber = rlpNumber(items[8]!), timestamp = rlpNumber(items[11]!);
634
+ if (blockNumber === null || timestamp === null) return null;
635
+ const blockHash = "0x" + Array.from(keccak_256(raw), (b) => b.toString(16).padStart(2, "0")).join("");
636
+ return { blockNumber, blockHash, timestamp };
637
+ }
638
+
586
639
  /* ── The window a reader states ─────────────────────────────────────────── */
587
640
 
588
641
  export interface CarrierBounds {
589
- notBefore: { blockNumber: number; blockHash: string; timestamp: number | null };
590
- /** The ceiling in POSITION: the next anchor. null means NOT FETCHED — say so in those words — never "none exists". */
642
+ /** The floor, on its chain: Ethereum (v1, v2) or Base (v3). */
643
+ notBefore: { chain: "ethereum" | "base"; blockNumber: number; blockHash: string; timestamp: number | null };
644
+ /**
645
+ * The ceiling in POSITION: the next anchor. On v1 and v2, null means NOT
646
+ * FETCHED (say so in those words), never "none exists". On v3 it is always
647
+ * null because none exists: order is the chain of proof hashes.
648
+ */
591
649
  notAfter: { blockNumber: number; blockHash: string; timestamp: number | null } | null;
592
650
  /**
593
651
  * v2: the ceiling in TIME. From carrierBounds, as the sidecar states it;
@@ -601,9 +659,17 @@ export interface CarrierBounds {
601
659
  }
602
660
 
603
661
  export function carrierBounds(payload: CarrierPayload): CarrierBounds {
604
- const f = payload.floor.witness;
605
- const floorTs = verifyWitnessHeader(f);
606
- const notBefore = { blockNumber: f.blockNumber, blockHash: f.blockHash.toLowerCase(), timestamp: floorTs.ok ? floorTs.timestamp : null };
662
+ let notBefore: CarrierBounds["notBefore"];
663
+ if (payload.floor.basis === "base-header") {
664
+ const h = baseHeaderFields(payload.floor.header);
665
+ notBefore = h === null
666
+ ? { chain: "base", blockNumber: 0, blockHash: "", timestamp: null }
667
+ : { chain: "base", blockNumber: h.blockNumber, blockHash: h.blockHash, timestamp: h.timestamp };
668
+ } else {
669
+ const f = payload.floor.witness;
670
+ const floorTs = verifyWitnessHeader(f);
671
+ notBefore = { chain: "ethereum", blockNumber: f.blockNumber, blockHash: f.blockHash.toLowerCase(), timestamp: floorTs.ok ? floorTs.timestamp : null };
672
+ }
607
673
  let notAfter: CarrierBounds["notAfter"] = null;
608
674
  if (payload.ceiling.status === "present") {
609
675
  const c = payload.ceiling.witness;