@agledger/verify-core 1.5.0 → 2.0.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/README.md CHANGED
@@ -35,17 +35,24 @@ for a single record export.
35
35
  import { verifyAuditExport } from '@agledger/verify-core';
36
36
 
37
37
  const result = verifyAuditExport(exportDocument, {
38
- publicKeys, // optional out-of-band keys (see "Out-of-band keys" below)
39
- requireOutOfBandKeys: true, // optional: refuse the export's embedded keys
38
+ // The SPKI digest of a vault key you took out of band (see "Anchoring keys").
39
+ trustAnchors: ['sha256:15d63684b387235c47fe3a81e3004b928f4ea535236a2c1b47465ce5fdd7ce0e'],
40
40
  });
41
41
 
42
- if (!result.valid) {
42
+ if (result.verdict === 'failed') {
43
43
  console.error(`Broken at position ${result.brokenAt?.position}: ${result.brokenAt?.code}`);
44
44
  process.exit(1);
45
45
  }
46
- // { valid: true, verifiedEntries, totalEntries, keyProvenance: { outOfBand, embedded }, ... }
46
+ console.log(result.verdict); // 'trusted', or 'unanchored' when nothing pinned backs the pass
47
+ // { valid: true, verdict, verifiedEntries, totalEntries, keyTrust, keyProvenance: { supplied, embedded }, ... }
47
48
  ```
48
49
 
50
+ Read `verdict` rather than `valid`: a valid result with no `trustAnchors` is
51
+ `unanchored`, which is not a trusted verdict. An option the function does not
52
+ read throws `TypeError` rather than being ignored, so a misspelt option, or
53
+ `requireOutOfBandKeys` (renamed `requireSuppliedKeys` in 2.0.0), cannot turn a
54
+ check off without a word.
55
+
49
56
  ## What it verifies
50
57
 
51
58
  - **`chainPosition` monotonicity**: gap-free, in order.
@@ -58,7 +65,17 @@ if (!result.valid) {
58
65
  matched verification key, under the algorithm its SPKI commits to (Ed25519
59
66
  or ES256; anything else fails closed as `CHAIN_UNSUPPORTED_ALGORITHM`).
60
67
  - **Signed-kid binding**: the row's `signingKeyId` names the key the protected
61
- header signed.
68
+ header signed. An entry that names a key but carries an all-zero signature
69
+ fails `CHAIN_SIGNATURE_INVALID`.
70
+ - **Unsigned entries**: an entry with no `signingKeyId` fails
71
+ `CHAIN_ENTRY_UNSIGNED` when it follows a signed entry in its chain, or when
72
+ it was written at or after the earliest `activatedAt` in the key set
73
+ (export `signingKeyWindows` and your own keys, retired keys included). With
74
+ `trustAnchors`, the activations an anchored key's statements sign count as
75
+ well, so an export stripped of its unsigned `signingKeyWindows` is still
76
+ held to them.
77
+ Earlier unsigned entries, written before the install had a key, count as
78
+ `signatureCoverage.skipped` rather than a break.
62
79
  - **Payload binding**: each entry's human-readable `payload` still matches the
63
80
  predicate inside the signed bytes, so a rewritten view of the record fails
64
81
  `CHAIN_PAYLOAD_BINDING_MISMATCH`.
@@ -68,14 +85,227 @@ if (!result.valid) {
68
85
  the attribution an export's own guide tells an auditor to rely on, match the
69
86
  actor claim signed in the protected header, so an export re-attributed to
70
87
  another actor fails `CHAIN_ACTOR_ATTRIBUTION_MISMATCH`.
88
+ - **Key anchoring**, with `trustAnchors`: each entry's key is linked by signed
89
+ key statements to a key you pinned, or the entry fails
90
+ `CHAIN_SIGNING_KEY_UNANCHORED` (below).
71
91
  - **Key validity windows**: each entry was written inside its signing key's
72
- activation window.
92
+ activation window. With `trustAnchors`, the window is the one the key
93
+ statements sign.
73
94
  - **Agent signatures**, when you supply the agent's cert key (below).
74
95
 
75
96
  The payload, OIDC, attribution and key-window checks run when the export
76
97
  carries their inputs, which every current Server does. The result's `optionalChecks` says
77
98
  which ran, so "not checked" never reads as "passed".
78
99
 
100
+ ## Anchoring keys
101
+
102
+ A vault key the Server publishes comes from its database, and anything with
103
+ write access to that database can add a key row and entries signed with it.
104
+ What it cannot add is a **key statement**: a COSE_Sign1 signed by a key the
105
+ Server already trusted (and, for a new key, by the new key too). Pass the SPKI
106
+ digest of a vault key you hold or took out of band as `trustAnchors`, and the
107
+ verifier walks the statements from it:
108
+
109
+ - the installer prints the digest of the first vault key, and the Server's
110
+ `signing-key-digest.js` derives one from any key you hold;
111
+ - the export's `exportMetadata.anchoredFrom` names the Server's own key, and
112
+ the result reports whether it is one of your anchors
113
+ (`keyTrust.anchoredFromPinned`), but it is the export's word and never
114
+ counts as an anchor itself.
115
+
116
+ An entry signed by a key the walk does not anchor fails
117
+ `CHAIN_SIGNING_KEY_UNANCHORED`, and each anchored key is held to the window its
118
+ statements sign. `keyTrust.status` says whether a pass can be trusted:
119
+
120
+ - `walked`: at least one entry verified under a key your anchors reach. The
121
+ only status a passing result is trusted on.
122
+ - `no_anchor`: no `trustAnchors` (an empty array is the same as none), so
123
+ `optionalChecks.key_anchoring` is `skipped_no_input` and the verdict rests on
124
+ keys nobody pinned: a key written into the database alone would pass.
125
+ - `no_anchored_signature`: the walk ran, but no entry verified under a key it
126
+ anchors, so `optionalChecks.key_anchoring` is `not_checked`. An export of
127
+ entries written before the install began signing passes under any pin, and
128
+ proves nothing about the pin.
129
+
130
+ A pass on `no_anchor` or `no_anchored_signature` is not a trusted verdict; the
131
+ `detail` says so, and `verdict` (and every AGLedger surface) reports it as
132
+ `unanchored`. `distrustedKeys` without `trustAnchors` throws `TypeError`, since
133
+ nothing would apply them, and so does a pinned key distrusted with no instant,
134
+ which the Server refuses to start with. A pin beside a dated entry
135
+ (`sha256:<hex>@<instant>`) is how a leaked key's history stays verifiable: the
136
+ pin vouches for what the key stored before the instant, and the entry
137
+ withdraws what it stored from then on.
138
+
139
+ ```ts
140
+ import { verifyAuditExport } from '@agledger/verify-core';
141
+
142
+ const result = verifyAuditExport(exportDocument, {
143
+ trustAnchors: ['sha256:15d63684b387235c47fe3a81e3004b928f4ea535236a2c1b47465ce5fdd7ce0e'],
144
+ // The operator's VAULT_DISTRUSTED_KEYS, when a key leaked: what it signed
145
+ // from the instant on (or, with none, from its retirement) counts for nothing.
146
+ distrustedKeys: [],
147
+ });
148
+
149
+ const { status, anchoredKeyIds, unanchoredKeyIds, findings } = result.keyTrust;
150
+ console.log(status, anchoredKeyIds, unanchoredKeyIds);
151
+ for (const f of findings) console.log(f.code, f.keyId, f.detail);
152
+ ```
153
+
154
+ The statements the export carries (`exportMetadata.signingKeyStatements`) are
155
+ walked, together with any `statements` on keys you supply from
156
+ `GET /v1/verification-keys`. Findings about the statements themselves make the
157
+ result invalid, at position 0:
158
+
159
+ - `KEY_STATEMENT_INVALID`: a statement that does not verify, disagrees with
160
+ what it is filed under, touches no anchored key, was signed by a key after
161
+ its closure or after the key was already admitted, or admits a trusted key
162
+ under an endorser the walk does not trust (the Server publishes the
163
+ admission and not its endorser);
164
+ - `KEY_CLOSURE_INVALID`: a retired key with no closure that counts for it, or
165
+ a closure by a key the walk does not anchor, by a key after its own
166
+ retirement, dated before its subject was activated, dated after the time it
167
+ was stored, or signed by a key the walk reaches but does not anchor and
168
+ closing a published key (the Server publishes the closure and not its
169
+ signer, so no walk over what it publishes can verify it);
170
+ - `CHAIN_KEY_WINDOW_DRIFT`: a listed window or status that differs from the
171
+ signed value (compared at millisecond precision).
172
+
173
+ A key the Server's `VAULT_DISTRUSTED_KEYS` names is listed with
174
+ `distrustedFrom`, the instant its entry gives (in an export's
175
+ `signingKeyWindows` and on `/v1/verification-keys`), and where that instant is
176
+ earlier than the retirement the key's closures sign, the listed `retiredAt` is
177
+ that instant. A walk not given the same entry still fails on that window, but
178
+ the finding names the entry the listing says the Server applied
179
+ (`distrustedKeys sha256:<hex>@<distrustedFrom>`) rather than reading as a
180
+ rewritten column, and says so when the entry it was given carries another
181
+ instant; an entry at an earlier instant, which fails nothing on the window,
182
+ is said in `keyTrust.notes`. `distrustedFrom` is the source's unsigned word
183
+ and only changes that wording: it never ends, opens or widens a window and
184
+ never clears a finding. Confirm the instant with the Server's operator before
185
+ giving that `distrustedKeys` entry: off a dump an entry also voids every
186
+ admission the key signed, so a key it admitted that nothing else reaches is
187
+ no longer trusted and its window no longer graded.
188
+
189
+ Statements are walked in the order the Server's database stored them,
190
+ `createdAt` then the row `id`, never by an instant a statement signs. A dump
191
+ carries that order (`created_at`), and so does every key document an API 2.0
192
+ Server serves: each statement in an export's `signingKeyStatements`,
193
+ `/v1/verification-keys` and `/.well-known/agledger-vault-keys.json` carries
194
+ its row `id` and `createdAt` at microsecond precision, and `keyTrust.order`
195
+ reads `written`. A `createdAt` that is not strict RFC 3339 (a `T`, an offset
196
+ or `Z`, a real calendar date) places nothing, and its statement is
197
+ `KEY_STATEMENT_INVALID`. Such a document lists under a trusted key its
198
+ admission, every later admission it signed, and the closures that count for
199
+ it, so a walk over it dates each window and cuts each edge back as the engine
200
+ does. Where it cannot (a later succession whose endorser the document does not
201
+ carry, or a closure by a key it does not list), the walk grades the window
202
+ more loosely than the listed one, and the listed `activatedAt` or `retiredAt`
203
+ reads as `CHAIN_KEY_WINDOW_DRIFT` (a listed retirement no closure it could
204
+ verify signs is `KEY_CLOSURE_INVALID`). A statement the export and a supplied
205
+ key both carry is one row, however its `id` and `createdAt` are spelled.
206
+
207
+ A document from a Server that published neither field is still read, and
208
+ `keyTrust.order` reads `signed`: statements are ordered by the instant each
209
+ one signs, with a closure after any admission that signs the same instant. For
210
+ a document the Server served, the two orders agree. If the export and a
211
+ supplied key document disagree (one carries write times and the other does
212
+ not), a statement the older one alone carries makes the whole walk fall back
213
+ to the signed order.
214
+
215
+ `createdAt` is not signed: whoever holds an export or a key document can edit
216
+ it, as they can reorder the document, with nothing offline to tell. So a
217
+ document's write order is never held against `distrustedKeys`. On any
218
+ statement from an export or a supplied key document, in either order, an edge
219
+ out of a distrusted key never admits a key or keeps one reachable, whatever
220
+ time it carries. Such a statement still counts for everything that can only
221
+ narrow trust: it dates its subject's window, cuts the subject's edge back as a
222
+ later admission, and a closure the key signed still ends a window. Where the
223
+ document dates it before the cutoff, so the engine would count it, it is no
224
+ finding: it is listed in `keyTrust.notes`, which never fails a verdict, and an
225
+ honest rotation away from the key passes when you pin its successor. Pinned
226
+ only on the distrusted key, its successor is not anchored. This is narrower
227
+ than the engine, which holds the key to the time its statements were really
228
+ stored, and never wider. Only
229
+ a dump walk holds a distrusted key's statements to their `created_at`, as the
230
+ engine does, and that adds assurance only for a dump you took from the Server
231
+ yourself or over a channel you trust; for any other dump it assures no more
232
+ than the stored times its holder chose.
233
+
234
+ An entry's `createdAt` is not signed either, so the holder of a leaked
235
+ distrusted key can still sign entries dated before its cutoff, and no offline
236
+ verifier can tell those from the history the key wrote inside its legitimate
237
+ window.
238
+
239
+ Without `distrustedKeys`, a key retired without `force` whose private half
240
+ later leaks can still admit a key on any walk: with a statement it dates
241
+ before its retirement under the signed order, or with an edited `createdAt`
242
+ under the write order. A forced retirement voids every edge out of its key
243
+ under either order. When a retired key may have leaked, retire it with
244
+ `force` or list it in `distrustedKeys`.
245
+
246
+ ### Walking a dump or a key document
247
+
248
+ `@agledger/verify` walks a full-vault dump with the same functions:
249
+
250
+ ```ts
251
+ import { readFileSync } from 'node:fs';
252
+ import { applyKeyTrust, buildKeyRegistry, computeKeyTrust, keyStatementFromDumpRow, trustKeyFromDumpRow } from '@agledger/verify-core';
253
+ import type { DumpKeyStatementRow, DumpSigningKeyRow } from '@agledger/verify-core';
254
+
255
+ const rows = <T,>(file: string): T[] =>
256
+ readFileSync(file, 'utf8').split('\n').filter((l) => l.trim() !== '').map((l) => JSON.parse(l) as T);
257
+ const keys = rows<DumpSigningKeyRow>('vault_signing_keys.ndjson');
258
+
259
+ const trust = computeKeyTrust({
260
+ keys: keys.map(trustKeyFromDumpRow),
261
+ statements: rows<DumpKeyStatementRow>('vault_key_statements.ndjson').map(keyStatementFromDumpRow),
262
+ trustAnchors: ['sha256:15d63684b387235c47fe3a81e3004b928f4ea535236a2c1b47465ce5fdd7ce0e'],
263
+ });
264
+ // Marks each key anchored, unanchored or undecided and gives anchored keys
265
+ // their signed windows; verifyChain then grades entries against it.
266
+ const registry = applyKeyTrust(
267
+ buildKeyRegistry(keys.map((k) => ({ keyId: k.key_id, spkiBase64: k.public_key, source: 'embedded' as const }))),
268
+ trust,
269
+ );
270
+ console.log([...registry.values()].map((k) => `${k.keyId} ${k.trust}`), trust.findings);
271
+ ```
272
+
273
+ A dump verifier reports the walk with `reportKeyTrust(registry, trust, null)`
274
+ and, once its chains are walked, settles it with
275
+ `settleKeyTrust(report, signedEntries)`, the count of entries whose signature
276
+ verified: with none, the status becomes `no_anchored_signature`.
277
+ `writtenWhileSigning(rowTime, signingSince)` is the unsigned-row rule for
278
+ checkpoints and read-log rows, and fails closed on a row with no readable time
279
+ once signing began.
280
+
281
+ A dump row repeating an earlier row's signed payload counts once, at its
282
+ first write: a row copied in the database under a new id and time says
283
+ nothing new, as the engine reads it. On a key document a copy stays a second
284
+ statement, since its `createdAt` is the holder's word.
285
+
286
+ On a dump, a `distrustedKeys` key that a key the walk trusts has retired is
287
+ bounded by that retirement (its `DistrustSpan` in `trust.distrustSpans`; only a
288
+ retirement by a key the walk trusts counts, as in the engine), and
289
+ what it signed before then is accounted for rather than failed, as the engine's
290
+ scan lists it: a key statement it signed that counts for nothing is listed in
291
+ `trust.accounted` (and the report's `accounted`) instead of `findings`, and a
292
+ chain entry whose signature verifies under it, outside what the key is
293
+ trusted for (the key unanchored, or the entry written at or after its cutoff),
294
+ is listed in the `verifyChain` result's `accounted` as
295
+ `CHAIN_SIGNED_BY_DISTRUSTED_KEY` (`AccountedEntry`: `code`, `chain`,
296
+ `recordId`, `orgId`, `scopeId`, `position`, `keyId`, `detail`) with signature
297
+ state `accounted`, and does not fail the chain. A verdict whose only items are
298
+ accounted ones passes, and should list them. What the key signed after that
299
+ retirement fails as before, and a distrusted key with a registry row that no
300
+ trusted key has retired is `KEY_CLOSURE_INVALID` naming the forced retire call
301
+ that bounds it. An audit export is never accounted for this way: its write
302
+ times are not the Server's word.
303
+
304
+ `keyStatementsFromVerificationKeys(document)` gives the same inputs from a
305
+ `GET /v1/verification-keys` response. A key reached only through a statement
306
+ this host cannot compute (Ed25519 history on a FIPS host) is `undecided`, and
307
+ entries under it are `CHAIN_UNSUPPORTED_ALGORITHM` rather than unanchored.
308
+
79
309
  ## Agent signatures
80
310
 
81
311
  An agent that authenticates with an ephemeral cert can sign each request body
@@ -155,19 +385,35 @@ console.log(describeUnsupportedAlgorithm(spkiBase64));
155
385
  that refuses to *load* a key of some algorithm produces no key object to
156
386
  resolve, which is exactly when the question matters most.
157
387
 
158
- ## Out-of-band keys
388
+ ## Supplied keys
159
389
 
160
- `options.publicKeys` accepts either of two shapes:
390
+ `options.publicKeys` accepts these shapes:
161
391
 
162
392
  - a **`Record<keyId, base64SpkiDer>`** map (compact, keyed by key id), or
163
- - an **`OutOfBandKeyEntry[]`** array, the natural shape returned by
393
+ - a **`SuppliedKeyEntry[]`** array, the natural shape returned by
164
394
  `client.verificationKeys.list().data` and SCITT COSE_KeySet listings, where
165
- each entry is `{ keyId, publicKey, activatedAt?, retiredAt? }` (`publicKey`
166
- is SPKI DER base64).
395
+ each entry is `{ keyId, publicKey, activatedAt?, retiredAt?, statements? }`
396
+ (`publicKey` is SPKI DER base64), or the `/v1/verification-keys` body as
397
+ served, `{ data: [...] }`, read as its `data`.
167
398
 
168
399
  Both are normalized at the boundary; anything else throws `TypeError`
169
400
  (fail-closed: the verifier never silently falls back to embedded keys).
170
401
 
402
+ ## Org-read log
403
+
404
+ The cross-party read log (`org_admin_reads`) is an RFC 9162 §2.1 Merkle tree,
405
+ the same construction SCITT Receipts use. Its hashes are lowercase hex:
406
+
407
+ ```ts
408
+ import { orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion } from '@agledger/verify-core';
409
+
410
+ // leaf_hash = hex(sha256(0x00 || cose_sign1)); a checkpoint's root is the RFC 9162 root over them.
411
+ const leaf = orgReadLeafHash(Buffer.from('cose-sign1-bytes'));
412
+ const root = orgReadMerkleRoot([leaf]);
413
+ // An inclusion proof from GET /v1/audit/org-reads/checkpoints/{id}/proof; a one-leaf tree has an empty path.
414
+ console.log(root === leaf, verifyOrgReadInclusion(leaf, 0, 1, [], root!)); // true true
415
+ ```
416
+
171
417
  ## Canonical failure taxonomy
172
418
 
173
419
  Every failure is a canonical SCREAMING_SNAKE `FailureCode`. Importing the
@@ -177,9 +423,11 @@ chain was checked by the SDK, the CLI, the MCP tool, or `@agledger/verify`.
177
423
 
178
424
  ## Key provenance
179
425
 
180
- The result distinguishes keys supplied **out of band** (by the caller) from keys
181
- **embedded in the export** under inspection. High-assurance audits can require
182
- out-of-band keys and fail closed on a self-attesting export.
426
+ The result distinguishes keys **supplied** by the caller from keys **embedded in
427
+ the export** under inspection (`keyProvenance`), and `requireSuppliedKeys`
428
+ refuses embedded keys. That says where a key came from, not that it is trusted:
429
+ a key fetched from the Server comes from its database too. Trust is what
430
+ `trustAnchors` establishes.
183
431
 
184
432
  ## License
185
433
 
@@ -22,14 +22,19 @@
22
22
  import { type CheckApplicability, type OptionalCheck, type SignatureOutcome } from './chain.js';
23
23
  import type { FailureCode } from './failures.js';
24
24
  import type { AgentPublicKeyJwk } from './primitives.js';
25
+ import { type DistrustedKey, type KeyTrustReport, type PublishedKeyStatement, type Verdict } from './key-statements.js';
25
26
  /** One entry of a `/audit-export` document. */
26
27
  export interface AuditExportEntryInput {
27
28
  /** 1-based chain position. Current exports emit `chainPosition`; pre-v0.25 used `position`. */
28
29
  chainPosition?: number;
29
30
  /** Legacy alias for `chainPosition`. */
30
31
  position?: number;
31
- /** ISO-8601 write time. Engine ≥ v0.26.x; gates the temporal key-validity check. */
32
- createdAt?: string;
32
+ /**
33
+ * ISO-8601 write time. Where the walk needs it (a key window, or an unsigned
34
+ * entry once signing began) a missing or unparseable one fails
35
+ * CHAIN_MALFORMED_ENTRY.
36
+ */
37
+ createdAt?: string | null;
33
38
  /** OIDC issuer the actor was synthesized from (engine ≥ v0.26.x). */
34
39
  actorOidcIss?: string | null;
35
40
  /** OIDC subject the actor was synthesized from (engine ≥ v0.26.x). */
@@ -64,6 +69,14 @@ export interface AuditExportEntryInput {
64
69
  export interface SigningKeyWindow {
65
70
  activatedAt: string;
66
71
  retiredAt: string | null;
72
+ /**
73
+ * The Server's `VAULT_DISTRUSTED_KEYS` instant for the key, present only on
74
+ * a key it names (RFC 3339 UTC, microsecond precision). Where it is earlier
75
+ * than the retirement the key's closures sign, `retiredAt` is this instant
76
+ * truncated to the millisecond. It changes only how the walk words a
77
+ * finding on the window: see `TrustKeyInput.distrustedFrom`.
78
+ */
79
+ distrustedFrom?: string;
67
80
  }
68
81
  /** A `/audit-export` document (only the fields the verifier reads). */
69
82
  export interface RecordAuditExportInput {
@@ -72,8 +85,15 @@ export interface RecordAuditExportInput {
72
85
  exportFormatVersion?: string;
73
86
  canonicalization?: string;
74
87
  signingPublicKeys?: Record<string, string>;
75
- /** keyId → activation/retirement window (engine ≥ v0.26.x). */
88
+ /** keyId → activation/retirement window, the values the key statements sign. */
76
89
  signingKeyWindows?: Record<string, SigningKeyWindow>;
90
+ /** keyId → the signed key statements admitting that key (API 2.0). Walked from `trustAnchors`. */
91
+ signingKeyStatements?: Record<string, PublishedKeyStatement[]>;
92
+ /**
93
+ * `sha256:<hex>` of the exporting Server's own key. Reported against the
94
+ * caller's anchors, never used as one: it is the artifact's word.
95
+ */
96
+ anchoredFrom?: string | null;
77
97
  };
78
98
  entries: AuditExportEntryInput[];
79
99
  /**
@@ -90,44 +110,77 @@ export interface RecordAuditExportInput {
90
110
  };
91
111
  }
92
112
  /**
93
- * Structural shape for a single out-of-band key in array form. Matches the SDK's
113
+ * Structural shape for a single supplied key in array form. Matches the SDK's
94
114
  * `VerificationKey` (the `.data[]` from `client.verificationKeys.list()`) plus
95
115
  * the SCITT COSE_KeySet (`/.well-known/scitt-keys`) entry shape; extra fields
96
116
  * are ignored. `publicKey` must be SPKI DER base64.
97
117
  */
98
- export interface OutOfBandKeyEntry {
118
+ export interface SuppliedKeyEntry {
99
119
  keyId: string;
100
120
  publicKey: string;
101
121
  /** Optional activation timestamp; feeds temporal key-validity when present. */
102
122
  activatedAt?: string;
103
123
  /** Optional retirement timestamp; `null` means "active, no scheduled retirement". */
104
124
  retiredAt?: string | null;
125
+ /**
126
+ * The key's signed statements, as `/v1/verification-keys` lists them. Walked
127
+ * with the export's own when `trustAnchors` is given.
128
+ */
129
+ statements?: PublishedKeyStatement[];
105
130
  }
106
131
  export interface VerifyExportOptions {
107
132
  /**
108
- * Public keys supplied OUT OF BAND from a trusted source (GET
109
- * /v1/verification-keys, /.well-known/scitt-keys). These override any key
110
- * embedded in the export. For a real independent audit, supply keys here
111
- * rather than trusting the export's own `signingPublicKeys`.
133
+ * Public keys the caller supplies (GET /v1/verification-keys,
134
+ * /.well-known/scitt-keys, its own records). These override any key
135
+ * embedded in the export under the same id. A key the Server serves comes
136
+ * from its database, so supplying keys says where they came from, not that
137
+ * they are trusted: pin `trustAnchors` for that.
112
138
  *
113
139
  * Accepts either form:
114
140
  * - `Record<keyId, base64SpkiDer>`: the compact map shape
115
- * - `OutOfBandKeyEntry[]`: the natural shape returned by
141
+ * - `SuppliedKeyEntry[]`: the natural shape returned by
116
142
  * `client.verificationKeys.list().data` and SCITT COSE_KeySet listings
117
143
  *
118
- * Anything else throws `TypeError` at the boundary. Fail-closed: the verifier
119
- * never silently falls back to embedded keys when the caller meant to defeat
120
- * trust in them.
144
+ * - `{ data: SuppliedKeyEntry[] }`: the `/v1/verification-keys` body as
145
+ * served, read as its `data`
146
+ *
147
+ * Anything else throws `TypeError` at the boundary.
121
148
  */
122
- publicKeys?: Record<string, string> | ReadonlyArray<OutOfBandKeyEntry>;
149
+ publicKeys?: Record<string, string> | ReadonlyArray<SuppliedKeyEntry> | {
150
+ data: ReadonlyArray<SuppliedKeyEntry>;
151
+ };
123
152
  /** Require every entry to reference this keyId (else CHAIN_KEY_POLICY_VIOLATION). */
124
153
  requireKeyId?: string;
125
154
  /**
126
- * High-assurance: refuse keys embedded in the export. An entry whose only key
127
- * is export-embedded fails CHAIN_KEY_POLICY_VIOLATION; verifying the engine
128
- * against its own embedded key is not an independent audit.
155
+ * Refuse keys embedded in the export: an entry whose only key is
156
+ * export-embedded fails CHAIN_KEY_POLICY_VIOLATION.
157
+ */
158
+ requireSuppliedKeys?: boolean;
159
+ /**
160
+ * SPKI digests (`sha256:<64 hex>`) of vault keys pinned out of band: the
161
+ * installer prints one, and the Server's `signing-key-digest.js` derives it
162
+ * from a key. With at least one, the signed key statements the export
163
+ * carries (`exportMetadata.signingKeyStatements`, plus any `statements` on
164
+ * supplied keys) are walked from these anchors, every key is graded
165
+ * anchored or not, an entry signed by a key the walk does not anchor fails
166
+ * CHAIN_SIGNING_KEY_UNANCHORED, and each anchored key's window is the one
167
+ * its statements sign. Without anchors the result says so in `keyTrust` and
168
+ * `optionalChecks.key_anchoring`, and every key is taken on the word of
169
+ * whoever embedded or supplied it. An empty array is the same as omitting
170
+ * it: no walk runs and `keyTrust.status` is `no_anchor`. Malformed entries
171
+ * throw `TypeError`.
129
172
  */
130
- requireOutOfBandKeys?: boolean;
173
+ trustAnchors?: readonly string[];
174
+ /**
175
+ * Keys distrusted from outside the database, in the Server's
176
+ * `VAULT_DISTRUSTED_KEYS` form (`sha256:<64 hex>`, optionally
177
+ * `@<RFC 3339 instant>`): what such a key stored at or after the instant
178
+ * (with none, from the retirement a trusted key signed for it, and with
179
+ * neither, ever) counts for nothing in the walk. Give auditors the entries
180
+ * the operator set. Used only with `trustAnchors`: given without them it
181
+ * throws `TypeError`, since nothing would apply it.
182
+ */
183
+ distrustedKeys?: ReadonlyArray<string | DistrustedKey>;
131
184
  /**
132
185
  * Ed25519 public keys of agent ephemeral certs, as JWKs: the `publicKeyJwk`
133
186
  * the agent sent to `POST /v1/auth/oidc/cert`, which is also the `cnf.jwk`
@@ -186,14 +239,23 @@ export interface VerifyExportResult {
186
239
  */
187
240
  optionalChecks: Record<OptionalCheck, CheckApplicability>;
188
241
  /**
189
- * How many signature checks resolved against out-of-band vs export-embedded
190
- * keys. `embedded > 0` means the verdict trusts keys shipped by the engine
191
- * that produced the export. Supply out-of-band keys for an independent audit.
242
+ * How many signature checks resolved against supplied vs export-embedded
243
+ * keys. Provenance only; whether a key is trusted is `keyTrust`.
192
244
  */
193
245
  keyProvenance: {
194
- outOfBand: number;
246
+ supplied: number;
195
247
  embedded: number;
196
248
  };
249
+ /**
250
+ * Whether the keys were anchored, and to what. `status: 'no_anchor'` means
251
+ * no `trustAnchors` were given, and `status: 'no_anchored_signature'` that
252
+ * they were but no entry verified under a key they anchor: either way the
253
+ * verdict rests on nothing pinned, which is not a trusted verdict whatever
254
+ * `valid` says (see `KeyTrustStatus`). Findings on
255
+ * the key statements themselves (KEY_STATEMENT_INVALID, KEY_CLOSURE_INVALID,
256
+ * CHAIN_KEY_WINDOW_DRIFT) are listed here and make `valid` false.
257
+ */
258
+ keyTrust: KeyTrustReport;
197
259
  /**
198
260
  * Per-entry fields the export self-describes as UNSIGNED display projections
199
261
  * (from `verificationGuide.unsignedFields`), e.g. `actorDisplayName`.
@@ -209,5 +271,19 @@ export interface VerifyExportResult {
209
271
  present: number;
210
272
  verified: number;
211
273
  };
274
+ /**
275
+ * `trusted`, `unanchored` or `failed` (see `Verdict`). Read this rather
276
+ * than `valid` alone: a valid result with no `trustAnchors`, or none that
277
+ * anchored a signature, is `unanchored`, which is not a trusted verdict.
278
+ */
279
+ verdict: Verdict;
212
280
  }
213
- export declare function verifyAuditExport(exportData: RecordAuditExportInput, options?: VerifyExportOptions): VerifyExportResult;
281
+ /**
282
+ * Verify one record's `/audit-export` document offline.
283
+ *
284
+ * Throws `TypeError` when the document is not an export at all (no
285
+ * `exportMetadata` object, or `entries` that is not an array), on a malformed
286
+ * option, and on `distrustedKeys` without `trustAnchors`. A malformed entry
287
+ * inside a well-formed document is a failure code on that entry, never a throw.
288
+ */
289
+ export declare function verifyAuditExport(exportData: RecordAuditExportInput, given?: VerifyExportOptions): VerifyExportResult;