@mikeargento/bitgraph-verify 1.14.0 → 1.15.1

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 (72) hide show
  1. package/dist/__tests__/carrier.test.js +19 -0
  2. package/dist/__tests__/carrier.test.js.map +1 -1
  3. package/dist/__tests__/carrier2.test.d.ts +2 -0
  4. package/dist/__tests__/carrier2.test.d.ts.map +1 -0
  5. package/dist/__tests__/carrier2.test.js +172 -0
  6. package/dist/__tests__/carrier2.test.js.map +1 -0
  7. package/dist/__tests__/ceiling.test.js +3 -2
  8. package/dist/__tests__/ceiling.test.js.map +1 -1
  9. package/dist/__tests__/settlement.test.d.ts +12 -0
  10. package/dist/__tests__/settlement.test.d.ts.map +1 -0
  11. package/dist/__tests__/settlement.test.js +185 -0
  12. package/dist/__tests__/settlement.test.js.map +1 -0
  13. package/dist/carrier-assemble.d.ts +33 -0
  14. package/dist/carrier-assemble.d.ts.map +1 -0
  15. package/dist/carrier-assemble.js +57 -0
  16. package/dist/carrier-assemble.js.map +1 -0
  17. package/dist/carrier-verify.d.ts +47 -1
  18. package/dist/carrier-verify.d.ts.map +1 -1
  19. package/dist/carrier-verify.js +292 -53
  20. package/dist/carrier-verify.js.map +1 -1
  21. package/dist/carrier.d.ts +93 -3
  22. package/dist/carrier.d.ts.map +1 -1
  23. package/dist/carrier.js +144 -19
  24. package/dist/carrier.js.map +1 -1
  25. package/dist/ceiling.d.ts +9 -1
  26. package/dist/ceiling.d.ts.map +1 -1
  27. package/dist/ceiling.js +16 -6
  28. package/dist/ceiling.js.map +1 -1
  29. package/dist/fuse-member.js +2 -2
  30. package/dist/fuse-member.js.map +1 -1
  31. package/dist/fuse-verify.js +3 -3
  32. package/dist/fuse-verify.js.map +1 -1
  33. package/dist/fuse.d.ts +34 -2
  34. package/dist/fuse.d.ts.map +1 -1
  35. package/dist/fuse.js +83 -6
  36. package/dist/fuse.js.map +1 -1
  37. package/dist/index.d.ts +10 -3
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +9 -2
  40. package/dist/index.js.map +1 -1
  41. package/dist/nitro.d.ts +128 -0
  42. package/dist/nitro.d.ts.map +1 -0
  43. package/dist/nitro.js +551 -0
  44. package/dist/nitro.js.map +1 -0
  45. package/dist/settlement.d.ts +114 -0
  46. package/dist/settlement.d.ts.map +1 -0
  47. package/dist/settlement.js +194 -0
  48. package/dist/settlement.js.map +1 -0
  49. package/package.json +1 -1
  50. package/src/__tests__/carrier.test.ts +18 -0
  51. package/src/__tests__/carrier2.test.ts +193 -0
  52. package/src/__tests__/ceiling.test.ts +3 -2
  53. package/src/__tests__/fixtures/carrier2/ceiling-26088459.witness.json +1 -0
  54. package/src/__tests__/fixtures/carrier2/ceiling-4548.anchor.json +1 -0
  55. package/src/__tests__/fixtures/carrier2/demo4546.ceiling.json +106 -0
  56. package/src/__tests__/fixtures/carrier2/demo4546.proof.json +47 -0
  57. package/src/__tests__/fixtures/carrier2/demo4546.txt +29 -0
  58. package/src/__tests__/fixtures/carrier2/floor-26088457.witness.json +1 -0
  59. package/src/__tests__/fixtures/carrier2/floor-4542.anchor.json +1 -0
  60. package/src/__tests__/fixtures/settlement/pointer-51979918-tx1.json +39 -0
  61. package/src/__tests__/fixtures/settlement/pointer-51979918.json +69 -0
  62. package/src/__tests__/settlement.test.ts +215 -0
  63. package/src/carrier-assemble.ts +74 -0
  64. package/src/carrier-verify.ts +328 -47
  65. package/src/carrier.ts +174 -18
  66. package/src/ceiling.ts +15 -6
  67. package/src/fuse-member.ts +2 -2
  68. package/src/fuse-verify.ts +3 -3
  69. package/src/fuse.ts +93 -6
  70. package/src/index.ts +30 -2
  71. package/src/nitro.ts +602 -0
  72. package/src/settlement.ts +263 -0
package/src/carrier.ts CHANGED
@@ -22,14 +22,25 @@
22
22
  * the carrier as recorded — the bytes inside it are.
23
23
  *
24
24
  * THE TIME WINDOW. The payload always carries the floor: the anchor the
25
- * enclave signed into the slot (`commit.slotAnchor`, present since enclave
26
- * v7) plus that block's header, so "placed no earlier than this block" checks
27
- * offline by identity. The ceiling cannot exist when the carrier is written —
25
+ * enclave fixed at slot allocation and signed at commit (`commit.slotAnchor`,
26
+ * present since enclave v7) plus that block's header, so the header checks
27
+ * offline against the signed hash; that the block is on Ethereum is one
28
+ * lookup anywhere. The ceiling cannot exist when the carrier is written —
28
29
  * the anchor that follows the commit has not landed yet — so it is either
29
30
  * `present` (stamped in later from public data) or `unfetched`, stated in so
30
31
  * many words. There is no third state, and absence of the field is a corrupt
31
32
  * block, not a missing bound.
32
33
  *
34
+ * bitgraph-carrier/2 (2026-09-30) keeps everything above and adds, in the same
35
+ * block: the ceiling in TIME (the bitgraph-ceiling/1 sidecar: a Base block the
36
+ * record existed by), its settlement on Ethereum when known (a
37
+ * bitgraph-settlement/1 pointer: the Ethereum block that committed the batch
38
+ * data), the AWS attestation laid out as openssl-checkable evidence
39
+ * (aws-nitro-witness/1), and the pins the file was made under (PCR0, the
40
+ * ceiling writer, the chains), which a verifier compares with ITS OWN list and
41
+ * never reads as authority. A reader that knows only v1 reports an unknown
42
+ * version (UNDETERMINED), never a verdict.
43
+ *
33
44
  * ⚠️ TWO BYTE-IDENTICAL COPIES OF THIS FILE EXIST, on purpose:
34
45
  * packages/verify/src/carrier.ts (canonical, published with the package)
35
46
  * website/src/lib/carrier.ts (the site cannot import unpublished code)
@@ -51,10 +62,16 @@ export const CARRIER_OVERHEAD = 24;
51
62
  export const MAX_CARRIER_PAYLOAD = 8 * 1024 * 1024;
52
63
 
53
64
  export const CARRIER_VERSION = "bitgraph-carrier/1";
65
+ export const CARRIER_VERSION_2 = "bitgraph-carrier/2";
66
+ export type CarrierVersion = typeof CARRIER_VERSION | typeof CARRIER_VERSION_2;
67
+ /** The sidecar and pointer formats a v2 block carries; their shapes are checked by their own modules. */
68
+ export const CEILING_SIDECAR_VERSION = "bitgraph-ceiling/1";
69
+ export const SETTLEMENT_POINTER_VERSION = "bitgraph-settlement/1";
70
+ export const ATTESTATION_WITNESS_VERSION = "aws-nitro-witness/1";
54
71
 
55
72
  /* ── The payload ────────────────────────────────────────────────────────── */
56
73
 
57
- /** The raw Ethereum block header, so the block's identity and time check offline. */
74
+ /** The raw Ethereum block header: offline it matches the signed hash and gives the block's time; that it is Ethereum's own block is one lookup. */
58
75
  export interface CarrierWitness {
59
76
  headerRlpHex: string;
60
77
  blockNumber: number;
@@ -85,12 +102,39 @@ export type CarrierCeiling =
85
102
  witness: CarrierWitness;
86
103
  };
87
104
 
105
+ /** v2: the ceiling in time, a Base block the record existed by, carried as the bitgraph-ceiling/1 sidecar. */
106
+ export type CarrierCeilingInTime =
107
+ | { status: "unfetched"; searched?: { at: string } }
108
+ | { status: "present"; sidecar: Record<string, unknown> };
109
+
110
+ /** v2: the Ethereum block that committed the Base batch data, as a bitgraph-settlement/1 pointer. Blob bytes travel beside the package, not here. */
111
+ export type CarrierSettlement =
112
+ | { status: "unfetched" }
113
+ | { status: "present"; pointer: Record<string, unknown> };
114
+
115
+ /** v2: what the file was made under. Declared only; a verifier compares with its own pins. */
116
+ export interface CarrierPins {
117
+ pcr0?: string;
118
+ enclave?: string;
119
+ ceilingWriter?: string;
120
+ chains?: { ethereum?: number; base?: number };
121
+ }
122
+
88
123
  export interface CarrierPayload {
89
- carrier: typeof CARRIER_VERSION;
124
+ carrier: CarrierVersion;
90
125
  /** The bitgraph/1 proof exactly as the commit returned it. */
91
126
  proof: CarrierProof;
92
127
  floor: CarrierFloor;
128
+ /** The ceiling in position: the next anchor in the chain. Every proof ever made has one. */
93
129
  ceiling: CarrierCeiling;
130
+ /** v2 only. Required on a v2 block, so absence reads as a corrupt block, never as "no ceiling". */
131
+ ceilingInTime?: CarrierCeilingInTime;
132
+ /** v2 only, optional. */
133
+ settlement?: CarrierSettlement;
134
+ /** v2 only, optional. */
135
+ pins?: CarrierPins;
136
+ /** v2 only, optional: the proof's attestation as aws-nitro-witness/1 evidence. */
137
+ attestation?: Record<string, unknown>;
94
138
  }
95
139
 
96
140
  export type CarrierParse =
@@ -187,7 +231,8 @@ export function buildCarrier(inner: Uint8Array, payload: CarrierPayload): Uint8A
187
231
  function payloadShapeError(p: unknown): string | null {
188
232
  const o = record(p);
189
233
  if (o === null) return "payload is not an object";
190
- if (o["carrier"] !== CARRIER_VERSION) return `unknown carrier version ${JSON.stringify(o["carrier"])}`;
234
+ const v2 = o["carrier"] === CARRIER_VERSION_2;
235
+ if (o["carrier"] !== CARRIER_VERSION && !v2) return `unknown carrier version ${JSON.stringify(o["carrier"])}`;
191
236
  if (record(o["proof"]) === null) return "payload carries no proof object";
192
237
  const floor = record(o["floor"]);
193
238
  if (floor === null || floor["status"] !== "present") return "floor must be present: a floorless carrier is not a not-before";
@@ -198,17 +243,44 @@ function payloadShapeError(p: unknown): string | null {
198
243
  }
199
244
  const ceil = record(o["ceiling"]);
200
245
  if (ceil === null) return "ceiling is missing: absence must be a stated fact, not a missing key";
201
- if (ceil["status"] === "unfetched") return null;
202
- if (ceil["status"] !== "present") return `ceiling status must be "unfetched" or "present", got ${JSON.stringify(ceil["status"])}`;
203
- if (ceil["basis"] !== "counter-order") return `unknown ceiling basis ${JSON.stringify(ceil["basis"])}`;
204
- if (record(ceil["anchor"]) === null) return "ceiling carries no anchor proof";
205
- const cw = record(ceil["witness"]);
206
- if (cw === null || typeof cw["headerRlpHex"] !== "string" || typeof cw["blockNumber"] !== "number" || typeof cw["blockHash"] !== "string") {
207
- return "ceiling carries no readable block-header witness";
246
+ if (ceil["status"] !== "unfetched") {
247
+ if (ceil["status"] !== "present") return `ceiling status must be "unfetched" or "present", got ${JSON.stringify(ceil["status"])}`;
248
+ if (ceil["basis"] !== "counter-order") return `unknown ceiling basis ${JSON.stringify(ceil["basis"])}`;
249
+ if (record(ceil["anchor"]) === null) return "ceiling carries no anchor proof";
250
+ const cw = record(ceil["witness"]);
251
+ if (cw === null || typeof cw["headerRlpHex"] !== "string" || typeof cw["blockNumber"] !== "number" || typeof cw["blockHash"] !== "string") {
252
+ return "ceiling carries no readable block-header witness";
253
+ }
254
+ }
255
+ if (!v2) return null;
256
+ // v2: the ceiling in time is stated either way; settlement, pins and the attestation witness are optional.
257
+ const ct = record(o["ceilingInTime"]);
258
+ if (ct === null) return "ceilingInTime is missing: a v2 block states the ceiling in time or that it was not fetched";
259
+ if (ct["status"] === "present") {
260
+ const sc = record(ct["sidecar"]);
261
+ if (sc === null || sc["version"] !== CEILING_SIDECAR_VERSION) return `ceilingInTime carries no ${CEILING_SIDECAR_VERSION} sidecar`;
262
+ } else if (ct["status"] !== "unfetched") return `ceilingInTime status must be "unfetched" or "present", got ${JSON.stringify(ct["status"])}`;
263
+ if (o["settlement"] !== undefined) {
264
+ const st = record(o["settlement"]);
265
+ if (st === null) return "settlement is not an object";
266
+ if (st["status"] === "present") {
267
+ const pt = record(st["pointer"]);
268
+ if (pt === null || pt["version"] !== SETTLEMENT_POINTER_VERSION) return `settlement carries no ${SETTLEMENT_POINTER_VERSION} pointer`;
269
+ } else if (st["status"] !== "unfetched") return `settlement status must be "unfetched" or "present", got ${JSON.stringify(st["status"])}`;
270
+ }
271
+ if (o["pins"] !== undefined && record(o["pins"]) === null) return "pins is not an object";
272
+ if (o["attestation"] !== undefined) {
273
+ const at = record(o["attestation"]);
274
+ if (at === null || at["format"] !== ATTESTATION_WITNESS_VERSION) return `attestation is not an ${ATTESTATION_WITNESS_VERSION} witness`;
208
275
  }
209
276
  return null;
210
277
  }
211
278
 
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;
282
+ }
283
+
212
284
  export function parseCarrier(bytes: Uint8Array): CarrierParse {
213
285
  if (bytes.length < CARRIER_OVERHEAD + 2) return { kind: "none" };
214
286
  if (!magicAt(bytes, bytes.length - 8)) return { kind: "none" };
@@ -260,6 +332,64 @@ export function completeCarrier(
260
332
  return { changed: true, bytes: buildCarrier(p.inner, payload) };
261
333
  }
262
334
 
335
+ /**
336
+ * v2: stamp the ceiling in time (a verified bitgraph-ceiling/1 sidecar) into a
337
+ * carrier, or record that a completion looked and found none yet. Pure; the
338
+ * caller verifies the sidecar BEFORE stamping. Never overwrites a present one
339
+ * that differs (a conflicting embedded ceiling is evidence worth keeping); the
340
+ * same one again is a no-op. A v1 block is left alone: it has no such field.
341
+ */
342
+ export function completeCarrierInTime(
343
+ bytes: Uint8Array,
344
+ sidecar: Record<string, unknown> | null,
345
+ searched?: { at: string },
346
+ ): { changed: boolean; bytes: Uint8Array; error?: string } {
347
+ const p = parseCarrier(bytes);
348
+ 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" };
350
+ const cur = p.payload.ceilingInTime;
351
+ if (cur && cur.status === "present") {
352
+ if (sidecar === null) return { changed: false, bytes };
353
+ const a = record(cur.sidecar["anchor"]), b = record(sidecar["anchor"]);
354
+ const same = a !== null && b !== null && a["txHash"] === b["txHash"] && String(a["blockHash"] ?? "").toLowerCase() === String(b["blockHash"] ?? "").toLowerCase();
355
+ return same ? { changed: false, bytes } : { changed: false, bytes, error: "carrier already holds a different ceiling in time; refusing to overwrite it" };
356
+ }
357
+ if (sidecar === null && !searched) return { changed: false, bytes };
358
+ const payload: CarrierPayload = {
359
+ ...p.payload,
360
+ ceilingInTime: sidecar === null ? { status: "unfetched", ...(searched ? { searched } : {}) } : { status: "present", sidecar },
361
+ };
362
+ return { changed: true, bytes: buildCarrier(p.inner, payload) };
363
+ }
364
+
365
+ /**
366
+ * v2: the settlement part a verified bitgraph-ceiling/1 sidecar carries, when
367
+ * the writer has attached its bitgraph-settlement/1 pointer; undefined before
368
+ * that. Builders and completions call this so the pointer travels with the
369
+ * ceiling it settles.
370
+ */
371
+ export function settlementFromSidecar(sidecar: Record<string, unknown> | null | undefined): Extract<CarrierSettlement, { status: "present" }> | undefined {
372
+ const p = sidecar ? record(sidecar["settlement"]) : null;
373
+ return p !== null && p["version"] === SETTLEMENT_POINTER_VERSION ? { status: "present", pointer: p } : undefined;
374
+ }
375
+
376
+ /** v2: stamp a verified settlement pointer. Never overwrites a present one that differs. */
377
+ export function completeCarrierSettlement(
378
+ bytes: Uint8Array,
379
+ pointer: Record<string, unknown>,
380
+ ): { changed: boolean; bytes: Uint8Array; error?: string } {
381
+ const p = parseCarrier(bytes);
382
+ 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" };
384
+ const cur = p.payload.settlement;
385
+ if (cur && cur.status === "present") {
386
+ const a = record(cur.pointer["l1"]), b = record(pointer["l1"]);
387
+ const same = a !== null && b !== null && a["txHash"] === b["txHash"] && String(a["blockHash"] ?? "").toLowerCase() === String(b["blockHash"] ?? "").toLowerCase();
388
+ return same ? { changed: false, bytes } : { changed: false, bytes, error: "carrier already holds a different settlement; refusing to overwrite it" };
389
+ }
390
+ return { changed: true, bytes: buildCarrier(p.inner, { ...p.payload, settlement: { status: "present", pointer } }) };
391
+ }
392
+
263
393
  /* ── Consistency checks (no network, no signatures — bindings only) ─────── */
264
394
 
265
395
  /** The identity an authenticated anchor proof claims: enclave-signed since v7. */
@@ -457,18 +587,44 @@ export function verifyWitnessHeader(w: CarrierWitness): WitnessCheck {
457
587
 
458
588
  export interface CarrierBounds {
459
589
  notBefore: { blockNumber: number; blockHash: string; timestamp: number | null };
460
- /** null means NOT FETCHED — say so in those words — never "none exists". */
590
+ /** The ceiling in POSITION: the next anchor. null means NOT FETCHED — say so in those words — never "none exists". */
461
591
  notAfter: { blockNumber: number; blockHash: string; timestamp: number | null } | null;
592
+ /**
593
+ * v2: the ceiling in TIME, as the sidecar states it (verifyCarrier recomputes
594
+ * it from the header). null on a v1 block or when not fetched.
595
+ */
596
+ existedBy: { chain: "base"; blockNumber: number; blockHash: string; timestamp: number } | null;
597
+ /** v2: the Ethereum block that committed the Base batch data, as the pointer states it. */
598
+ settledBy: { chain: "ethereum"; blockNumber: number; blockHash: string; timestamp: number } | null;
462
599
  }
463
600
 
464
601
  export function carrierBounds(payload: CarrierPayload): CarrierBounds {
465
602
  const f = payload.floor.witness;
466
603
  const floorTs = verifyWitnessHeader(f);
467
604
  const notBefore = { blockNumber: f.blockNumber, blockHash: f.blockHash.toLowerCase(), timestamp: floorTs.ok ? floorTs.timestamp : null };
468
- if (payload.ceiling.status !== "present") return { notBefore, notAfter: null };
469
- const c = payload.ceiling.witness;
470
- const ceilTs = verifyWitnessHeader(c);
471
- return { notBefore, notAfter: { blockNumber: c.blockNumber, blockHash: c.blockHash.toLowerCase(), timestamp: ceilTs.ok ? ceilTs.timestamp : null } };
605
+ let notAfter: CarrierBounds["notAfter"] = null;
606
+ if (payload.ceiling.status === "present") {
607
+ const c = payload.ceiling.witness;
608
+ const ceilTs = verifyWitnessHeader(c);
609
+ notAfter = { blockNumber: c.blockNumber, blockHash: c.blockHash.toLowerCase(), timestamp: ceilTs.ok ? ceilTs.timestamp : null };
610
+ }
611
+ let existedBy: CarrierBounds["existedBy"] = null;
612
+ const ct = payload.ceilingInTime;
613
+ if (ct && ct.status === "present") {
614
+ const a = record(ct.sidecar["anchor"]);
615
+ if (a && typeof a["blockNumber"] === "number" && typeof a["blockHash"] === "string" && typeof a["blockTimestamp"] === "number") {
616
+ existedBy = { chain: "base", blockNumber: a["blockNumber"], blockHash: a["blockHash"].toLowerCase(), timestamp: a["blockTimestamp"] };
617
+ }
618
+ }
619
+ let settledBy: CarrierBounds["settledBy"] = null;
620
+ const st = payload.settlement;
621
+ if (st && st.status === "present") {
622
+ const l1 = record(st.pointer["l1"]);
623
+ if (l1 && typeof l1["blockNumber"] === "number" && typeof l1["blockHash"] === "string" && typeof l1["blockTimestamp"] === "number") {
624
+ settledBy = { chain: "ethereum", blockNumber: l1["blockNumber"], blockHash: l1["blockHash"].toLowerCase(), timestamp: l1["blockTimestamp"] };
625
+ }
626
+ }
627
+ return { notBefore, notAfter, existedBy, settledBy };
472
628
  }
473
629
 
474
630
  /** SHA-256 of the committed bytes, compared to the carried proof's artifact digest. */
package/src/ceiling.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * A ceiling in TIME for a BitGraph, carried beside the proof, never inside it.
5
5
  *
6
- * Every BitGraph already has a floor in time (the Ethereum block fused in at
7
- * slot allocation, `commit.slotAnchor`) and a ceiling in POSITION (the
6
+ * Every BitGraph already has a floor in time (the Ethereum block the enclave
7
+ * fixes at slot allocation and signs at commit, `commit.slotAnchor`) and a ceiling in POSITION (the
8
8
  * anchors that follow it in the chain). This adds the one thing a record
9
9
  * cannot supply for itself: something outside the operator's control that
10
10
  * depends on the record. After a commit, a writer puts a Merkle root over
@@ -165,10 +165,19 @@ function hhmmss(unix: number): string {
165
165
  return new Date(unix * 1000).toISOString().slice(11, 19);
166
166
  }
167
167
 
168
- export function ceilingLabel(status: CeilingStatus, blockNumber: number, blockTimestamp: number): string {
168
+ /**
169
+ * One line for people. It states what this check establishes, the transaction's
170
+ * inclusion in a Base block whose header is given, and never more: the sidecar's
171
+ * `status` is what BitGraph's Base node reported when the file was written, an
172
+ * observation the file cannot prove (an outside review on 2026-09-30 changed
173
+ * it to "finalized" and every offline check still passed). Settlement is proven
174
+ * only by a bitgraph-settlement/1 pointer, checked by verifySettlementPointer.
175
+ */
176
+ export function ceilingLabel(status: CeilingStatus, blockNumber: number, blockTimestamp: number, hasSettlementPointer = false): string {
169
177
  const at = `Base block ${blockNumber.toLocaleString("en-US")} at ${hhmmss(blockTimestamp)} UTC`;
170
- if (status === "safe" || status === "finalized") return `Ceiling: ${at}, settled on Ethereum.`;
171
- return `Ceiling: ${at}. Relies on Base's sequencer until settled on Ethereum.`;
178
+ if (hasSettlementPointer) return `Ceiling: included in ${at}. A settlement pointer to Ethereum is attached; check it with verifySettlementPointer.`;
179
+ if (status === "safe" || status === "finalized") return `Ceiling: included in ${at}. BitGraph's Base node reported the block "${status}" when this file was written; that report is not proven here, and no settlement evidence is attached.`;
180
+ return `Ceiling: included in ${at}. Relies on Base's sequencer until its batch data is on Ethereum; no settlement evidence is attached.`;
172
181
  }
173
182
 
174
183
  /**
@@ -302,7 +311,7 @@ export async function verifyCeiling(
302
311
  ceiling: { chainId: a.chainId, blockNumber: header.number, blockHash: header.hash, blockTimestamp: header.timestamp },
303
312
  widthSeconds: width,
304
313
  },
305
- label: ceilingLabel(status, header.number, header.timestamp),
314
+ label: ceilingLabel(status, header.number, header.timestamp, typeof (sidecar as { settlement?: unknown }).settlement === "object" && (sidecar as { settlement?: unknown }).settlement !== null),
306
315
  headerCheckedAgainstChain: false,
307
316
  };
308
317
  }
@@ -47,7 +47,7 @@ import {
47
47
  bytesEqual,
48
48
  bytesToBase64,
49
49
  bytesToHex,
50
- computeSlotCommitment,
50
+ commitmentForProof,
51
51
  getPlacement,
52
52
  PLACEMENTS,
53
53
  parseSetManifest,
@@ -388,7 +388,7 @@ export async function verifyFuseMember(opts: FuseMemberOptions): Promise<FuseMem
388
388
  }
389
389
  let commitment: Uint8Array;
390
390
  try {
391
- commitment = computeSlotCommitment(slot);
391
+ commitment = commitmentForProof(proof, slot);
392
392
  } catch (err) {
393
393
  return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
394
394
  }
@@ -30,7 +30,7 @@ import type { BitGraphProof, VerificationPolicy } from "./types.js";
30
30
  import {
31
31
  bytesEqual,
32
32
  bytesToBase64,
33
- computeSlotCommitment,
33
+ commitmentForProof,
34
34
  findCommitment,
35
35
  getPlacement,
36
36
  isCarryEncoding,
@@ -233,7 +233,7 @@ export async function verifyFuse(opts: FuseVerifyOptions): Promise<FuseVerifyRes
233
233
  }
234
234
  let expected: Uint8Array;
235
235
  try {
236
- expected = computeSlotCommitment(slot);
236
+ expected = commitmentForProof(proof, slot);
237
237
  } catch (err) {
238
238
  return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
239
239
  }
@@ -314,7 +314,7 @@ export async function verifyFuse(opts: FuseVerifyOptions): Promise<FuseVerifyRes
314
314
  }
315
315
  let commitment: Uint8Array;
316
316
  try {
317
- commitment = computeSlotCommitment(slot);
317
+ commitment = commitmentForProof(proof, slot);
318
318
  } catch (err) {
319
319
  return base("INVALID_SLOT_COMMITMENT", common, `commitment could not be recomputed: ${err instanceof Error ? err.message : String(err)}`);
320
320
  }
package/src/fuse.ts CHANGED
@@ -176,6 +176,90 @@ export function computeSlotCommitment(slot: SlotAllocation): Uint8Array {
176
176
  return sha256(slotCommitmentPreimage(slot));
177
177
  }
178
178
 
179
+ // ---------------------------------------------------------------------------
180
+ // bitgraph-fuse/2 (2026-09-30): the commitment also binds the floor block.
181
+ //
182
+ // commitment/2 = SHA256(UTF8("bitgraph-fuse/2") || 0x00 || slotRecordHash || nonce || floorBlockHash)
183
+ //
184
+ // floorBlockHash is the 32 raw bytes of the Ethereum block hash the enclave
185
+ // signs into the proof as commit.slotAnchor.blockHash (enclave v9 returns it
186
+ // with the allocation, so a producer knows it before finishing the file). A
187
+ // file carrying commitment/2 could not have been finished before that block
188
+ // existed, by hash alone: the floor under the file's content no longer rests
189
+ // on the enclave's counter. Everything else is fuse/1's: the placements, the
190
+ // payload formats and the set documents carry the 32-byte commitment and do
191
+ // not change. A proof is fuse/2 exactly when its SIGNED attribution name says
192
+ // so; a fuse/1 verifier sees an ordinary proof and says nothing about the file.
193
+ // ---------------------------------------------------------------------------
194
+
195
+ export const FUSE2_PROFILE = "bitgraph-fuse/2" as const;
196
+ export const FUSE2_ATTRIBUTION_NAME = FUSE2_PROFILE;
197
+
198
+ /** "bitgraph-fuse/2" followed by one zero byte. */
199
+ export const FUSE2_DOMAIN: Uint8Array = (() => {
200
+ const label = new TextEncoder().encode(FUSE2_PROFILE);
201
+ const out = new Uint8Array(label.length + 1);
202
+ out.set(label, 0);
203
+ out[label.length] = 0x00;
204
+ return out;
205
+ })();
206
+
207
+ /** Which commitment a fused proof's signed marker declares: 1, 2, or null when the proof is not fused. */
208
+ export function fuseVersionOfName(name: unknown): 1 | 2 | null {
209
+ return name === FUSE_ATTRIBUTION_NAME ? 1 : name === FUSE2_ATTRIBUTION_NAME ? 2 : null;
210
+ }
211
+
212
+ /** True for either fused marker name. Use this, never a string compare against one version. */
213
+ export function isFuseMarkerName(name: unknown): boolean {
214
+ return fuseVersionOfName(name) !== null;
215
+ }
216
+
217
+ function floorHashBytes(floorBlockHash: string | Uint8Array): Uint8Array {
218
+ const b = typeof floorBlockHash === "string" ? hexToBytes(floorBlockHash.toLowerCase().replace(/^0x/, "")) : floorBlockHash;
219
+ if (b === null || b.length !== 32) throw new TypeError("the floor block hash must be 32 bytes");
220
+ return b;
221
+ }
222
+
223
+ /** The exact preimage of commitment/2: domain || slotRecordHash || nonce || floorBlockHash. */
224
+ export function slotCommitment2Preimage(slot: SlotAllocation, floorBlockHash: string | Uint8Array): Uint8Array {
225
+ const nonce = base64ToBytes(slot.nonceB64);
226
+ if (nonce === null || nonce.length !== 32) {
227
+ throw new TypeError("slot.nonceB64 must decode to exactly 32 bytes");
228
+ }
229
+ return concat(FUSE2_DOMAIN, computeSlotRecordHash(slot), nonce, floorHashBytes(floorBlockHash));
230
+ }
231
+
232
+ /** commitment/2 = SHA256(domain/2 || slotRecordHash || nonce || floorBlockHash). */
233
+ export function computeSlotCommitment2(slot: SlotAllocation, floorBlockHash: string | Uint8Array): Uint8Array {
234
+ return sha256(slotCommitment2Preimage(slot, floorBlockHash));
235
+ }
236
+
237
+ /**
238
+ * The commitment a fused proof's bytes must carry, chosen by its signed marker:
239
+ * fuse/2 binds the proof's own signed commit.slotAnchor block, fuse/1 does not.
240
+ * Throws when a fuse/2 proof has no signed floor to bind.
241
+ */
242
+ export function commitmentForProof(proof: BitGraphProof, slot: SlotAllocation): Uint8Array {
243
+ if (fuseVersionOfName(proof.attribution?.name) === 2) {
244
+ const hash = proof.commit?.slotAnchor?.blockHash;
245
+ if (typeof hash !== "string") throw new TypeError("a bitgraph-fuse/2 proof must carry a signed commit.slotAnchor to bind");
246
+ return computeSlotCommitment2(slot, hash);
247
+ }
248
+ return computeSlotCommitment(slot);
249
+ }
250
+
251
+ /**
252
+ * The commitment a PRODUCER writes into new bytes, from what the allocation
253
+ * returned: fuse/2 when the enclave handed back its floor anchor (v9 and
254
+ * later), else fuse/1. The attribution name must be chosen to match; see
255
+ * fuseAttribution's version argument.
256
+ */
257
+ export function producerCommitment(slot: SlotAllocation, floor?: { blockHash: string } | null): { commitment: Uint8Array; version: 1 | 2 } {
258
+ return floor && typeof floor.blockHash === "string"
259
+ ? { commitment: computeSlotCommitment2(slot, floor.blockHash), version: 2 }
260
+ : { commitment: computeSlotCommitment(slot), version: 1 };
261
+ }
262
+
179
263
  // ---------------------------------------------------------------------------
180
264
  // Form C canonical payload
181
265
  // ---------------------------------------------------------------------------
@@ -907,11 +991,11 @@ export function getPlacement(id: string): Placement | undefined {
907
991
  * set/1 refuses an origin digest: a set/1 marker carrying one is out of
908
992
  * profile and verifyFuseMember refuses it.
909
993
  */
910
- export function fuseAttribution(placement: PlacementId, originDigest?: Uint8Array): Attribution {
994
+ export function fuseAttribution(placement: PlacementId, originDigest?: Uint8Array, version: 1 | 2 = 1): Attribution {
911
995
  if (originDigest !== undefined && originDigest.length !== 32) throw new TypeError("originDigest must be 32 bytes");
912
996
  if ((placement === SET_PLACEMENT_ID || placement === SET2_PLACEMENT_ID) && originDigest !== undefined) throw new TypeError(`${placement} has no single origin; a set marker carries no origin digest`);
913
997
  return {
914
- name: FUSE_ATTRIBUTION_NAME,
998
+ name: version === 2 ? FUSE2_ATTRIBUTION_NAME : FUSE_ATTRIBUTION_NAME,
915
999
  title: placement,
916
1000
  ...(originDigest !== undefined ? { message: bytesToBase64(originDigest) } : {}),
917
1001
  };
@@ -933,6 +1017,8 @@ export interface FuseMarker {
933
1017
  originSource?: MarkerSource;
934
1018
  /** "attribution" when the proof's signed attribution marks it fused, else "manifest". */
935
1019
  source: MarkerSource;
1020
+ /** Which commitment the signed marker declares; absent on a manifest-only marker, which means 1. */
1021
+ version?: 1 | 2;
936
1022
  }
937
1023
 
938
1024
  /** Read the fused marker from a proof's signed attribution, or null when the proof is not marked fused. */
@@ -983,15 +1069,16 @@ export function findCommitment(bytes: Uint8Array, commitment: Uint8Array, encodi
983
1069
  }
984
1070
 
985
1071
  /** The attribution a producer sends for an artifact made with the commitment inside it. */
986
- export function inlineAttribution(): { name: string; title: string } {
987
- return { name: FUSE_ATTRIBUTION_NAME, title: ENCODING_BASE64URL };
1072
+ export function inlineAttribution(version: 1 | 2 = 1): { name: string; title: string } {
1073
+ return { name: version === 2 ? FUSE2_ATTRIBUTION_NAME : FUSE_ATTRIBUTION_NAME, title: ENCODING_BASE64URL };
988
1074
  }
989
1075
 
990
1076
  export function readFuseAttribution(proof: BitGraphProof): FuseMarker | null {
991
1077
  const a = proof.attribution;
992
- if (a === undefined || a.name !== FUSE_ATTRIBUTION_NAME) return null;
1078
+ const version = fuseVersionOfName(a?.name);
1079
+ if (a === undefined || version === null) return null;
993
1080
  const declared = typeof a.title === "string" && a.title.length > 0;
994
- const marker: FuseMarker = { placement: declared ? (a.title as string) : null, placementSource: declared ? "attribution" : null, source: "attribution" };
1081
+ const marker: FuseMarker = { placement: declared ? (a.title as string) : null, placementSource: declared ? "attribution" : null, source: "attribution", version };
995
1082
  if (typeof a.message === "string" && a.message.length > 0) {
996
1083
  const d = base64ToBytes(a.message);
997
1084
  // A message that is not a digest is still a fused marker; the origin is simply undeclared.
package/src/index.ts CHANGED
@@ -59,6 +59,15 @@ export {
59
59
  computeSlotRecordHash,
60
60
  slotCommitmentPreimage,
61
61
  computeSlotCommitment,
62
+ FUSE2_PROFILE,
63
+ FUSE2_DOMAIN,
64
+ FUSE2_ATTRIBUTION_NAME,
65
+ fuseVersionOfName,
66
+ isFuseMarkerName,
67
+ slotCommitment2Preimage,
68
+ computeSlotCommitment2,
69
+ commitmentForProof,
70
+ producerCommitment,
62
71
  buildFusePayload,
63
72
  parseFusePayload,
64
73
  fuseAttribution,
@@ -100,8 +109,27 @@ export type {
100
109
  CarrierWitness, CarrierProof, CarrierFloor, CarrierCeiling, CarrierPayload,
101
110
  CarrierParse, WitnessCheck, CarrierBounds,
102
111
  } from "./carrier.js";
103
- export { verifyCarrier } from "./carrier-verify.js";
104
- export type { CarrierVerifyResult } from "./carrier-verify.js";
112
+ export { verifyCarrier, verifyCarrierPayload, BITGRAPH_CEILING_WRITER, BASE_MAINNET_CHAIN_ID } from "./carrier-verify.js";
113
+ export type { CarrierVerifyResult, CarrierClaim, ClaimResult, CarrierLookups, CarrierVerifyOptions } from "./carrier-verify.js";
114
+
115
+ /* bitgraph-carrier/2 (2026-09-30): the ceiling in time, its settlement, the attestation witness and the declared pins, in the same block. */
116
+ export {
117
+ CARRIER_VERSION_2, CEILING_SIDECAR_VERSION, SETTLEMENT_POINTER_VERSION, ATTESTATION_WITNESS_VERSION,
118
+ carrierVersionOf, completeCarrierInTime, completeCarrierSettlement, settlementFromSidecar,
119
+ } from "./carrier.js";
120
+ export type { CarrierVersion, CarrierCeilingInTime, CarrierSettlement, CarrierPins } from "./carrier.js";
121
+ export { assembleCarrierV2Payload, carrierBlockSize, CARRIER_BLOCK_ZIP_LIMIT } from "./carrier-assemble.js";
122
+ export type { CarrierV2Parts } from "./carrier-assemble.js";
123
+
124
+ /* AWS Nitro attestation: decode, verify (chain to the AWS root, validity at the document's instant), and the openssl-checkable witness. */
125
+ export {
126
+ AWS_NITRO_ROOT_CA_PEM, awsNitroRootDer, awsNitroRootSha256, decodeNitroAttestation, verifyNitroAttestation,
127
+ attestationWitness, witnessMatchesAttestation, encodeSigStructure, rawEcdsaSigToDer, derToPem, pemToDer, ATTESTATION_WITNESS_FORMAT,
128
+ } from "./nitro.js";
129
+ export type { NitroDocument, NitroDecoded, NitroCheck, NitroVerifyOptions, NitroVerifyResult, AttestationWitness } from "./nitro.js";
130
+
131
+ /* Settlement of a Base ceiling on Ethereum: L1 data inclusion (bitgraph-settlement/1). The pointer layer is here; the blob layer is bitgraph-audit's. */
132
+ export * from "./settlement.js";
105
133
 
106
134
  // Ceiling in time on Base (bitgraph-ceiling/1): a sidecar beside the proof, never inside it.
107
135
  export {