@mikeargento/bitgraph-audit 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/audit.d.ts CHANGED
@@ -8,7 +8,7 @@ import type { AuditOptions, AuditResult, ExitFlags, IngestResult } from "./types
8
8
  * this equals package.json's version, so the constant cannot drift silently
9
9
  * across releases.
10
10
  */
11
- export declare const AUDIT_VERSION = "0.12.0";
11
+ export declare const AUDIT_VERSION = "0.14.0";
12
12
  /** The audit package's own version. */
13
13
  export declare function auditToolVersion(): string;
14
14
  /** Options for auditIngest(): the audit options plus the run stamp. */
package/dist/audit.js CHANGED
@@ -36,7 +36,7 @@ import { validateAttestations } from "./attestation.js";
36
36
  * this equals package.json's version, so the constant cannot drift silently
37
37
  * across releases.
38
38
  */
39
- export const AUDIT_VERSION = "0.12.0";
39
+ export const AUDIT_VERSION = "0.14.0";
40
40
  /** The audit package's own version. */
41
41
  export function auditToolVersion() {
42
42
  return AUDIT_VERSION;
package/dist/tot.d.ts CHANGED
@@ -39,6 +39,13 @@ export interface TotVerdict {
39
39
  checks: NitroCheck[];
40
40
  /** The public floor signed into the TOT, when the receipt was accepted and its TOT carries one. Not yet looked up. */
41
41
  floor?: SlotFloor;
42
+ /**
43
+ * On ACCEPT of a bitgraph/slot/1 TOT: the names of fields that sit in `slotAllocation` beside the ones the
44
+ * enclave signed. The format does not refuse them (a slot/2 TOT is refused for one). They are under no
45
+ * signature, carry no claim and are never read; they are named so that a tool does not show one as if the
46
+ * enclave had said it. Absent when there are none.
47
+ */
48
+ unsignedTotFields?: string[];
42
49
  }
43
50
  /** R1, the receipt's form: every field this format requires, in the shape it requires. Null when it is in form. */
44
51
  export declare function totFormProblem(receipt: unknown): string | null;
@@ -62,7 +69,9 @@ export declare function verifyTotReceipt(opts: {
62
69
  * not-checked the lookup could not be made.
63
70
  * none the TOT carries no floor.
64
71
  *
65
- * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network.
72
+ * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network. The answer
73
+ * then carries `source: "supplied"`: it is as good as where the block came from, and a block that did not come
74
+ * from the chain shows nothing. Without `block` the chain is asked and the answer carries `source: "lookup"`.
66
75
  */
67
76
  export declare function checkTotFloor(opts: {
68
77
  receipt: unknown;
package/dist/tot.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tot.d.ts","sourceRoot":"","sources":["../src/tot.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGe,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAC1F,MAAM,8BAA8B,CAAC;AAEtC,+BAA+B;AAC/B,eAAO,MAAM,UAAU,oBAAoB,CAAC;AAC5C,wEAAwE;AACxE,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C,wGAAwG;AACxG,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAE/C,CAAC;AAEH,gHAAgH;AAChH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAE/C,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAAoE,CAAC;AAQnH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC7B,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC;IAClC,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,sHAAsH;IACtH,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAaD,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAqC9D;AAiBD,gEAAgE;AAChE,w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CAAC,CA0BtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CACrE,GAAG,OAAO,CAAC,UAAU,CAAC,CAWtB;AAWD,0FAA0F;AAC1F,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,wBAAwB,CAAC;AAExE,MAAM,WAAW,UAAU;IACzB;wCACoC;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,oEAAoE;IACpE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAAC,MAAM,CAAC,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CA0ClL"}
package/dist/tot.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * receipts has spent it twice whoever holds the key, and a receipt whose signatures fail is
18
18
  * nobody's and cannot refuse another.
19
19
  */
20
- import { verifyAttested, verifyProofIntegrity, createVerificationContext, computeSignedBodyHash, computeSlotRecordHash, buildSignedBody, slotFloorProblem, totFloorOf, checkFloorOnline, checkFloorAgainstBlock, } from "@mikeargento/bitgraph-verify";
20
+ import { verifyAttested, verifyProofIntegrity, createVerificationContext, computeSignedBodyHash, computeSlotRecordHash, buildSignedBody, slotFormProblem, totFloorOf, checkFloorOnline, checkFloorAgainstBlock, } from "@mikeargento/bitgraph-verify";
21
21
  /** The first format's name. */
22
22
  export const TOT_FORMAT = "bitgraph-tot-v1";
23
23
  /** The second format's name: v1, and a TOT may carry a public floor. */
@@ -35,8 +35,10 @@ export const TOT_MEASUREMENTS = Object.freeze([...TOT_V1_MEASUREMENTS, ...TOT_V2
35
35
  /** The two TOT record versions. */
36
36
  const SLOT_1 = "bitgraph/slot/1";
37
37
  const SLOT_2 = "bitgraph/slot/2";
38
- /** Exactly what a bitgraph/slot/2 TOT holds, its signature included. Nothing else may sit in the record. */
39
- const SLOT_2_FIELDS = "chainId,counter,epochId,floor,nonceB64,publicKeyB64,signatureB64,version";
38
+ /** What a bitgraph/slot/2 TOT holds, its signature included. */
39
+ const SLOT_2_FIELDS = ["chainId", "counter", "epochId", "floor", "nonceB64", "publicKeyB64", "signatureB64", "version"];
40
+ /** What a bitgraph/slot/1 TOT holds, its signature included. Anything else in the record is outside the signature. */
41
+ const SLOT_1_FIELDS = new Set(["chainId", "counter", "epochId", "nonceB64", "publicKeyB64", "signatureB64", "version"]);
40
42
  const B64_32 = (s) => {
41
43
  if (typeof s !== "string")
42
44
  return false;
@@ -95,12 +97,11 @@ export function totFormProblem(receipt) {
95
97
  return "slotAllocation (the TOT) is missing";
96
98
  if (t["version"] !== SLOT_1 && t["version"] !== SLOT_2)
97
99
  return 'slotAllocation.version must be "bitgraph/slot/1" or "bitgraph/slot/2"';
98
- // A floor is signed in a slot/2 TOT and absent from a slot/1 TOT. A slot/2 TOT holds its listed fields and no others.
99
- const floor = slotFloorProblem(t);
100
- if (floor)
101
- return floor;
102
- if (t["version"] === SLOT_2 && Object.keys(t).sort().join(",") !== SLOT_2_FIELDS)
103
- return "a bitgraph/slot/2 slotAllocation must hold exactly its listed fields";
100
+ // A floor is signed in a slot/2 TOT and absent from a slot/1 TOT. A slot/2 TOT holds its listed fields and no
101
+ // others. The rule is the checker library's, so every tool refuses the same records.
102
+ const form = slotFormProblem(t);
103
+ if (form)
104
+ return form;
104
105
  if (typeof t["counter"] !== "string" || !DEC.test(t["counter"]))
105
106
  return "slotAllocation.counter must be a decimal string";
106
107
  if (t["time"] !== undefined)
@@ -150,12 +151,16 @@ export async function verifyTotReceipt(opts) {
150
151
  });
151
152
  if (!r.valid)
152
153
  return { verdict: "REJECT", reason: r.reason ?? "the receipt does not verify", file, checks: r.checks };
154
+ // A slot/2 TOT was held to its exact fields by R1, so only a slot/1 TOT can carry anything beside them.
155
+ const tot = p.slotAllocation;
156
+ const unsigned = tot["version"] === SLOT_1 ? Object.keys(tot).filter((k) => !SLOT_1_FIELDS.has(k)).sort() : [];
153
157
  return {
154
158
  verdict: "ACCEPT",
155
159
  file,
156
160
  ...(r.attestedAtMs !== null ? { attestedAt: new Date(r.attestedAtMs).toISOString() } : {}),
157
161
  checks: r.checks,
158
162
  ...(totFloorOf(p) ? { floor: totFloorOf(p) } : {}),
163
+ ...(unsigned.length > 0 ? { unsignedTotFields: unsigned } : {}),
159
164
  };
160
165
  }
161
166
  /**
@@ -169,7 +174,9 @@ export async function verifyTotReceipt(opts) {
169
174
  * not-checked the lookup could not be made.
170
175
  * none the TOT carries no floor.
171
176
  *
172
- * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network.
177
+ * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network. The answer
178
+ * then carries `source: "supplied"`: it is as good as where the block came from, and a block that did not come
179
+ * from the chain shows nothing. Without `block` the chain is asked and the answer carries `source: "lookup"`.
173
180
  */
174
181
  export async function checkTotFloor(opts) {
175
182
  if (totFormProblem(opts.receipt) !== null)
@@ -185,6 +192,17 @@ export async function checkTotFloor(opts) {
185
192
  return checkFloorAgainstBlock({ ...common, block: opts.block });
186
193
  return checkFloorOnline({ ...common, ...(opts.rpcUrl ? { rpcUrl: opts.rpcUrl } : {}), ...(opts.fetcher ? { fetcher: opts.fetcher } : {}) });
187
194
  }
195
+ /** A receipt whose slot/2 TOT is cut down to its listed fields. Anything else in the record is under no signature. */
196
+ function withSignedTotFieldsOnly(p) {
197
+ const t = p.slotAllocation;
198
+ if (!t || t["version"] !== SLOT_2)
199
+ return p;
200
+ const kept = {};
201
+ for (const k of SLOT_2_FIELDS)
202
+ if (t[k] !== undefined)
203
+ kept[k] = t[k];
204
+ return { ...p, slotAllocation: kept };
205
+ }
188
206
  /**
189
207
  * The set check (section 8): every TOT is spent once. Two receipts that differ in their signed bodies and carry the same
190
208
  * TOT, or two different TOTs at one position (the same key, epoch, chain and count), are refused together. The same
@@ -216,7 +234,11 @@ export async function checkSpentOnce(receipts) {
216
234
  }
217
235
  if (!inForm)
218
236
  continue;
219
- const ok = await verifyProofIntegrity({ proof: p, trustAnchors: { requireAtomic: true }, context: createVerificationContext() });
237
+ // The set rule counts a receipt by its signatures and its TOT binding, not by its form. A slot/2 TOT with a
238
+ // field beside its signed ones is refused on its own (R1), and it still stands at its position: the released
239
+ // vectors count it, and a field added to a copy must not take that copy out of this check. So the signatures
240
+ // are checked over the TOT's signed fields alone.
241
+ const ok = await verifyProofIntegrity({ proof: withSignedTotFieldsOnly(p), trustAnchors: { requireAtomic: true }, context: createVerificationContext() });
220
242
  if (!ok.valid)
221
243
  continue;
222
244
  counted.push(i);
package/dist/tot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tot.js","sourceRoot":"","sources":["../src/tot.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,cAAc,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,eAAe,EAC9H,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,sBAAsB,GAEvE,MAAM,8BAA8B,CAAC;AAEtC,+BAA+B;AAC/B,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAC5C,wEAAwE;AACxE,MAAM,CAAC,MAAM,aAAa,G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AQ,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACjJ,CAAC;IACD,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC5B,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;AAC7H,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikeargento/bitgraph-audit",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Offline audit of a folder of BitGraph proofs: each proof checked, the counter order rebuilt, gaps and conflicts reported.",
5
5
  "keywords": [
6
6
  "bitgraph",
@@ -42,7 +42,7 @@
42
42
  "node": ">=20"
43
43
  },
44
44
  "dependencies": {
45
- "@mikeargento/bitgraph-verify": "^1.30.0",
45
+ "@mikeargento/bitgraph-verify": "^1.32.0",
46
46
  "@noble/hashes": "^1.4.0",
47
47
  "@paulmillr/trusted-setups": "0.3.0",
48
48
  "micro-eth-signer": "0.20.1"
@@ -0,0 +1,125 @@
1
+ // Copyright (c) 2024-2026 Argento Computing Inc.
2
+
3
+ /**
4
+ * A real bitgraph-tot-v2 receipt (spec/vectors/bitgraph-tot-v2-real/), checked with the real inputs: the first
5
+ * receipt of enclave image v14, which binds spec/BITGRAPH-TOT-2.md. The released version 2 vectors are made under
6
+ * test inputs with definite-length attestation documents; this one carries what AWS's hardware writes.
7
+ *
8
+ * Also here: what the check says of fields that sit in a TOT beside the signed ones.
9
+ */
10
+
11
+ import { test } from "node:test";
12
+ import assert from "node:assert/strict";
13
+ import { readFileSync } from "node:fs";
14
+ import { verifyTotReceipt, checkTotFloor, checkSpentOnce, ingestEntries, auditIngest } from "@mikeargento/bitgraph-audit";
15
+ import { verifyAttested, verifyCarrier, buildBitGraphedFileV5, type BitGraphProof } from "@mikeargento/bitgraph-verify";
16
+
17
+ const at = (p: string) => new URL(`../../../../${p}`, import.meta.url);
18
+ const RECEIPT = JSON.parse(readFileSync(at("spec/vectors/bitgraph-tot-v2-real/receipt.json"), "utf8"));
19
+ const BLOCK = JSON.parse(readFileSync(at("spec/vectors/bitgraph-tot-v2-real/base-block-66095720.json"), "utf8"));
20
+ const SPEC = new Uint8Array(readFileSync(at("spec/BITGRAPH-TOT-2.md")));
21
+ const V2 = JSON.parse(readFileSync(at("spec/vectors/bitgraph-tot-v2.json"), "utf8"));
22
+ const V1 = JSON.parse(readFileSync(at("spec/vectors/bitgraph-tot-v1.json"), "utf8"));
23
+ const testInputs = { rootDer: new Uint8Array(Buffer.from(V2.testTrustInputs.rootDerB64, "base64")), measurements: V2.testTrustInputs.acceptedMeasurements as string[] };
24
+
25
+ /** The first byte of a COSE_Sign1 document's payload: [protected, unprotected, payload, signature]. */
26
+ function payloadFirstByte(reportB64: string): number {
27
+ const d = Buffer.from(reportB64, "base64");
28
+ let i = d[0] === 0xd2 ? 1 : 0; // an optional tag 18
29
+ assert.equal(d[i], 0x84, "an array of four");
30
+ i += 1;
31
+ const skipBstr = (): void => {
32
+ const b = d[i]!;
33
+ assert.equal(b >> 5, 2, "a byte string");
34
+ const n = b & 0x1f;
35
+ if (n < 24) i += 1 + n;
36
+ else if (n === 24) i += 2 + d[i + 1]!;
37
+ else if (n === 25) i += 3 + d.readUInt16BE(i + 1);
38
+ else throw new Error("unexpected length");
39
+ };
40
+ skipBstr(); // protected
41
+ assert.equal(d[i], 0xa0, "an empty unprotected map");
42
+ i += 1;
43
+ const b = d[i]!;
44
+ assert.equal(b >> 5, 2, "the payload is a byte string");
45
+ const n = b & 0x1f;
46
+ return d[i + (n < 24 ? 1 : n === 24 ? 2 : 3)]!;
47
+ }
48
+
49
+ test("the real v14 receipt is accepted with the real inputs, with its file and without", async () => {
50
+ const withFile = await verifyTotReceipt({ receipt: RECEIPT, file: SPEC });
51
+ assert.equal(withFile.verdict, "ACCEPT", withFile.reason);
52
+ assert.equal(withFile.file, "compared");
53
+ assert.equal(withFile.attestedAt, "2026-12-04T18:38:39.740Z");
54
+ assert.deepEqual(withFile.floor, { network: "eip155:8453", number: "66095720", hashB64: "G9xjlrSMxrcJ6qaehB3xwqagBThiViOlXCUo+Q+Lg/k=" });
55
+ assert.equal(withFile.unsignedTotFields, undefined);
56
+ assert.equal((await verifyTotReceipt({ receipt: RECEIPT })).verdict, "ACCEPT");
57
+ // Another file is not the one it binds, and the test inputs do not accept it.
58
+ assert.equal((await verifyTotReceipt({ receipt: RECEIPT, file: new Uint8Array([1, 2, 3]) })).verdict, "REJECT");
59
+ assert.equal((await verifyTotReceipt({ receipt: RECEIPT, ...testInputs })).verdict, "REJECT");
60
+ });
61
+
62
+ test("a real attestation document is a CBOR map of indefinite length; the test documents are not", () => {
63
+ assert.equal(payloadFirstByte(RECEIPT.environment.attestation.reportB64), 0xbf);
64
+ assert.equal(payloadFirstByte(V1.receipts.find((r: { name: string }) => r.name === "valid").receipt.environment.attestation.reportB64), 0xbf);
65
+ for (const v of V2.receipts) assert.notEqual(payloadFirstByte(v.receipt.environment.attestation.reportB64), 0xbf, v.name);
66
+ });
67
+
68
+ test("its floor against the block Base returned: confirmed for a supplied block, 140 ms before the attestation", async () => {
69
+ const c = await checkTotFloor({ receipt: RECEIPT, attestedAt: "2026-12-04T18:38:39.740Z", maxFloorGapMs: 2000, block: BLOCK });
70
+ assert.equal(c.status, "confirmed");
71
+ assert.equal(c.source, "supplied", "the block came from a file here, not from the chain");
72
+ assert.equal(c.timeBoundByHash, true);
73
+ assert.equal(c.blockTimeMs, 1796409519600);
74
+ assert.equal(c.gapMs, 140);
75
+ assert.equal(c.stale, false);
76
+ });
77
+
78
+ test("a field beside a slot/1 TOT's signed ones is not refused, and is named as unsigned", async () => {
79
+ const v = V2.receipts.find((r: { name: string }) => r.name === "without-floor");
80
+ assert.equal(v.receipt.slotAllocation.version, "bitgraph/slot/1");
81
+ const plain = await verifyTotReceipt({ receipt: v.receipt, ...testInputs });
82
+ assert.equal(plain.verdict, "ACCEPT");
83
+ assert.equal(plain.unsignedTotFields, undefined);
84
+ const noted = { ...v.receipt, slotAllocation: { ...v.receipt.slotAllocation, note: "made after block 1", zeta: "x" } };
85
+ const r = await verifyTotReceipt({ receipt: noted, ...testInputs });
86
+ assert.equal(r.verdict, "ACCEPT", "version 1 of the format does not refuse it");
87
+ assert.deepEqual(r.unsignedTotFields, ["note", "zeta"]);
88
+ assert.equal(r.floor, undefined, "nothing unsigned is read as a floor");
89
+ // The same field beside a slot/2 TOT is refused outright.
90
+ const w = V2.receipts.find((x: { name: string }) => x.name === "with-floor");
91
+ const refused = await verifyTotReceipt({ receipt: { ...w.receipt, slotAllocation: { ...w.receipt.slotAllocation, note: "x" } }, ...testInputs });
92
+ assert.equal(refused.verdict, "REJECT");
93
+ assert.match(String(refused.reason), /^R1 form: /);
94
+ // No real receipt of version 1 carries one.
95
+ for (const x of V1.receipts) {
96
+ const got = await verifyTotReceipt({ receipt: x.receipt });
97
+ if (got.verdict === "ACCEPT") assert.equal(got.unsignedTotFields, undefined, x.name);
98
+ }
99
+ });
100
+
101
+ test("one rule for a slot/2 TOT's fields: the format's check, the main check and the carrier's all refuse an extra one", async () => {
102
+ const extra = { ...RECEIPT, slotAllocation: { ...RECEIPT.slotAllocation, note: "x" } };
103
+ const format = await verifyTotReceipt({ receipt: extra, file: SPEC });
104
+ assert.equal(format.verdict, "REJECT");
105
+ assert.equal(format.reason, "R1 form: a bitgraph/slot/2 slotAllocation must hold exactly its listed fields");
106
+ assert.equal((await verifyAttested({ proof: extra as unknown as BitGraphProof, bytes: SPEC })).valid, false);
107
+ assert.equal((await verifyCarrier(buildBitGraphedFileV5(SPEC, extra, null))).verdict, "FALSE");
108
+ // The receipt as made passes all three.
109
+ assert.equal((await verifyAttested({ proof: RECEIPT as BitGraphProof, bytes: SPEC })).valid, true);
110
+ assert.equal((await verifyCarrier(buildBitGraphedFileV5(SPEC, RECEIPT, null))).verdict, "TRUE");
111
+ });
112
+
113
+ test("an audit run over loose receipts reports a TOT consumed twice, under its own codes", async () => {
114
+ const set = V1.sets.find((s: { name: string }) => s.name === "spent-twice");
115
+ assert.equal((await checkSpentOnce(set.receipts)).reason, "DUPLICATE_TOT");
116
+ const enc = new TextEncoder();
117
+ const entries = set.receipts.map((r: unknown, i: number) => ({ path: `receipt-${i}.json`, open: () => enc.encode(JSON.stringify(r)) }));
118
+ const twice = await auditIngest(await ingestEntries(entries), { startedAt: "" });
119
+ const codes = twice.anomalies.anomalies.map((a) => a.code);
120
+ assert.ok(codes.includes("slot-collision"), codes.join(","));
121
+ assert.ok(codes.includes("counter-collision"), codes.join(","));
122
+ // One of them alone is clean.
123
+ const once = await auditIngest(await ingestEntries([entries[0]]), { startedAt: "" });
124
+ assert.deepEqual(once.anomalies.anomalies.map((a) => a.code), []);
125
+ });
package/src/audit.ts CHANGED
@@ -40,7 +40,7 @@ import type { AuditOptions, AuditResult, ExitFlags, IngestResult } from "./types
40
40
  * this equals package.json's version, so the constant cannot drift silently
41
41
  * across releases.
42
42
  */
43
- export const AUDIT_VERSION = "0.12.0";
43
+ export const AUDIT_VERSION = "0.14.0";
44
44
 
45
45
  /** The audit package's own version. */
46
46
  export function auditToolVersion(): string {
package/src/tot.ts CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  import {
23
23
  verifyAttested, verifyProofIntegrity, createVerificationContext, computeSignedBodyHash, computeSlotRecordHash, buildSignedBody,
24
- slotFloorProblem, totFloorOf, checkFloorOnline, checkFloorAgainstBlock,
24
+ slotFormProblem, totFloorOf, checkFloorOnline, checkFloorAgainstBlock,
25
25
  type BitGraphProof, type NitroCheck, type SlotFloor, type FloorCheck, type RpcBlockHeader,
26
26
  } from "@mikeargento/bitgraph-verify";
27
27
 
@@ -46,8 +46,10 @@ export const TOT_MEASUREMENTS: readonly string[] = Object.freeze([...TOT_V1_MEAS
46
46
  /** The two TOT record versions. */
47
47
  const SLOT_1 = "bitgraph/slot/1";
48
48
  const SLOT_2 = "bitgraph/slot/2";
49
- /** Exactly what a bitgraph/slot/2 TOT holds, its signature included. Nothing else may sit in the record. */
50
- const SLOT_2_FIELDS = "chainId,counter,epochId,floor,nonceB64,publicKeyB64,signatureB64,version";
49
+ /** What a bitgraph/slot/2 TOT holds, its signature included. */
50
+ const SLOT_2_FIELDS = ["chainId", "counter", "epochId", "floor", "nonceB64", "publicKeyB64", "signatureB64", "version"] as const;
51
+ /** What a bitgraph/slot/1 TOT holds, its signature included. Anything else in the record is outside the signature. */
52
+ const SLOT_1_FIELDS: ReadonlySet<string> = new Set(["chainId", "counter", "epochId", "nonceB64", "publicKeyB64", "signatureB64", "version"]);
51
53
 
52
54
  export interface TotVerdict {
53
55
  verdict: "ACCEPT" | "REJECT";
@@ -61,6 +63,13 @@ export interface TotVerdict {
61
63
  checks: NitroCheck[];
62
64
  /** The public floor signed into the TOT, when the receipt was accepted and its TOT carries one. Not yet looked up. */
63
65
  floor?: SlotFloor;
66
+ /**
67
+ * On ACCEPT of a bitgraph/slot/1 TOT: the names of fields that sit in `slotAllocation` beside the ones the
68
+ * enclave signed. The format does not refuse them (a slot/2 TOT is refused for one). They are under no
69
+ * signature, carry no claim and are never read; they are named so that a tool does not show one as if the
70
+ * enclave had said it. Absent when there are none.
71
+ */
72
+ unsignedTotFields?: string[];
64
73
  }
65
74
 
66
75
  const B64_32 = (s: unknown): boolean => {
@@ -102,10 +111,10 @@ export function totFormProblem(receipt: unknown): string | null {
102
111
  const t = r["slotAllocation"];
103
112
  if (!isObject(t)) return "slotAllocation (the TOT) is missing";
104
113
  if (t["version"] !== SLOT_1 && t["version"] !== SLOT_2) return 'slotAllocation.version must be "bitgraph/slot/1" or "bitgraph/slot/2"';
105
- // A floor is signed in a slot/2 TOT and absent from a slot/1 TOT. A slot/2 TOT holds its listed fields and no others.
106
- const floor = slotFloorProblem(t);
107
- if (floor) return floor;
108
- if (t["version"] === SLOT_2 && Object.keys(t).sort().join(",") !== SLOT_2_FIELDS) return "a bitgraph/slot/2 slotAllocation must hold exactly its listed fields";
114
+ // A floor is signed in a slot/2 TOT and absent from a slot/1 TOT. A slot/2 TOT holds its listed fields and no
115
+ // others. The rule is the checker library's, so every tool refuses the same records.
116
+ const form = slotFormProblem(t);
117
+ if (form) return form;
109
118
  if (typeof t["counter"] !== "string" || !DEC.test(t["counter"])) return "slotAllocation.counter must be a decimal string";
110
119
  if (t["time"] !== undefined) return "slotAllocation.time must be absent";
111
120
  if (!B64_32(t["nonceB64"]) || !B64_32(t["epochId"]) || !B64_32(t["publicKeyB64"])) return "slotAllocation.nonceB64, epochId and publicKeyB64 must each be 32 bytes in canonical base64";
@@ -152,12 +161,16 @@ export async function verifyTotReceipt(opts: {
152
161
  ...(opts.rootDer ? { rootDer: opts.rootDer } : {}),
153
162
  });
154
163
  if (!r.valid) return { verdict: "REJECT", reason: r.reason ?? "the receipt does not verify", file, checks: r.checks };
164
+ // A slot/2 TOT was held to its exact fields by R1, so only a slot/1 TOT can carry anything beside them.
165
+ const tot = p.slotAllocation as unknown as Record<string, unknown>;
166
+ const unsigned = tot["version"] === SLOT_1 ? Object.keys(tot).filter((k) => !SLOT_1_FIELDS.has(k)).sort() : [];
155
167
  return {
156
168
  verdict: "ACCEPT",
157
169
  file,
158
170
  ...(r.attestedAtMs !== null ? { attestedAt: new Date(r.attestedAtMs).toISOString() } : {}),
159
171
  checks: r.checks,
160
172
  ...(totFloorOf(p) ? { floor: totFloorOf(p)! } : {}),
173
+ ...(unsigned.length > 0 ? { unsignedTotFields: unsigned } : {}),
161
174
  };
162
175
  }
163
176
 
@@ -172,7 +185,9 @@ export async function verifyTotReceipt(opts: {
172
185
  * not-checked the lookup could not be made.
173
186
  * none the TOT carries no floor.
174
187
  *
175
- * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network.
188
+ * Pass `block` (what the chain says, or null for "no such block") to apply the rule with no network. The answer
189
+ * then carries `source: "supplied"`: it is as good as where the block came from, and a block that did not come
190
+ * from the chain shows nothing. Without `block` the chain is asked and the answer carries `source: "lookup"`.
176
191
  */
177
192
  export async function checkTotFloor(opts: {
178
193
  receipt: unknown;
@@ -196,6 +211,15 @@ export async function checkTotFloor(opts: {
196
211
  return checkFloorOnline({ ...common, ...(opts.rpcUrl ? { rpcUrl: opts.rpcUrl } : {}), ...(opts.fetcher ? { fetcher: opts.fetcher } : {}) });
197
212
  }
198
213
 
214
+ /** A receipt whose slot/2 TOT is cut down to its listed fields. Anything else in the record is under no signature. */
215
+ function withSignedTotFieldsOnly(p: BitGraphProof): BitGraphProof {
216
+ const t = p.slotAllocation as unknown as Record<string, unknown> | undefined;
217
+ if (!t || t["version"] !== SLOT_2) return p;
218
+ const kept: Record<string, unknown> = {};
219
+ for (const k of SLOT_2_FIELDS) if (t[k] !== undefined) kept[k] = t[k];
220
+ return { ...p, slotAllocation: kept as unknown as NonNullable<BitGraphProof["slotAllocation"]> };
221
+ }
222
+
199
223
  /** The set rule's reasons: two receipts spend one TOT, or two TOTs claim one position. */
200
224
  export type SpentTwiceCode = "DUPLICATE_TOT" | "DUPLICATE_TOT_POSITION";
201
225
 
@@ -231,7 +255,11 @@ export async function checkSpentOnce(receipts: readonly unknown[]): Promise<{ ve
231
255
  let inForm = false;
232
256
  try { inForm = recordProblem(buildSignedBody(p), "the signed body") === null && recordProblem(totBody, "the TOT body") === null; } catch { inForm = false; }
233
257
  if (!inForm) continue;
234
- const ok = await verifyProofIntegrity({ proof: p, trustAnchors: { requireAtomic: true }, context: createVerificationContext() });
258
+ // The set rule counts a receipt by its signatures and its TOT binding, not by its form. A slot/2 TOT with a
259
+ // field beside its signed ones is refused on its own (R1), and it still stands at its position: the released
260
+ // vectors count it, and a field added to a copy must not take that copy out of this check. So the signatures
261
+ // are checked over the TOT's signed fields alone.
262
+ const ok = await verifyProofIntegrity({ proof: withSignedTotFieldsOnly(p), trustAnchors: { requireAtomic: true }, context: createVerificationContext() });
235
263
  if (!ok.valid) continue;
236
264
  counted.push(i);
237
265
  const t = p.slotAllocation!;