@agledger/verify-core 2.2.0 → 4.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.
Files changed (49) hide show
  1. package/LICENSE +18 -18
  2. package/README.md +797 -29
  3. package/dist/acknowledgements.d.ts +32 -0
  4. package/dist/acknowledgements.js +88 -0
  5. package/dist/anchors.d.ts +349 -0
  6. package/dist/anchors.js +654 -0
  7. package/dist/attestation.d.ts +98 -0
  8. package/dist/attestation.js +145 -0
  9. package/dist/audit-export.d.ts +343 -20
  10. package/dist/audit-export.js +400 -22
  11. package/dist/batch-head.d.ts +28 -0
  12. package/dist/batch-head.js +169 -0
  13. package/dist/batch.d.ts +69 -0
  14. package/dist/batch.js +99 -0
  15. package/dist/bulk-export.d.ts +161 -0
  16. package/dist/bulk-export.js +711 -0
  17. package/dist/chain.d.ts +135 -13
  18. package/dist/chain.js +229 -24
  19. package/dist/claim.d.ts +23 -0
  20. package/dist/claim.js +100 -0
  21. package/dist/export-anchors.d.ts +84 -0
  22. package/dist/export-anchors.js +109 -0
  23. package/dist/export-evidence.d.ts +90 -0
  24. package/dist/export-evidence.js +186 -0
  25. package/dist/export-pages.d.ts +476 -0
  26. package/dist/export-pages.js +586 -0
  27. package/dist/failures.d.ts +20 -16
  28. package/dist/failures.js +44 -16
  29. package/dist/federation-wire.d.ts +78 -11
  30. package/dist/federation-wire.js +199 -57
  31. package/dist/history-seal.d.ts +100 -0
  32. package/dist/history-seal.js +301 -0
  33. package/dist/index.d.ts +36 -8
  34. package/dist/index.js +17 -4
  35. package/dist/key-statements.d.ts +138 -5
  36. package/dist/key-statements.js +191 -20
  37. package/dist/ml-dsa-kats.d.ts +18 -0
  38. package/dist/ml-dsa-kats.js +241 -0
  39. package/dist/primitives.d.ts +255 -18
  40. package/dist/primitives.js +612 -55
  41. package/dist/read-log.d.ts +350 -0
  42. package/dist/read-log.js +816 -0
  43. package/dist/schema-chain-export.d.ts +82 -0
  44. package/dist/schema-chain-export.js +474 -0
  45. package/dist/walk-anchors.d.ts +115 -0
  46. package/dist/walk-anchors.js +133 -0
  47. package/dist/walk-checkpoints.d.ts +125 -0
  48. package/dist/walk-checkpoints.js +118 -0
  49. package/package.json +6 -5
@@ -0,0 +1,301 @@
1
+ /**
2
+ * The history seal: what an ML-DSA key signs over everything written under
3
+ * the keys before it.
4
+ *
5
+ * When a Server retires an Ed25519, ES256 or ES384 vault key from a process
6
+ * that signs with ML-DSA, it writes one seal: an RFC 9162 Merkle root over one
7
+ * leaf per chain, each leaf the chain's tip at that moment, in the 56-byte
8
+ * form the batched cadence uses ({@link BATCH_LEAF_FORMAT}). The retirement
9
+ * waits out every write under the retired key first, so nothing that key
10
+ * signs can land above a sealed tip.
11
+ *
12
+ * The seal is one COSE_Sign1 in the key-statement envelope: protected header
13
+ * `{1: alg, 3: cty, 4: kid}` with `cty` = {@link HISTORY_SEAL_CTY}, signed
14
+ * over the RFC 9052 `Sig_structure` with an empty external_aad. Its payload is
15
+ * a deterministic-CBOR map:
16
+ *
17
+ * typ 'history-seal'
18
+ * iss the Server's issuer URL (informational)
19
+ * seal the seal's id (a uuid string)
20
+ * treeSize how many leaves the root covers
21
+ * root bstr of 32 bytes
22
+ * leaf the leaf format
23
+ * subject { kid, spkiSha256, alg, activatedAt, retiredAt }: the retired key
24
+ * closure hex SHA-256 of the closure payload the same retirement signed
25
+ * iat epoch seconds, informational
26
+ *
27
+ * The seal and that closure name each other: the closure carries
28
+ * `history: { seal, root, treeSize }`, and both are signed by one key.
29
+ *
30
+ * What a verifier does with it, on a walk that trusts an ML-DSA key: every
31
+ * entry signed by a classical key must sit at or below its chain's leaf in the
32
+ * seal that covers that key, and the chain's entry at the sealed position must
33
+ * be the one the leaf names. A classical signature alone then proves nothing;
34
+ * the ML-DSA-signed root does. The seal that covers a key is its own, or, for
35
+ * a key retired before any seal was written, the first seal written after its
36
+ * retirement (every seal covers every chain's tip). A classical key no seal
37
+ * covers is reported as unsealed.
38
+ *
39
+ * A walk that trusts no ML-DSA key (an install that signs with ES384
40
+ * throughout, or a verification with no `trustAnchors`) writes no seal and is
41
+ * held to none.
42
+ */
43
+ import { decode as cborDecode, encode as cborEncode, rfc8949EncodeOptions } from 'cborg';
44
+ import { BATCH_LEAF_FORMAT, batchLeafBytes } from './batch.js';
45
+ import { STRICT_CBOR_DECODE } from './cbor-strict.js';
46
+ import { placeInKeyWindow } from './chain.js';
47
+ import { STATEMENT_COSE_ALG, decodeSign1, isPostQuantumKey, sigStructure, spkiSha256 } from './key-statements.js';
48
+ import { instantMs } from './instant.js';
49
+ import { describeUnsupportedAlgorithm, resolveKeyAlgorithm, resolveKeyAlgorithmOrHostRefused, rfc9162LeafHash, runtimeCanCompute, signatureShape, verifyRfc9162Inclusion, verifySignatureBytes, } from './primitives.js';
50
+ /** COSE content type (header label 3) of a signed history seal. */
51
+ export const HISTORY_SEAL_CTY = 'application/vnd.agledger.history-seal+cbor';
52
+ /** The chain key the platform-ops chain's leaf carries. */
53
+ export const PLATFORM_OPS_CHAIN_KEY = '00000000-0000-0000-0000-000000000000';
54
+ const HEX64 = /^[0-9a-f]{64}$/;
55
+ const HEX16 = /^[0-9a-f]{16}$/;
56
+ const INSTANT_US = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{6}Z$/;
57
+ function decodeHistorySealPayload(bytes) {
58
+ let raw;
59
+ try {
60
+ raw = cborDecode(bytes, { ...STRICT_CBOR_DECODE, useMaps: false });
61
+ if (Buffer.compare(Buffer.from(cborEncode(raw, rfc8949EncodeOptions)), Buffer.from(bytes)) !== 0)
62
+ return null;
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw) || raw instanceof Uint8Array)
68
+ return null;
69
+ const r = raw;
70
+ const { typ, iss, seal, treeSize, root, leaf, subject, closure, iat } = r;
71
+ if (typ !== 'history-seal' || typeof iss !== 'string' || typeof seal !== 'string'
72
+ || typeof treeSize !== 'number' || !Number.isSafeInteger(treeSize) || treeSize < 0
73
+ || !(root instanceof Uint8Array) || root.length !== 32
74
+ || typeof leaf !== 'string' || typeof iat !== 'number' || !Number.isInteger(iat)
75
+ || (closure !== undefined && (typeof closure !== 'string' || !HEX64.test(closure)))
76
+ || Object.keys(r).length !== (closure === undefined ? 8 : 9)) {
77
+ return null;
78
+ }
79
+ if (subject === null || typeof subject !== 'object' || Array.isArray(subject) || subject instanceof Uint8Array)
80
+ return null;
81
+ const s = subject;
82
+ const { kid, spkiSha256: digest, alg, activatedAt, retiredAt } = s;
83
+ if (typeof kid !== 'string' || !HEX16.test(kid) || typeof digest !== 'string' || !HEX64.test(digest) || digest.slice(0, 16) !== kid
84
+ || typeof alg !== 'string' || typeof activatedAt !== 'string' || !INSTANT_US.test(activatedAt)
85
+ || typeof retiredAt !== 'string' || !INSTANT_US.test(retiredAt) || Object.keys(s).length !== 5) {
86
+ return null;
87
+ }
88
+ return {
89
+ seal,
90
+ treeSize,
91
+ root: Buffer.from(root).toString('hex'),
92
+ leaf,
93
+ subject: { kid, spkiSha256: digest, alg, activatedAt, retiredAt },
94
+ closure: closure ?? null,
95
+ };
96
+ }
97
+ /**
98
+ * Judge one history seal against the keys the artifact's entries are verified
99
+ * with (after `applyKeyTrust`) and the walk that anchored them. Never throws
100
+ * on a malformed seal: it is `invalid`, with the reason.
101
+ */
102
+ export function judgeHistorySeal(seal, keys, trust) {
103
+ const id = typeof seal?.id === 'string' ? seal.id : '';
104
+ const signingKeyId = typeof seal?.signingKeyId === 'string' ? seal.signingKeyId : null;
105
+ const verdict = (state, detail, payload = null) => ({
106
+ id,
107
+ state,
108
+ detail,
109
+ // A seal that does not decode still counts against the key it is filed for.
110
+ subjectKeyId: payload?.subject.kid ?? (typeof seal?.retiredKeyId === 'string' ? seal.retiredKeyId : null),
111
+ subjectRetiredAt: payload?.subject.retiredAt ?? null,
112
+ treeSize: payload?.treeSize ?? null,
113
+ root: payload?.root ?? null,
114
+ signingKeyId,
115
+ });
116
+ if (id === '' || signingKeyId === null)
117
+ return verdict('invalid', 'The history seal carries no id or no signingKeyId.');
118
+ const sign1 = decodeSign1(seal.coseSign1);
119
+ if (sign1 === null)
120
+ return verdict('invalid', `History seal ${id} does not decode as a tagged COSE_Sign1.`);
121
+ if (sign1.cty !== HISTORY_SEAL_CTY)
122
+ return verdict('invalid', `History seal ${id} is not signed as a history seal (content type ${JSON.stringify(sign1.cty)}).`);
123
+ const payload = decodeHistorySealPayload(sign1.payloadBstr);
124
+ if (payload === null)
125
+ return verdict('invalid', `History seal ${id}'s payload does not decode as a history seal.`);
126
+ const bad = (detail) => verdict('invalid', detail, payload);
127
+ if (sign1.kid !== signingKeyId)
128
+ return bad(`History seal ${id} is filed under key ${signingKeyId} and its signed kid is ${sign1.kid ?? 'absent'}.`);
129
+ if (payload.seal.toLowerCase() !== id.toLowerCase())
130
+ return bad(`History seal ${id} signs the id ${payload.seal}.`);
131
+ if (payload.leaf !== BATCH_LEAF_FORMAT)
132
+ return bad(`History seal ${id} names the leaf format ${JSON.stringify(payload.leaf)}; this verifier reads ${BATCH_LEAF_FORMAT}.`);
133
+ if (typeof seal.retiredKeyId !== 'string' || seal.retiredKeyId !== payload.subject.kid) {
134
+ return bad(`History seal ${id} is filed for key ${String(seal.retiredKeyId)} and signs the retirement of ${payload.subject.kid}.`);
135
+ }
136
+ if (seal.treeSize !== undefined && seal.treeSize !== payload.treeSize)
137
+ return bad(`History seal ${id}'s treeSize is ${seal.treeSize} beside it and ${payload.treeSize} signed.`);
138
+ if (seal.rootHash !== undefined && (typeof seal.rootHash !== 'string' || seal.rootHash.toLowerCase() !== payload.root)) {
139
+ return bad(`History seal ${id}'s rootHash differs from the root it signs.`);
140
+ }
141
+ // The retired key: the one the artifact holds under that id, and a classical one.
142
+ const subject = keys.get(payload.subject.kid);
143
+ if (subject && spkiSha256(subject.spkiBase64) !== payload.subject.spkiSha256) {
144
+ return bad(`History seal ${id} names key ${payload.subject.kid} with another fingerprint than the key this artifact carries under that id.`);
145
+ }
146
+ if (payload.subject.alg.startsWith('ML-DSA') || (subject && isPostQuantumKey(subject.spkiBase64))) {
147
+ return bad(`History seal ${id} seals ${payload.subject.kid}, an ML-DSA key; a seal covers what an Ed25519, ES256 or ES384 key signed.`);
148
+ }
149
+ // The closure the same retirement signed, bound both ways and signed by the same key.
150
+ if (payload.closure === null)
151
+ return bad(`History seal ${id} names no closure, so nothing ties it to the retirement of ${payload.subject.kid}.`);
152
+ const closure = (trust.closures.get(payload.subject.spkiSha256) ?? []).find((c) => c.digest === payload.closure);
153
+ if (!closure) {
154
+ return bad(`History seal ${id} names a closure of ${payload.subject.kid} (payload digest ${payload.closure.slice(0, 16)}...) that is not among the closures of that key this walk counts.`);
155
+ }
156
+ if (closure.history === null || closure.history.seal.toLowerCase() !== id.toLowerCase()
157
+ || closure.history.root !== payload.root || closure.history.treeSize !== payload.treeSize) {
158
+ return bad(`History seal ${id} names a closure of ${payload.subject.kid} that does not name this seal, its root and its tree size back.`);
159
+ }
160
+ if (closure.endorserKeyId !== signingKeyId) {
161
+ return bad(`History seal ${id} is signed by ${signingKeyId}, and the closure it names is signed by ${closure.endorserKeyId}; one retirement signs both with one key.`);
162
+ }
163
+ if (closure.retiredAt !== payload.subject.retiredAt) {
164
+ return bad(`History seal ${id} dates ${payload.subject.kid}'s retirement ${payload.subject.retiredAt}, and the closure it names dates it ${closure.retiredAt}.`);
165
+ }
166
+ const key = keys.get(signingKeyId);
167
+ if (!key)
168
+ return bad(`No public key is available for history seal ${id}'s signing key ${signingKeyId}.`);
169
+ // An ML-DSA key this host refused to load is a host refusal, as it is for
170
+ // an entry's key, not a key of another type.
171
+ const algorithm = resolveKeyAlgorithmOrHostRefused(key.spkiBase64);
172
+ if (typeof algorithm !== 'object' || !algorithm.name.startsWith('ML-DSA')) {
173
+ return bad(`History seal ${id} is signed by ${signingKeyId}, which is not an ML-DSA key; only an ML-DSA signature seals what classical keys signed.`);
174
+ }
175
+ // Checks that need no computation run before this host's capability or the
176
+ // key's undecided trust is asked, so they read the same on every host.
177
+ if (algorithm.verifiable) {
178
+ if (sign1.alg !== STATEMENT_COSE_ALG[algorithm.name])
179
+ return bad(`History seal ${id}'s protected-header alg is not the one key ${signingKeyId} (${algorithm.name}) signs under.`);
180
+ if (signatureShape(algorithm, sign1.signature) !== 'signature') {
181
+ return bad(`History seal ${id}'s signature is not a signature under key ${signingKeyId} (${algorithm.name}): all zero, or not ${algorithm.signatureLength} bytes.`);
182
+ }
183
+ }
184
+ if (key.trust === 'undecided' || !algorithm.verifiable || !runtimeCanCompute(algorithm)) {
185
+ return verdict('unsupported', `History seal ${id}'s key ${signingKeyId} ${describeUnsupportedAlgorithm(key.spkiBase64)}`, payload);
186
+ }
187
+ if (key.trust !== 'anchored')
188
+ return bad(`History seal ${id}'s key ${signingKeyId} is not linked by any signed key statement to a pinned trust anchor.`);
189
+ const placed = placeInKeyWindow(key, seal.createdAt, `History seal ${id}`);
190
+ if (placed.placement !== 'inside') {
191
+ return bad('detail' in placed ? placed.detail : `History seal ${id} was written outside key ${signingKeyId}'s window.`);
192
+ }
193
+ if (!verifySignatureBytes(key.spkiBase64, sigStructure(sign1.protectedBstr, sign1.payloadBstr), sign1.signature)) {
194
+ return bad(`History seal ${id}'s signature does not verify under key ${signingKeyId}.`);
195
+ }
196
+ return verdict('ok', `History seal ${id} verifies under key ${signingKeyId} and seals what ${payload.subject.kid} signed until ${payload.subject.retiredAt}.`, payload);
197
+ }
198
+ /**
199
+ * Judge the seals an artifact carries and decide which one covers each
200
+ * classical key. `trust` is the key walk; null (no `trustAnchors`) holds no
201
+ * key to any seal.
202
+ */
203
+ export function planHistorySeals(seals, keys, trust) {
204
+ const judged = new Map();
205
+ const bytesOf = new Map();
206
+ if (trust !== null) {
207
+ for (const seal of seals) {
208
+ const v = judgeHistorySeal(seal, keys, trust);
209
+ const id = v.id.toLowerCase();
210
+ // Anything that is neither a string nor bytes is already `invalid` above; it only needs a spelling to compare.
211
+ const raw = seal?.coseSign1;
212
+ const bytes = typeof raw === 'string' ? raw : raw instanceof Uint8Array ? Buffer.from(raw).toString('base64') : `?${String(raw)}`;
213
+ if (judged.has(id) && bytesOf.get(id) !== bytes) {
214
+ judged.set(id, { ...v, state: 'invalid', detail: `History seal ${v.id} is listed twice with different bytes.` });
215
+ }
216
+ else if (!judged.has(id)) {
217
+ judged.set(id, v);
218
+ bytesOf.set(id, bytes);
219
+ }
220
+ }
221
+ }
222
+ const applies = trust !== null && [...keys.values()].some((k) => k.trust === 'anchored' && isPostQuantumKey(k.spkiBase64));
223
+ // Seals that hold, earliest retirement first: the order a key with no seal
224
+ // of its own is matched against.
225
+ const holding = [...judged.values()]
226
+ .filter((v) => v.state === 'ok' && v.subjectRetiredAt !== null)
227
+ .sort((a, b) => instantMs(a.subjectRetiredAt ?? '') - instantMs(b.subjectRetiredAt ?? ''));
228
+ const cache = new Map();
229
+ const decide = (keyId) => {
230
+ const key = keys.get(keyId);
231
+ if (!applies || !key || key.trust !== 'anchored')
232
+ return null;
233
+ const algorithm = resolveKeyAlgorithm(key.spkiBase64);
234
+ if (typeof algorithm !== 'object' || isPostQuantumKey(key.spkiBase64))
235
+ return null;
236
+ const own = [...judged.values()].filter((v) => v.subjectKeyId === keyId);
237
+ const ownOk = own.find((v) => v.state === 'ok');
238
+ if (ownOk)
239
+ return { state: 'sealed', seal: ownOk };
240
+ const ownBad = own.find((v) => v.state === 'invalid') ?? own[0];
241
+ if (ownBad)
242
+ return { state: ownBad.state === 'unsupported' ? 'unsupported' : 'invalid', detail: ownBad.detail };
243
+ if (typeof key.retiredAt !== 'string' || key.retiredAt === '') {
244
+ return {
245
+ state: 'unsealed',
246
+ detail: `Key ${keyId} (${algorithm.name}) has no retirement signed by an ML-DSA key and no history seal. Until it is retired from a process that signs with ML-DSA, what it signed rests on its ${algorithm.name} signatures alone. Retire it on the Server and take the export again.`,
247
+ };
248
+ }
249
+ const retired = instantMs(key.retiredAt);
250
+ const later = holding.find((v) => instantMs(v.subjectRetiredAt ?? '') >= retired);
251
+ if (later)
252
+ return { state: 'sealed', seal: later };
253
+ return {
254
+ state: 'unsealed',
255
+ detail: `Key ${keyId} (${algorithm.name}) was retired ${key.retiredAt}, and this artifact carries no history seal written at or after that. What it signed rests on its ${algorithm.name} signatures alone.`,
256
+ };
257
+ };
258
+ return {
259
+ seals: judged,
260
+ coverOf(keyId) {
261
+ if (!cache.has(keyId))
262
+ cache.set(keyId, decide(keyId));
263
+ return cache.get(keyId) ?? null;
264
+ },
265
+ };
266
+ }
267
+ /**
268
+ * Resolve a chain's leaf in a seal whose verdict is `ok`: the proof must be
269
+ * for this chain and reach the signed root. `proof` is null or undefined when
270
+ * the artifact carries none for this chain (the seal has no leaf for it).
271
+ */
272
+ export function resolveHistorySealLeaf(seal, chainKey, proof) {
273
+ if (proof === null || proof === undefined)
274
+ return { state: 'missing' };
275
+ const bad = (detail) => ({ state: 'invalid', detail });
276
+ const leaf = proof.leaf;
277
+ if (typeof proof !== 'object' || leaf === null || typeof leaf !== 'object')
278
+ return bad(`History seal ${seal.id}'s proof is not { leaf, leafIndex, auditPath }.`);
279
+ const { chainKey: named, chainPosition, entryHash } = leaf;
280
+ if (typeof named !== 'string' || typeof chainKey !== 'string' || named.toLowerCase() !== chainKey.toLowerCase()) {
281
+ return bad(`History seal ${seal.id}'s proof is for chain ${String(named)}, not this chain (${String(chainKey)}).`);
282
+ }
283
+ const bytes = typeof chainPosition === 'number' && typeof entryHash === 'string' ? batchLeafBytes(named.toLowerCase(), chainPosition, entryHash) : null;
284
+ if (bytes === null || typeof chainPosition !== 'number' || typeof entryHash !== 'string') {
285
+ return bad(`History seal ${seal.id}'s leaf for this chain is not a chain key, a position and a 64-character lowercase hex entry hash.`);
286
+ }
287
+ if (seal.treeSize === null || seal.root === null)
288
+ return bad(`History seal ${seal.id} carries no signed tree size or root.`);
289
+ if (!Number.isSafeInteger(proof.leafIndex) || proof.leafIndex < 0 || proof.leafIndex >= seal.treeSize) {
290
+ return bad(`History seal ${seal.id}'s proof names leaf ${String(proof.leafIndex)}, outside the ${seal.treeSize} leaves it signs.`);
291
+ }
292
+ const hashes = proof.auditPath;
293
+ if (!Array.isArray(hashes) || !hashes.every((h) => typeof h === 'string' && HEX64.test(h))) {
294
+ return bad(`History seal ${seal.id}'s auditPath is not an array of 64-character lowercase hex hashes.`);
295
+ }
296
+ const path = hashes.map((h) => new Uint8Array(Buffer.from(h, 'hex')));
297
+ if (!verifyRfc9162Inclusion(rfc9162LeafHash(bytes), proof.leafIndex, seal.treeSize, path, new Uint8Array(Buffer.from(seal.root, 'hex')))) {
298
+ return bad(`History seal ${seal.id}'s proof does not reach the root it signs from this chain's leaf.`);
299
+ }
300
+ return { state: 'ok', chainPosition, entryHash };
301
+ }
package/dist/index.d.ts CHANGED
@@ -6,14 +6,42 @@
6
6
  export { suggestion } from './failures.js';
7
7
  export type { FailureCode } from './failures.js';
8
8
  export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
9
- export type { AccountedEntry, AccountedEntryCode, AgentKeyRegistry, KeySource, KeyTrustState, KeyWindowPlacement, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, VerifyChainOptions, } from './chain.js';
10
- export { verifyAuditExport } from './audit-export.js';
11
- export type { AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, ExportOptionalCheck, } from './audit-export.js';
12
- export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
9
+ export type { AccountedEntry, AccountedEntryCode, AgentKeyEntry, AgentKeyRegistry, KeySource, KeyTrustState, KeyWindowPlacement, VerificationKey, KeyRegistry, NormalizedEntry, OptionalCheck, CheckApplicability, SignatureOutcome, ChainEntryResult, ChainResult, EvidenceBindingCounts, HistorySealCounts, SignatureCoverage, VerifyChainOptions, } from './chain.js';
10
+ export { NOT_A_RECORD_EXPORT, auditVaultExportKind, capVerdict, verifyAuditExport } from './audit-export.js';
11
+ export type { VerdictCap, VerdictCapReason, AuditExportEntryInput, RecordAuditExportInput, SigningKeyWindow, VerifyExportOptions, SuppliedKeyEntry, EntryVerificationResult, VerifyExportResult, ExportOptionalCheck, } from './audit-export.js';
12
+ export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, sealedVerdict, pinReachesNoKey, isPostQuantumKey, pinPredatesDetail, pinPredatesSuccessors, isUnverifiable, unverifiableVerdict, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
13
13
  export type { ComputeKeyTrustInput, DistrustedKey, DistrustSpan, DumpKeyStatementRow, DumpSigningKeyRow, KeyRegistryFinding, KeyRegistryFindingCode, KeyStatementInput, KeyStatementKind, KeyTrust, KeyTrustEntry, KeyTrustNote, KeyTrustReport, KeyTrustStatus, PublishedKeyStatement, TrustKeyInput, Verdict, VerificationKeysDocument, } from './key-statements.js';
14
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, } from './federation-wire.js';
15
- export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, CheckFederationWireOptions, } from './federation-wire.js';
14
+ export { BATCH_HEAD_CTY, BATCH_LEAF_FORMAT, BATCH_MARKER_LABEL, BATCH_PENDING_GRACE_SECONDS, batchLeafBytes, checkBatchProof, isBatchedProtectedHeader, } from './batch.js';
15
+ export type { BatchHeadRegistry, BatchHeadVerdict, BatchProofInput } from './batch.js';
16
+ export { buildBatchHeadRegistry, judgeBatchHead } from './batch-head.js';
17
+ export type { BatchHeadInput } from './batch-head.js';
18
+ export { HISTORY_SEAL_CTY, PLATFORM_OPS_CHAIN_KEY, judgeHistorySeal, planHistorySeals, resolveHistorySealLeaf } from './history-seal.js';
19
+ export type { HistorySealCover, HistorySealInput, HistorySealLeaf, HistorySealPlan, HistorySealProofInput, HistorySealVerdict } from './history-seal.js';
20
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, FEDERATION_ACK_DOMAIN, FEDERATION_ACK_KINDS, FEDERATION_CO_SIGN_CLAIM_FIELDS, FEDERATION_CO_SIGN_DOMAIN, FederationKeyHistoryError, verifyFederationAck, verifyFederationCoSign, } from './federation-wire.js';
21
+ export type { FederationKeyEntry, FederationKeyHistoryDocument, FederationKeyHistoryStatement, FederationKeyRegistry, FederationTrustedKey, FederationWire, FederationWireOutcome, CheckFederationWireOptions, FederationAckInput, FederationCoSignInput, FederationSignatureOutcome, } from './federation-wire.js';
16
22
  export { instantMs } from './instant.js';
17
23
  export { assertKnownOptions } from './options.js';
18
- export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
19
- export type { CoseSign1Parts, CoseVerifyOutcome, KeyAlgorithm, ActorClaim, ChainClaim, AgentPublicKeyJwk, AgentSignatureClaim, AgentSignatureOutcome, ReceiptInclusionProof, ReceiptVerifyOutcome, } from './primitives.js';
24
+ export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, hostRefusalCause, uncomputableAlgorithm, uncomputableAlgorithms, uncomputableNote, verifyAsIfHostComputed, isVerifyingAsIfHostComputed, hasComputableAnchor, anchorAlgorithms, unverifiableDetail, NODE_FLOOR, runtimeBelowFloor, belowFloorNotice, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, agentJwkThumbprint, agentJwkToSpki, agentKeyAlgorithm, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
25
+ export type { CoseSign1Parts, CoseVerifyOutcome, KeyAlgorithm, ActorClaim, ChainClaim, AgentPublicKeyJwk, AgentSignatureClaim, AgentSignatureOutcome, ReceiptInclusionProof, ReceiptVerifyOutcome, Uncomputable, UncomputableAlgorithm, RuntimeBelowFloor, } from './primitives.js';
26
+ export { decodeSignedClaim, uuidSubjectDigest, UNSIGNED_KID } from './claim.js';
27
+ export type { SignedClaim } from './claim.js';
28
+ export { verifyExportCheckpoint, verifyExportReceipts } from './export-evidence.js';
29
+ export type { CheckpointEvidenceInput, CheckpointEvidenceReport, ExportCheckpointInput, ReceiptCounts, } from './export-evidence.js';
30
+ export { ANCHOR_DOCUMENT_VERSION, KEY_WINDOW_CLOCK_SKEW_SECONDS, VAULT_CHECKPOINT_PREDICATE_TYPE, anchorDocumentChainKey, anchorObjectKeyOfPath, compareCheckpointAnchors, placeSignedIat, rewindAcknowledgementOf, unreadableAnchorVerdict, verifyRewindAcknowledgements, } from './anchors.js';
31
+ export type { AcknowledgedRewindInput, AcknowledgementReport, AcknowledgementVerdict, AnchorChainView, AnchorComparison, AnchorDisagreementCode, AnchorDocumentInput, AnchorFinding, AnchorNotComparableReason, AnchorVerdict, CoveredFinding, RewindAcknowledgement, } from './anchors.js';
32
+ export { verifyCheckpointCoverage, verifyExportAnchors } from './export-anchors.js';
33
+ export type { CheckpointCoverageReport, ExportAnchorsReport, ExportAnchorsWalkView, ExportEvidenceFinding } from './export-anchors.js';
34
+ export { CONTENT_BOUND_ENTRY_TYPES, CONTENT_HASH_PATTERN, readComplianceRecords, verifyAttestations } from './attestation.js';
35
+ export type { AttestationEntryReport, AttestationFinding, AttestationReport, AttestationEntryView, ComplianceRecordInput } from './attestation.js';
36
+ export { verifyBulkExport } from './bulk-export.js';
37
+ export type { BulkWalkChainSet, BulkWalkQuery, VerifyBulkExportOptions, VerifyBulkExportResult } from './bulk-export.js';
38
+ export type { AcknowledgementSource } from './acknowledgements.js';
39
+ export { walkOrder } from './export-pages.js';
40
+ export { schemaCheckpointKey, verifySchemaChainExport } from './schema-chain-export.js';
41
+ export type { VerifySchemaChainExportOptions, VerifySchemaChainExportResult } from './schema-chain-export.js';
42
+ export type { BulkExportPage, ExportChainResult, ExportPageMetadata, ExportPageRow, ExportReadTime, ReadTimeSource, ExportWalkFinding, ExportWalkInput, ExportWalkReport, ExportWalkResultBase, SchemaChainExportPage, } from './export-pages.js';
43
+ export { judgeListedCheckpoints } from './walk-checkpoints.js';
44
+ export type { ChainHeldTo, ListedCheckpointFinding, ListedCheckpointOutcome, ListedCheckpointView, VaultCheckpointRow, VaultCheckpointsPage } from './walk-checkpoints.js';
45
+ export type { WalkAcknowledgements, WalkAnchorsReport } from './walk-anchors.js';
46
+ export { orgReadDocumentKind, READ_LOG_STAMP_SKEW_SECONDS, readLogStampDisagreement, verifyOrgReadCheckpoint, verifyOrgReadLog, verifyOrgReadProof } from './read-log.js';
47
+ export type { OrgReadCheckpointInput, OrgReadCheckpointReport, OrgReadCheckpointsPage, OrgReadCosignatureReport, OrgReadCosignerKey, OrgReadDumpRow, OrgReadEntriesPage, OrgReadEntryInput, OrgReadFinding, OrgReadLeafReport, OrgReadListedCheckpoint, OrgReadProofInput, VerifyOrgReadCheckpointResult, VerifyOrgReadLogResult, VerifyOrgReadOptions, VerifyOrgReadProofResult, } from './read-log.js';
package/dist/index.js CHANGED
@@ -5,9 +5,22 @@
5
5
  */
6
6
  export { suggestion } from './failures.js';
7
7
  export { ACCOUNTED_ENTRY_CODE, buildAgentKeyRegistry, buildKeyRegistry, chainOfScope, distrustAccounts, earliestKeyActivation, placeInKeyWindow, verifyChain, writtenWhileSigning, } from './chain.js';
8
- export { verifyAuditExport } from './audit-export.js';
9
- export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
10
- export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, } from './federation-wire.js';
8
+ export { NOT_A_RECORD_EXPORT, auditVaultExportKind, capVerdict, verifyAuditExport } from './audit-export.js';
9
+ export { KEY_STATEMENT_CTY, KEY_STATEMENT_KINDS, applyKeyTrust, assertNotPinnedAndDistrusted, computeKeyTrust, keyStatementFromDumpRow, keyStatementsFromExport, keyStatementsFromVerificationKeys, parseDistrustedKeys, parseTrustAnchors, reportKeyTrust, settleKeyTrust, spkiSha256, sealedVerdict, pinReachesNoKey, isPostQuantumKey, pinPredatesDetail, pinPredatesSuccessors, isUnverifiable, unverifiableVerdict, verdictOf, trustKeyFromDumpRow, } from './key-statements.js';
10
+ export { BATCH_HEAD_CTY, BATCH_LEAF_FORMAT, BATCH_MARKER_LABEL, BATCH_PENDING_GRACE_SECONDS, batchLeafBytes, checkBatchProof, isBatchedProtectedHeader, } from './batch.js';
11
+ export { buildBatchHeadRegistry, judgeBatchHead } from './batch-head.js';
12
+ export { HISTORY_SEAL_CTY, PLATFORM_OPS_CHAIN_KEY, judgeHistorySeal, planHistorySeals, resolveHistorySealLeaf } from './history-seal.js';
13
+ export { FEDERATION_KEY_STATEMENT_DOMAIN, FEDERATION_WIRE_SCHEME, buildFederationKeyRegistry, canonicalizeJson, checkFederationWire, extractFederationWire, federationSignInput, normalizeFederationKey, FEDERATION_KEY_WINDOW_SKEW_MS, FEDERATION_ACK_DOMAIN, FEDERATION_ACK_KINDS, FEDERATION_CO_SIGN_CLAIM_FIELDS, FEDERATION_CO_SIGN_DOMAIN, FederationKeyHistoryError, verifyFederationAck, verifyFederationCoSign, } from './federation-wire.js';
11
14
  export { instantMs } from './instant.js';
12
15
  export { assertKnownOptions } from './options.js';
13
- export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
16
+ export { sha256Hex, sha256HexString, verifyEd25519Bytes, verifySignatureBytes, resolveKeyAlgorithm, algorithmByName, runtimeCanCompute, looksLikeEd25519Key, describeUnsupportedAlgorithm, hostRefusalCause, uncomputableAlgorithm, uncomputableAlgorithms, uncomputableNote, verifyAsIfHostComputed, isVerifyingAsIfHostComputed, hasComputableAnchor, anchorAlgorithms, unverifiableDetail, NODE_FLOOR, runtimeBelowFloor, belowFloorNotice, decodeCoseSign1, verifyCoseSign1, extractActorClaim, extractChainClaim, extractKid, extractOnBehalfOfClaim, extractTraceparentClaim, extractAgentSignatureClaim, agentJwkThumbprint, agentJwkToSpki, agentKeyAlgorithm, ed25519JwkThumbprint, ed25519JwkToSpki, verifyAgentSignature, AGENT_SIGNATURE_CONTEXT, decodePredicate, buildPredicateForRow, stripEnvelopeExtensions, deepEqual, orgReadLeafHash, orgReadMerkleRoot, verifyOrgReadInclusion, rfc9162LeafHash, rfc9162NodeHash, verifyRfc9162Inclusion, extractReceiptInclusionProof, verifyReceipt, } from './primitives.js';
17
+ export { decodeSignedClaim, uuidSubjectDigest, UNSIGNED_KID } from './claim.js';
18
+ export { verifyExportCheckpoint, verifyExportReceipts } from './export-evidence.js';
19
+ export { ANCHOR_DOCUMENT_VERSION, KEY_WINDOW_CLOCK_SKEW_SECONDS, VAULT_CHECKPOINT_PREDICATE_TYPE, anchorDocumentChainKey, anchorObjectKeyOfPath, compareCheckpointAnchors, placeSignedIat, rewindAcknowledgementOf, unreadableAnchorVerdict, verifyRewindAcknowledgements, } from './anchors.js';
20
+ export { verifyCheckpointCoverage, verifyExportAnchors } from './export-anchors.js';
21
+ export { CONTENT_BOUND_ENTRY_TYPES, CONTENT_HASH_PATTERN, readComplianceRecords, verifyAttestations } from './attestation.js';
22
+ export { verifyBulkExport } from './bulk-export.js';
23
+ export { walkOrder } from './export-pages.js';
24
+ export { schemaCheckpointKey, verifySchemaChainExport } from './schema-chain-export.js';
25
+ export { judgeListedCheckpoints } from './walk-checkpoints.js';
26
+ export { orgReadDocumentKind, READ_LOG_STAMP_SKEW_SECONDS, readLogStampDisagreement, verifyOrgReadCheckpoint, verifyOrgReadLog, verifyOrgReadProof } from './read-log.js';
@@ -1,8 +1,16 @@
1
+ import { type Uncomputable } from './primitives.js';
1
2
  import type { KeyRegistry } from './chain.js';
2
3
  /** Content type of a key statement's COSE_Sign1 (protected header label 3). */
3
4
  export declare const KEY_STATEMENT_CTY = "application/vnd.agledger.key-statement+cbor";
4
5
  export declare const KEY_STATEMENT_KINDS: readonly ['succession', 'closure', 'genesis'];
5
6
  export type KeyStatementKind = (typeof KEY_STATEMENT_KINDS)[number];
7
+ /**
8
+ * The COSE `alg` a statement signature must carry for its key's algorithm.
9
+ * Exactly one per algorithm, as the Server signs and checks them; the chain
10
+ * envelope's wider acceptance (RFC 9864 fully-specified code points) does not
11
+ * apply to statements.
12
+ */
13
+ export declare const STATEMENT_COSE_ALG: Readonly<Record<string, number>>;
6
14
  /**
7
15
  * One key statement as a source carries it. A dump row maps onto it with
8
16
  * {@link keyStatementFromDumpRow}; a key document's `statements` with
@@ -171,8 +179,12 @@ export interface KeyTrust {
171
179
  /** SPKI digests of the undecided keys. */
172
180
  undecided: ReadonlySet<string>;
173
181
  findings: KeyRegistryFinding[];
182
+ /** Each key's counting closures signed by a trusted key, by the key's SPKI digest. */
183
+ closures: ReadonlyMap<string, readonly CountedClosure[]>;
174
184
  /** Non-fatal: see {@link KeyTrustNote}. */
175
185
  notes: KeyTrustNote[];
186
+ /** ML-DSA keys (`sha256:<hex>`) a trusted classical key handed over to, which the walk did not follow from it. */
187
+ successorPins: string[];
176
188
  /**
177
189
  * Non-fatal: statements of a dump that a `distrustedKeys` key signed, that
178
190
  * count for nothing, and that were stored before a key the walk trusts
@@ -199,6 +211,21 @@ export interface KeyTrust {
199
211
  unverifiable: number;
200
212
  };
201
213
  }
214
+ /** A closure the walk counts, signed by a key it trusts: what a history seal is bound to. */
215
+ export interface CountedClosure {
216
+ /** SHA-256 (lowercase hex) of the closure's signed payload bytes. */
217
+ digest: string;
218
+ /** The key that signed it. */
219
+ endorserKeyId: string;
220
+ /** The retirement it signs for its subject. */
221
+ retiredAt: string;
222
+ /** The history seal it names, when it names one. */
223
+ history: {
224
+ seal: string;
225
+ root: string;
226
+ treeSize: number;
227
+ } | null;
228
+ }
202
229
  /**
203
230
  * What a `distrustedKeys` entry covers for one key, as the Server's
204
231
  * `distrustSpans` gives it. `cutoff`: the instant from which what the key
@@ -242,6 +269,21 @@ export declare function parseDistrustedKeys(raw: string | readonly string[]): Di
242
269
  * it walks.
243
270
  */
244
271
  export declare function assertNotPinnedAndDistrusted(trustAnchors: string | readonly string[] | undefined, distrustedKeys: ReadonlyArray<string | DistrustedKey> | undefined): void;
272
+ /** A decoded statement-style COSE_Sign1: protected header `{1: alg, 3: cty, 4: kid}`. Internal. */
273
+ export interface Sign1 {
274
+ protectedBstr: Uint8Array;
275
+ payloadBstr: Uint8Array;
276
+ signature: Uint8Array;
277
+ alg: number | null;
278
+ cty: unknown;
279
+ kid: string | null;
280
+ }
281
+ /** Internal: not re-exported from the package. */
282
+ export declare function decodeSign1(raw: unknown): Sign1 | null;
283
+ /** Internal: not re-exported from the package. */
284
+ export declare function sigStructure(protectedBstr: Uint8Array, payloadBstr: Uint8Array): Uint8Array;
285
+ /** Whether a key (base64 SPKI DER) is an ML-DSA key. */
286
+ export declare function isPostQuantumKey(spkiBase64: string): boolean;
245
287
  /**
246
288
  * Walk the key statements from `trustAnchors` and decide which keys are
247
289
  * trusted and what window each carries. Two passes, no fixpoint:
@@ -378,10 +420,56 @@ export type KeyTrustStatus = 'walked' | 'no_anchor' | 'no_anchored_signature';
378
420
  * anchored a signature (`keyTrust.status: 'walked'`), and `unanchored` when it
379
421
  * is valid but rests on nothing pinned, or when the only thing that failed is
380
422
  * that nothing is signed by a key the pinned trustAnchors anchor (see
381
- * {@link verdictOf}). Read this rather than `valid` alone: a valid result with
382
- * no `trustAnchors` is `unanchored`.
423
+ * {@link verdictOf}). `unverifiable` when it is not valid and would be valid
424
+ * if the signature checks this host refused, under algorithms this build
425
+ * supports, had verified: nothing was found wrong, and the signatures this
426
+ * host refused were not verified
427
+ * (see {@link isUnverifiable}). Read this rather than `valid`
428
+ * alone: a valid result with no `trustAnchors` is `unanchored`.
429
+ */
430
+ export type Verdict = 'trusted' | 'unanchored' | 'unverifiable' | 'failed';
431
+ /**
432
+ * Whether a result is `unverifiable`: it is not valid, at least one signature
433
+ * check could not be computed (`uncomputable.count`), this host refused an
434
+ * algorithm this build supports (an `uncomputable.algorithms` entry with cause
435
+ * `host`), and the same input with the same options would be valid if the
436
+ * checks this host refused had verified (`passesIfComputed`, a rerun inside
437
+ * `verifyAsIfHostComputed`, called only when the rest holds).
438
+ *
439
+ * Nothing else is assumed in that rerun: a check under a key of a type this
440
+ * build cannot compute still fails, a signature that was checked and did not
441
+ * verify still fails, and hash, link and count checks run as they are. So a
442
+ * finding that follows only from a refused check (a key closure the refused
443
+ * key signed, an entry under a key the walk could not reach past it) leaves
444
+ * the result `unverifiable`, and any other failure makes it `failed`.
445
+ *
446
+ * The verdict is reserved for a refusal the verifier establishes on this host
447
+ * itself: cause `host` rests on this build's own known-answer test of the
448
+ * algorithm (`runtimeCanCompute`), which nothing in an artifact can change.
449
+ * On a host that computes every algorithm this build supports there is no such
450
+ * cause, the rerun never runs, and no artifact reads `unverifiable`.
451
+ */
452
+ export declare function isUnverifiable(result: {
453
+ valid: boolean;
454
+ uncomputable: Pick<Uncomputable, 'count' | 'algorithms'>;
455
+ passesIfComputed: () => boolean;
456
+ }): boolean;
457
+ /**
458
+ * The {@link Verdict} of a result, with the could-not-compute rule first:
459
+ * `unverifiable` when {@link isUnverifiable} holds, and otherwise whatever
460
+ * `otherwise` gives (`sealedVerdict(verdictOf(...))`, which is called only
461
+ * then, so its reruns cost nothing on an unverifiable result). So a real
462
+ * failure anywhere is `failed`, a result that would be valid had this host
463
+ * computed the algorithms it refused is `unverifiable`, and the `unanchored`
464
+ * readings of a pin that was not met or that predates the move to ML-DSA
465
+ * apply only to a result that is not. `valid` is unchanged: an unverifiable
466
+ * result is not valid.
383
467
  */
384
- export type Verdict = 'trusted' | 'unanchored' | 'failed';
468
+ export declare function unverifiableVerdict(result: {
469
+ valid: boolean;
470
+ uncomputable: Pick<Uncomputable, 'count' | 'algorithms'>;
471
+ passesIfComputed: () => boolean;
472
+ }, otherwise: () => Verdict): Verdict;
385
473
  /**
386
474
  * The {@link Verdict} of a result that carries `valid` and a `keyTrust` report.
387
475
  *
@@ -396,11 +484,48 @@ export type Verdict = 'trusted' | 'unanchored' | 'failed';
396
484
  * of its own; neither is trusted, and the result keeps `valid: false`. An
397
485
  * artifact in which the pin anchors even one key stays `failed`, since an
398
486
  * entry beside it under an unanchored key is a substitution.
487
+ *
488
+ * Pass `passesPinnedOn` as well: it reruns the same input with `trustAnchors`
489
+ * replaced by the list it is given and says whether that run is valid. A
490
+ * pinned run that failed, whose pin is a classical key that handed over to an
491
+ * ML-DSA key (`keyTrust.successorPins`), and whose rerun with those keys
492
+ * pinned beside it passes, is `unanchored` too: the pin predates the move to
493
+ * ML-DSA, and the only thing wrong is that a classical pin does not reach the
494
+ * keys after it. The pinned key itself signed the handover, so this is not a
495
+ * key from elsewhere; it is still not a trusted verdict, since nothing
496
+ * post-quantum links the pin to them. The result keeps `valid: false`.
497
+ *
498
+ * This never returns `unverifiable`: wrap it in {@link unverifiableVerdict},
499
+ * which takes precedence over both `unanchored` readings of a failed run.
399
500
  */
400
501
  export declare function verdictOf(result: {
401
502
  valid: boolean;
402
- keyTrust: Pick<KeyTrustReport, 'status' | 'anchoredKeyIds'>;
403
- }, passesUnpinned?: () => boolean): Verdict;
503
+ keyTrust: Pick<KeyTrustReport, 'status' | 'anchoredKeyIds'> & Partial<Pick<KeyTrustReport, 'anchors' | 'successorPins'>>;
504
+ }, passesUnpinned?: () => boolean, passesPinnedOn?: (trustAnchors: string[]) => boolean): Verdict;
505
+ /** Whether a pinned walk anchored no key at all: the pin names nothing this input holds or links to. */
506
+ export declare function pinReachesNoKey(keyTrust: Pick<KeyTrustReport, 'status' | 'anchoredKeyIds'>): boolean;
507
+ /**
508
+ * Whether a failed pinned run failed only because its pin predates the move to
509
+ * ML-DSA: the walk names successor keys, and the same input passes with them
510
+ * pinned beside the anchors given.
511
+ */
512
+ export declare function pinPredatesSuccessors(keyTrust: Partial<Pick<KeyTrustReport, 'anchors' | 'successorPins'>>, passesPinnedOn?: (trustAnchors: string[]) => boolean): boolean;
513
+ /**
514
+ * What to tell the holder of a pin that predates the move to ML-DSA (a result
515
+ * whose verdict is `unanchored`, `valid` false and `keyTrust.successorPins`
516
+ * not empty): what happened, that it is not evidence of tampering, and which
517
+ * key to confirm and pin.
518
+ */
519
+ export declare function pinPredatesDetail(successorPins: readonly string[]): string;
520
+ /**
521
+ * A verdict, given how the entries classical keys signed stand against the
522
+ * history seals: `trusted` becomes `unanchored` when any such entry is
523
+ * unsealed, since it then rests on a classical signature no ML-DSA key vouches
524
+ * for. Every other verdict is unchanged.
525
+ */
526
+ export declare function sealedVerdict(verdict: Verdict, historySeal: {
527
+ unsealed: number;
528
+ }): Verdict;
404
529
  /** What a verification result says about key anchoring. */
405
530
  export interface KeyTrustReport {
406
531
  /** See {@link KeyTrustStatus}. */
@@ -420,6 +545,14 @@ export interface KeyTrustReport {
420
545
  findings: KeyRegistryFinding[];
421
546
  /** Non-fatal notes from the walk (see {@link KeyTrustNote}); they never fail a verdict. */
422
547
  notes: KeyTrustNote[];
548
+ /**
549
+ * The ML-DSA keys (`sha256:<hex>`) an anchored classical key handed over to
550
+ * in a succession the walk verified on the classical side and did not
551
+ * follow, since a classical signature admits no ML-DSA key. Not empty means
552
+ * the pin predates the move to ML-DSA: the keys after it, and what they
553
+ * signed, are unanchored from that pin alone (see {@link verdictOf}).
554
+ */
555
+ successorPins: string[];
423
556
  /**
424
557
  * Non-fatal: the statements of a dump a `distrustedKeys` key signed that its
425
558
  * entry and a trusted key's retirement of it account for (see