@mikeargento/bitgraph-verify 1.31.0 → 1.32.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.
@@ -0,0 +1,114 @@
1
+ // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
+
3
+ /**
4
+ * A BitGraphed file (carrier v5 and v6) around a receipt whose TOT carries a signed floor. The receipt is real: the
5
+ * first of enclave image v14 (spec/vectors/bitgraph-tot-v2-real/), which binds spec/BITGRAPH-TOT-2.md. The carrier
6
+ * needs no change to hold it; these tests pin what its check says about the floor, and that it says nothing stale
7
+ * about block reads and Base writes that such a receipt never had. Every check runs offline.
8
+ *
9
+ * cd packages/verify && npx tsc -p . && node --test dist/__tests__/carrier-tot.test.js
10
+ */
11
+
12
+ import { test } from "node:test";
13
+ import { strict as assert } from "node:assert";
14
+ import { readFileSync } from "node:fs";
15
+ import { buildBitGraphedFileV5, buildBitGraphedFileV6 } from "../carrier5.js";
16
+ import { verifyCarrier } from "../carrier-verify.js";
17
+ import { parseCarrier } from "../carrier.js";
18
+ import { verifyAttested } from "../attested.js";
19
+ import { totFloorOf } from "../tot-floor.js";
20
+ import { slotFormProblem } from "../fuse.js";
21
+ import type { BitGraphProof } from "../types.js";
22
+
23
+ const repo = new URL("../../../../", import.meta.url);
24
+ const file = new Uint8Array(readFileSync(new URL("spec/BITGRAPH-TOT-2.md", repo)));
25
+ const proof = JSON.parse(readFileSync(new URL("spec/vectors/bitgraph-tot-v2-real/receipt.json", repo), "utf8")) as Record<string, unknown>;
26
+ const FLOOR = { network: "eip155:8453", number: "66095720", hashB64: "G9xjlrSMxrcJ6qaehB3xwqagBThiViOlXCUo+Q+Lg/k=" };
27
+ const claimOf = (r: Awaited<ReturnType<typeof verifyCarrier>>, id: string) => r.claims.find((c) => c.id === id);
28
+ const withTot = (change: Record<string, unknown>) => ({ ...proof, slotAllocation: { ...(proof["slotAllocation"] as Record<string, unknown>), ...change } });
29
+
30
+ test("v5 and v6 carry a v14 receipt unchanged, and the check reports the floor signed into its TOT", async () => {
31
+ for (const [version, bg] of [[5, buildBitGraphedFileV5(file, proof, null)], [6, buildBitGraphedFileV6(file, proof, null, null)]] as const) {
32
+ const parsed = parseCarrier(bg);
33
+ assert.equal(parsed.kind === "carrier" ? parsed.inner.length : null, file.length, "stripping the block gives the file back");
34
+ const r = await verifyCarrier(bg);
35
+ assert.equal(r.verdict, "TRUE", r.reasons.join("; "));
36
+ assert.equal(r.version, version);
37
+ assert.deepEqual(r.totFloor, FLOOR);
38
+ const signed = claimOf(r, "floor.signed");
39
+ assert.equal(signed?.result, "TRUE");
40
+ assert.match(String(signed?.detail), /Base block 66095720 \(0x1bdc6396b4…\), signed with the TOT's random number and not looked up here/);
41
+ assert.match(r.reading, /^BitGraph #2: these exact bytes, bound by BitGraph's published enclave image v14\. Its TOT carries a signed floor, Base block 66095720: found there with that hash, the TOT was made after that block\. This file's own SHA-256 /);
42
+ // The floor is signed, not confirmed: no bound is stated from it.
43
+ assert.equal(r.bounds, null);
44
+ }
45
+ });
46
+
47
+ test("nothing stale is said of a v14 receipt: no block read is missed, and no Base write is awaited", async () => {
48
+ const r = await verifyCarrier(buildBitGraphedFileV6(file, proof, null, null));
49
+ assert.equal(claimOf(r, "floor.read"), undefined, "a receipt with a signed floor is not told it lacks a block read");
50
+ const ceiling = claimOf(r, "ceiling.time");
51
+ assert.equal(ceiling?.result, "NOT_CARRIED");
52
+ assert.equal(ceiling?.detail, "none exists: receipts of this enclave image are written to no chain");
53
+ assert.doesNotMatch(r.reading, /Check those blocks/);
54
+ for (const c of r.claims) assert.doesNotMatch(c.detail, /before the Base write landed|without a Base block read/, c.id);
55
+ });
56
+
57
+ test("the bytes and the floor are both held: a changed byte or a changed floor makes the file FALSE", async () => {
58
+ const bg = buildBitGraphedFileV5(file, proof, null);
59
+ const flipped = bg.slice();
60
+ flipped[100] = flipped[100]! ^ 1;
61
+ assert.equal((await verifyCarrier(flipped)).verdict, "FALSE");
62
+ const moved = await verifyCarrier(buildBitGraphedFileV5(file, withTot({ floor: { ...FLOOR, number: "66095721" } }), null));
63
+ assert.equal(moved.verdict, "FALSE");
64
+ assert.equal(moved.totFloor, undefined, "a floor is read only from a proof that verifies");
65
+ assert.equal(claimOf(moved, "floor.signed"), undefined);
66
+ });
67
+
68
+ test("a slot/2 TOT holds exactly its fields: every check refuses an extra one, the carrier's included", async () => {
69
+ const extra = withTot({ note: "made after block 1" });
70
+ assert.equal(slotFormProblem(extra.slotAllocation), "a bitgraph/slot/2 slotAllocation must hold exactly its listed fields");
71
+ assert.equal(totFloorOf(extra as unknown as BitGraphProof), null);
72
+ const direct = await verifyAttested({ proof: extra as unknown as BitGraphProof, bytes: file });
73
+ assert.equal(direct.valid, false);
74
+ assert.match(String(direct.reason), /must hold exactly its listed fields/);
75
+ const carried = await verifyCarrier(buildBitGraphedFileV5(file, extra, null));
76
+ assert.equal(carried.verdict, "FALSE");
77
+ assert.equal(carried.totFloor, undefined);
78
+ // A key with no value is not a field: it is absent from the record's JSON.
79
+ assert.equal(slotFormProblem({ ...(proof["slotAllocation"] as Record<string, unknown>), time: undefined } as Record<string, unknown>), null);
80
+ // A missing field is refused the same way.
81
+ const { chainId: _c, ...short } = proof["slotAllocation"] as Record<string, unknown>;
82
+ assert.match(String(slotFormProblem(short)), /exactly its listed fields/);
83
+ // The receipt as made is in form.
84
+ assert.equal(slotFormProblem(proof["slotAllocation"] as Record<string, unknown>), null);
85
+ assert.equal((await verifyAttested({ proof: proof as unknown as BitGraphProof, bytes: file })).valid, true);
86
+ });
87
+
88
+ test("a caller's own pinned image is judged by its list, so a carrier under test inputs can come out TRUE", async () => {
89
+ const V1 = JSON.parse(readFileSync(new URL("spec/vectors/bitgraph-tot-v1.json", repo), "utf8"));
90
+ const set = V1.sets.find((x: { name: string }) => x.name === "spent-twice");
91
+ const t = set.testTrustInputs;
92
+ const rootDer = new Uint8Array(Buffer.from(t.rootDerB64, "base64"));
93
+ const bg = buildBitGraphedFileV5(new Uint8Array(Buffer.from(set.filesB64[0], "base64")), set.receipts[0], null);
94
+
95
+ const pinned = await verifyCarrier(bg, { pins: { pcr0: t.acceptedMeasurements, rootDer } });
96
+ assert.equal(pinned.verdict, "TRUE", pinned.reasons.join("; "));
97
+ const pins = claimOf(pinned, "attestation.pins");
98
+ assert.deepEqual([pins?.result, pins?.name, pins?.restsOn], ["TRUE", "The image is one the verifier accepts", "the verifier's own list"]);
99
+ assert.doesNotMatch(pinned.reading, /BitGraph's published/);
100
+ assert.match(pinned.reading, /an enclave image on the verifier's list/);
101
+
102
+ // A list without it, and an empty list, never make it TRUE.
103
+ const other = await verifyCarrier(bg, { pins: { pcr0: ["00".repeat(48)], rootDer } });
104
+ assert.notEqual(other.verdict, "TRUE");
105
+ assert.equal(claimOf(other, "attestation.pins")?.result, "FALSE");
106
+ const none = await verifyCarrier(bg, { pins: { pcr0: [], rootDer } });
107
+ assert.notEqual(none.verdict, "TRUE");
108
+ assert.equal(claimOf(none, "attestation.pins")?.result, "UNDETERMINED");
109
+
110
+ // With no pins, the published images are the list, and a test image is not one of them.
111
+ const plain = await verifyCarrier(bg);
112
+ assert.notEqual(plain.verdict, "TRUE");
113
+ assert.equal(claimOf(plain, "attestation.pins")?.name, "The image is one BitGraph published");
114
+ });
@@ -36,7 +36,20 @@ test("the real v6 file checks: the file, the proof, its own Base floor and the B
36
36
  assert.equal(claim(r, "ceiling.time"), "TRUE");
37
37
  assert.equal(r.bounds?.notBefore.blockNumber, 53405648);
38
38
  assert.ok(r.bounds?.existedBy && r.bounds.existedBy.blockNumber > 53405648, "the ceiling is after the floor");
39
- assert.match(r.reading, /BitGraph #304: these exact bytes, .* after Base block 53405648 and written to Base by block/);
39
+ assert.match(r.reading, /BitGraph #304: these exact bytes, .* after Base block 53405648 and written to Base by block \d+\. Check those blocks on Base to place it in real time\. This file's own SHA-256 /);
40
+ assert.equal(r.totFloor, undefined, "a slot/1 receipt signs no floor in its TOT");
41
+ });
42
+
43
+ test("an earlier receipt with nothing carried: the block read and the Base write are named as not carried", async () => {
44
+ const r = await verifyCarrier(buildBitGraphedFileV6(file, proof, null, null));
45
+ assert.equal(r.verdict, "TRUE", r.reasons.join("; "));
46
+ const read = r.claims.find((c) => c.id === "floor.read");
47
+ assert.equal(read?.result, "NOT_CARRIED");
48
+ assert.equal(read?.detail, "this record was bound without a Base block read before it");
49
+ const write = r.claims.find((c) => c.id === "ceiling.time");
50
+ assert.equal(write?.result, "NOT_CARRIED");
51
+ assert.equal(write?.detail, "no Base write is carried with this file; if one was made for this proof, it can be looked up by the proof's hash");
52
+ assert.doesNotMatch(r.reading, /Check those blocks|signed floor/);
40
53
  });
41
54
 
42
55
  test("a v6 file bound without a floor still checks, and says the floor is not carried", async () => {
@@ -53,7 +53,7 @@ import { baseTimeIsBound, checkFloorHeader, floorTimeIsBound, verifyCeiling, che
53
53
  import { hexToBytes as evmHex } from "./ceiling-evm.js";
54
54
  import { PUBLISHED_PCR0S, publishedMeasurement } from "./measurements.js";
55
55
  import { verifySettlementPointer, checkSettlementOnline, BASE_MAINNET_SETTLEMENT_PINS, type SettlementPointer, type SettlementPins } from "./settlement.js";
56
- import type { BitGraphProof } from "./types.js";
56
+ import type { BitGraphProof, SlotFloor } from "./types.js";
57
57
  import { sha256 } from "@noble/hashes/sha256";
58
58
  import { verifyCarrierV5 } from "./carrier5.js";
59
59
  import {
@@ -128,6 +128,11 @@ export interface CarrierVerifyResult {
128
128
  /** The ceiling in position: "none" on v3, where none exists (order is the chain of proof hashes). */
129
129
  ceiling: "present" | "unfetched" | "none" | null;
130
130
  claims: CarrierClaim[];
131
+ /**
132
+ * v5 and v6, on a valid proof whose TOT is a bitgraph/slot/2 record: the floor signed into the TOT. Signed, not
133
+ * looked up: whether its chain holds that block is a separate, online question (checkFloorOnline).
134
+ */
135
+ totFloor?: SlotFloor;
131
136
  /** Plain language, written from the claims. */
132
137
  reading: string;
133
138
  payload: CarrierPayload | null;
package/src/carrier5.ts CHANGED
@@ -18,6 +18,11 @@
18
18
  * the floor block is a leaf of the very tree the proof binds, and the attested bind time is after its timestamp; the
19
19
  * ceiling's batch holds this proof and its transaction is in the Base block it names. Whether those two Base blocks are
20
20
  * on Base's canonical chain is a check against Base (Basescan), not one a file can carry.
21
+ *
22
+ * A proof whose TOT carries a floor under its signature (bitgraph/slot/2, enclave v14 on) needs nothing more in the
23
+ * block: the floor is in the proof. It is reported as signed and not looked up; whether Base holds that block is the
24
+ * same kind of check against Base (checkFloorOnline). Such a proof has no block read before it and no Base write
25
+ * after it, and the result does not speak of either as if one were owed.
21
26
  */
22
27
 
23
28
  import { sha256 } from "@noble/hashes/sha256";
@@ -27,6 +32,7 @@ import { chainLinkMatches } from "./proof-hash.js";
27
32
  import { verifyAttested } from "./attested.js";
28
33
  import { verifyCeiling, type CeilingSidecar } from "./ceiling.js";
29
34
  import { checkTreeFloor, treeMemberOf } from "./tree-member.js";
35
+ import { FLOOR_NETWORKS, floorHashHex, totFloorOf } from "./tot-floor.js";
30
36
  import type { BitGraphProof } from "./types.js";
31
37
  import type { CarrierClaim, CarrierVerifyResult, ClaimResult } from "./carrier-verify.js";
32
38
 
@@ -81,7 +87,19 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
81
87
  else if (member) add("tree.member", "The file is in the tree the proof binds", r.treeMember ? "TRUE" : "FALSE", "SHA-256", r.treeMember ? `file ${r.treeMember.index + 1} of ${r.treeMember.files}: its hash walks up the tree to the root the proof binds` : (r.reason ?? "its hash does not reach the root"));
82
88
  else add("bytes.digest", "The file is the bound bytes", r.valid || !/digest/.test(r.reason ?? "") ? "TRUE" : "FALSE", "SHA-256", "the bytes before the block hash to the proof's digest");
83
89
  for (const c of r.checks) add(`attestation.${c.name.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`, c.name, c.pass ? "TRUE" : "FALSE", "the AWS Nitro attestation", c.detail);
84
- add("attestation.pins", "The image is one BitGraph published", r.image ? "TRUE" : "FALSE", "BitGraph's published enclave images", r.image ? `PCR0 ${String(r.pcr0).slice(0, 16)}… is the ${r.image.version} image` : `PCR0 ${String(r.pcr0 ?? "").slice(0, 16)}… is not one of BitGraph's`);
90
+ if (opts.pcr0 === undefined) {
91
+ add("attestation.pins", "The image is one BitGraph published", r.image ? "TRUE" : "FALSE", "BitGraph's published enclave images", r.image ? `PCR0 ${String(r.pcr0).slice(0, 16)}… is the ${r.image.version} image` : `PCR0 ${String(r.pcr0 ?? "").slice(0, 16)}… is not one of BitGraph's`);
92
+ } else {
93
+ // A caller that names its own images is judged by its own list, as for carriers /1 to /4 and exports.
94
+ const listed = opts.pcr0.map((x) => String(x).toLowerCase());
95
+ const hardwareOk = r.pcr0 !== null && r.checks.length > 0 && r.checks.every((c) => c.pass);
96
+ if (!hardwareOk) add("attestation.pins", "The image is one the verifier accepts", "UNDETERMINED", "", "not judged: the attestation did not verify in full, and a declared measurement is not hardware evidence");
97
+ else if (listed.length === 0) add("attestation.pins", "The image is one the verifier accepts", "UNDETERMINED", "", `no accepted images were given: PCR0 is ${r.pcr0}; any AWS Nitro enclave can produce a valid attestation, and only a measurement policy says whose this is`);
98
+ else {
99
+ const ok = listed.includes(r.pcr0 as string);
100
+ add("attestation.pins", "The image is one the verifier accepts", ok ? "TRUE" : "FALSE", "the verifier's own list", `PCR0 ${String(r.pcr0).slice(0, 16)}… is ${ok ? "" : "not "}on the verifier's list`);
101
+ }
102
+ }
85
103
  add("proof.signature", "The signature, the nonce's record and the two consecutive counts", r.valid ? "TRUE" : "FALSE", "Ed25519", r.valid ? "the enclave's key signed this body" : (r.reason ?? "did not verify"));
86
104
 
87
105
  // 3. The floor: a leaf of the very tree the proof binds, and before the attested bind time.
@@ -96,6 +114,14 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
96
114
  }
97
115
  }
98
116
 
117
+ // 3a. A floor signed into the TOT (bitgraph/slot/2). It is part of what the enclave signed, so a valid proof
118
+ // carries it whole; nothing here asks a chain about it. It says "after", once the block is found on its chain.
119
+ const totFloor = r.valid ? totFloorOf(proof) : null;
120
+ if (totFloor) {
121
+ const net = FLOOR_NETWORKS[totFloor.network]?.name ?? totFloor.network;
122
+ add("floor.signed", "A public floor is signed into the TOT", "TRUE", "Ed25519, the TOT's own signature", `${net} block ${totFloor.number} (${(floorHashHex(totFloor) ?? "").slice(0, 12)}…), signed with the TOT's random number and not looked up here: found on ${net} with that hash, it shows the TOT was made after that block`);
123
+ }
124
+
99
125
  // 3b. v6: the file's own floor. The block read bound on the counts right before the file: its proof is BitGraph's,
100
126
  // it binds its block file, and the file's signed prevB64 is its hash, so nothing was bound between them. The block's
101
127
  // hash could not be known before the block, so the file was bound after it. Whether the block is on Base's canonical
@@ -117,7 +143,7 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
117
143
  add("floor.time", "The bind came after the floor block's time", after ? "TRUE" : "FALSE", "the AWS Nitro attestation's time", after ? `bound ${iso(Math.floor(r.attestedAtMs! / 1000))}, block ${iso(f!.timestamp)}` : "the attested bind time is not after the block's time");
118
144
  notBefore = { chain: "base", blockNumber: f!.number, blockHash: f!.hash, timestamp: f!.timestamp };
119
145
  }
120
- } else if (fl?.status === "none") add("floor.read", "A Base floor", "NOT_CARRIED", "", "this record was bound without a Base block read before it");
146
+ } else if (fl?.status === "none" && !totFloor) add("floor.read", "A Base block read bound right before this file", "NOT_CARRIED", "", "this record was bound without a Base block read before it");
121
147
 
122
148
  // 4. The ceiling: this proof's hash is in the batch the Base transaction carries, and that transaction is in its block.
123
149
  let existedBy: CarrierBounds["existedBy"] = null;
@@ -126,20 +152,28 @@ export async function verifyCarrierV5(payloadIn: CarrierPayload, inner: Uint8Arr
126
152
  const w = c.window?.ceiling;
127
153
  add("ceiling.time", "Written to Base, in a batch from BitGraph's writer", c.ok ? "TRUE" : "FALSE", "Base: the batch root, the transaction and the block header", c.ok && w ? `Base block ${w.blockNumber} (${iso(w.blockTimestamp)}): the proof existed by then` : (c.reason ?? "the ceiling does not verify"));
128
154
  if (c.ok && w) existedBy = { chain: "base", blockNumber: w.blockNumber, blockHash: w.blockHash, timestamp: w.blockTimestamp };
129
- } else add("ceiling.time", "Written to Base", "NOT_CARRIED", "", "this file was made before the Base write landed; the ceiling can be looked up by the proof's hash");
155
+ } else if (imageWritesNoChain(r.image?.version)) add("ceiling.time", "Written to Base", "NOT_CARRIED", "", "none exists: receipts of this enclave image are written to no chain");
156
+ else add("ceiling.time", "Written to Base", "NOT_CARRIED", "", "no Base write is carried with this file; if one was made for this proof, it can be looked up by the proof's hash");
130
157
 
131
158
  const failed = claims.filter((c) => c.result === "FALSE");
132
159
  const verdict: CarrierVerifyResult["verdict"] = failed.length > 0 ? "FALSE" : r.valid ? "TRUE" : "UNDETERMINED";
133
160
  const where = member ? `file ${member.index + 1} of a tree of ${member.files}` : "these exact bytes";
134
161
  const reading = verdict === "TRUE"
135
- ? `BitGraph #${proof.commit?.counter}: ${where}, bound by BitGraph's published enclave image ${r.image?.version ?? ""}${notBefore ? ` after Base block ${notBefore.blockNumber}` : ""}${existedBy ? ` and written to Base by block ${existedBy.blockNumber}` : ""}. Check those blocks on Base to place it in real time.`
162
+ ? `BitGraph #${proof.commit?.counter}: ${where}, bound by ${r.image ? `BitGraph's published enclave image ${r.image.version}` : `an enclave image on the verifier's list (PCR0 ${String(r.pcr0).slice(0, 16)}…)`}${notBefore ? ` after Base block ${notBefore.blockNumber}` : ""}${existedBy ? ` and written to Base by block ${existedBy.blockNumber}` : ""}.${notBefore || existedBy ? " Check those blocks on Base to place it in real time." : ""}${totFloor ? ` Its TOT carries a signed floor, ${FLOOR_NETWORKS[totFloor.network]?.name ?? totFloor.network} block ${totFloor.number}: found there with that hash, the TOT was made after that block.` : ""}`
136
163
  : `This BitGraphed file does not check: ${failed.map((c) => c.detail).join("; ") || "the proof did not verify"}.`;
137
164
  return {
138
165
  verdict, carrier: "ok", version: payload.carrier === CARRIER_VERSION_6 ? 6 : 5, reasons: claims.filter((c) => c.result !== "TRUE" && c.result !== "NOT_CARRIED").map((c) => c.detail),
139
166
  bounds: notBefore ? { notBefore, notAfter: null, existedBy, settledBy: null } : null,
140
167
  ceiling: null, claims, reading, payload: payloadIn, inner,
168
+ ...(totFloor ? { totFloor } : {}),
141
169
  };
142
170
  }
143
171
 
172
+ /** Enclave image v14 and later: nothing about their receipts is written to any chain, so no Base write exists to look for. */
173
+ function imageWritesNoChain(version: string | undefined): boolean {
174
+ const n = /^v(\d+)$/.exec(version ?? "");
175
+ return n !== null && Number(n[1]) >= 14;
176
+ }
177
+
144
178
  /** The bound bytes' SHA-256 as hex (for callers printing the envelope rule). */
145
179
  export const innerHex = (inner: Uint8Array) => hex(sha256(inner));
package/src/fuse.ts CHANGED
@@ -192,6 +192,26 @@ export function slotFloorProblem(slot: { version?: unknown; floor?: unknown }):
192
192
  return null;
193
193
  }
194
194
 
195
+ /** Exactly what a bitgraph/slot/2 record holds, its signature included. */
196
+ const SLOT_2_FIELDS = "chainId,counter,epochId,floor,nonceB64,publicKeyB64,signatureB64,version";
197
+
198
+ /**
199
+ * Why a slotAllocation is not in form as a TOT record, or null: its floor (slotFloorProblem), and for a
200
+ * bitgraph/slot/2 record that it holds exactly its listed fields and nothing else (BITGRAPH-TOT-2, section 3).
201
+ * Only the listed fields are rebuilt into the signed bytes, so an extra field would sit in the record under no
202
+ * signature; every check refuses it, so no tool can show one as if the enclave had said it. A key whose value is
203
+ * undefined is not a field: it does not exist in the record's JSON.
204
+ */
205
+ export function slotFormProblem(slot: { version?: unknown; floor?: unknown }): string | null {
206
+ const floor = slotFloorProblem(slot);
207
+ if (floor) return floor;
208
+ if (slot.version === SLOT_VERSION_2) {
209
+ const held = Object.entries(slot as Record<string, unknown>).filter(([, v]) => v !== undefined).map(([k]) => k).sort().join(",");
210
+ if (held !== SLOT_2_FIELDS) return "a bitgraph/slot/2 slotAllocation must hold exactly its listed fields";
211
+ }
212
+ return null;
213
+ }
214
+
195
215
  /** SHA-256 of the canonical slot body; equals the proof's commit.slotHashB64. */
196
216
  export function computeSlotRecordHash(slot: SlotAllocation): Uint8Array {
197
217
  return sha256(canonicalize(canonicalSlotBody(slot) as unknown as BitGraphProof));
package/src/index.ts CHANGED
@@ -72,6 +72,7 @@ export {
72
72
  SLOT_VERSION_2,
73
73
  FLOOR_NETWORK_BASE,
74
74
  slotFloorProblem,
75
+ slotFormProblem,
75
76
  computeSlotRecordHash,
76
77
  slotCommitmentPreimage,
77
78
  computeSlotCommitment,
package/src/tot-floor.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
 
30
30
  import type { BitGraphProof, SlotFloor } from "./types.js";
31
- import { base64ToBytes, slotFloorProblem, SLOT_VERSION_2, FLOOR_NETWORK_BASE } from "./fuse.js";
31
+ import { base64ToBytes, slotFormProblem, SLOT_VERSION_2, FLOOR_NETWORK_BASE } from "./fuse.js";
32
32
  import { headerRlpFromRpc, type RpcBlockHeader } from "./ceiling.js";
33
33
  import { bytesToHex } from "./ceiling-evm.js";
34
34
 
@@ -74,7 +74,7 @@ export interface FloorCheck {
74
74
  /** The floor a receipt's TOT carries under its signature, or null: no floor, not a slot/2 record, or not in form. */
75
75
  export function totFloorOf(proof: Pick<BitGraphProof, "slotAllocation"> | null | undefined): SlotFloor | null {
76
76
  const slot = proof?.slotAllocation;
77
- if (!slot || slot.version !== SLOT_VERSION_2 || slotFloorProblem(slot) !== null) return null;
77
+ if (!slot || slot.version !== SLOT_VERSION_2 || slotFormProblem(slot) !== null) return null;
78
78
  const f = slot.floor!;
79
79
  return { network: f.network, number: f.number, hashB64: f.hashB64 };
80
80
  }
package/src/verifier.ts CHANGED
@@ -83,7 +83,7 @@ import { createVerify, createHash } from "node:crypto";
83
83
  import { verifyAsync as ed25519VerifyAsync } from "@noble/ed25519";
84
84
  import { sha256 } from "@noble/hashes/sha256";
85
85
  import { canonicalize, constantTimeEqual } from "./canonical.js";
86
- import { SLOT_VERSION_2, slotFloorProblem } from "./fuse.js";
86
+ import { SLOT_VERSION_2, slotFormProblem } from "./fuse.js";
87
87
  import type { EnforcementTier, BitGraphProof, SignedBody, SlotAllocation, VerificationPolicy, AgencyEnvelope, AuthorizationPayload, WebAuthnAuthorization } from "./types.js";
88
88
 
89
89
  // ---------------------------------------------------------------------------
@@ -901,9 +901,9 @@ async function verifySlotAllocation(proof: BitGraphProof): Promise<string | null
901
901
  if (slot.version !== "bitgraph/slot/1" && slot.version !== SLOT_VERSION_2) {
902
902
  return `slotAllocation.version must be "bitgraph/slot/1" or "bitgraph/slot/2", got "${String(slot.version)}"`;
903
903
  }
904
- // A floor is signed in a slot/2 record and absent from a slot/1 record.
905
- const floorProblem = slotFloorProblem(slot);
906
- if (floorProblem) return floorProblem;
904
+ // A floor is signed in a slot/2 record and absent from a slot/1 record; a slot/2 record holds only its fields.
905
+ const formProblem = slotFormProblem(slot);
906
+ if (formProblem) return formProblem;
907
907
  if (typeof slot.nonceB64 !== "string" || slot.nonceB64.length === 0) {
908
908
  return "slotAllocation.nonceB64 must be a non-empty string";
909
909
  }