@agledger/verify-core 2.1.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.
- package/LICENSE +18 -18
- package/README.md +869 -53
- package/dist/acknowledgements.d.ts +32 -0
- package/dist/acknowledgements.js +88 -0
- package/dist/anchors.d.ts +349 -0
- package/dist/anchors.js +654 -0
- package/dist/attestation.d.ts +98 -0
- package/dist/attestation.js +145 -0
- package/dist/audit-export.d.ts +404 -29
- package/dist/audit-export.js +547 -28
- package/dist/batch-head.d.ts +28 -0
- package/dist/batch-head.js +169 -0
- package/dist/batch.d.ts +69 -0
- package/dist/batch.js +99 -0
- package/dist/bulk-export.d.ts +161 -0
- package/dist/bulk-export.js +711 -0
- package/dist/cbor-strict.d.ts +9 -0
- package/dist/cbor-strict.js +14 -0
- package/dist/chain.d.ts +221 -31
- package/dist/chain.js +339 -65
- package/dist/claim.d.ts +23 -0
- package/dist/claim.js +100 -0
- package/dist/export-anchors.d.ts +84 -0
- package/dist/export-anchors.js +109 -0
- package/dist/export-evidence.d.ts +90 -0
- package/dist/export-evidence.js +186 -0
- package/dist/export-pages.d.ts +476 -0
- package/dist/export-pages.js +586 -0
- package/dist/failures.d.ts +44 -26
- package/dist/failures.js +81 -31
- package/dist/federation-wire.d.ts +106 -20
- package/dist/federation-wire.js +286 -76
- package/dist/history-seal.d.ts +100 -0
- package/dist/history-seal.js +301 -0
- package/dist/index.d.ts +37 -9
- package/dist/index.js +18 -5
- package/dist/instant.d.ts +1 -1
- package/dist/instant.js +1 -1
- package/dist/key-statements.d.ts +160 -11
- package/dist/key-statements.js +261 -60
- package/dist/ml-dsa-kats.d.ts +18 -0
- package/dist/ml-dsa-kats.js +241 -0
- package/dist/options.js +4 -4
- package/dist/primitives.d.ts +287 -47
- package/dist/primitives.js +673 -101
- package/dist/read-log.d.ts +350 -0
- package/dist/read-log.js +816 -0
- package/dist/schema-chain-export.d.ts +82 -0
- package/dist/schema-chain-export.js +474 -0
- package/dist/walk-anchors.d.ts +115 -0
- package/dist/walk-anchors.js +133 -0
- package/dist/walk-checkpoints.d.ts +125 -0
- package/dist/walk-checkpoints.js +118 -0
- package/package.json +9 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Acknowledgements of lost history a caller gives beside an artifact that
|
|
3
|
+
* does not carry them: an org admin's export walk leaves out the
|
|
4
|
+
* platform-ops chain whose RESTORE_EPOCH entries they are, so a genuine
|
|
5
|
+
* acknowledged rewind would read as a cut there.
|
|
6
|
+
*
|
|
7
|
+
* Each acknowledgement is a platform-ops RESTORE_EPOCH entry, verified from
|
|
8
|
+
* its own signed envelope as an export's `checkpointEvidence.acknowledgedRewinds`
|
|
9
|
+
* are (`verifyRewindAcknowledgements`): only its signed `coveredFindings`
|
|
10
|
+
* are read, and its link in the platform-ops chain is established only by a
|
|
11
|
+
* dump of that chain.
|
|
12
|
+
*/
|
|
13
|
+
import type { AcknowledgedRewindInput } from './anchors.js';
|
|
14
|
+
/**
|
|
15
|
+
* Where acknowledgements can be read from, each a parsed JSON document:
|
|
16
|
+
* - a record export (`GET /v1/records/{id}/audit-export`), read at
|
|
17
|
+
* `exportMetadata.checkpointEvidence.acknowledgedRewinds`;
|
|
18
|
+
* - a page of a walk of `GET /v1/audit-vault/export` under a platform key,
|
|
19
|
+
* read as the RESTORE_EPOCH rows of its platform-ops chain;
|
|
20
|
+
* - an array of `acknowledgedRewinds` items, or one item, or an object
|
|
21
|
+
* carrying `acknowledgedRewinds`.
|
|
22
|
+
*/
|
|
23
|
+
export type AcknowledgementSource = unknown;
|
|
24
|
+
/**
|
|
25
|
+
* The acknowledgement items the sources hold, each once (by entryId), with
|
|
26
|
+
* where each came from. Throws `TypeError` on a source that is none of the
|
|
27
|
+
* forms {@link AcknowledgementSource} lists, naming why.
|
|
28
|
+
*/
|
|
29
|
+
export declare function readAcknowledgementSources(fn: string, sources: unknown): Array<{
|
|
30
|
+
item: AcknowledgedRewindInput;
|
|
31
|
+
source: string;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PLATFORM_OPS_CHAIN_KEY } from './history-seal.js';
|
|
2
|
+
function isRecord(value) {
|
|
3
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
4
|
+
}
|
|
5
|
+
function isItem(value) {
|
|
6
|
+
return isRecord(value) && typeof value['coseSign1'] === 'string' && 'chainPosition' in value && 'entryId' in value;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The acknowledgement items the sources hold, each once (by entryId), with
|
|
10
|
+
* where each came from. Throws `TypeError` on a source that is none of the
|
|
11
|
+
* forms {@link AcknowledgementSource} lists, naming why.
|
|
12
|
+
*/
|
|
13
|
+
export function readAcknowledgementSources(fn, sources) {
|
|
14
|
+
if (sources === undefined)
|
|
15
|
+
return [];
|
|
16
|
+
if (!Array.isArray(sources))
|
|
17
|
+
throw new TypeError(`${fn}: acknowledgements must be an array of sources (record exports, bulk export pages, or acknowledgedRewinds items).`);
|
|
18
|
+
const out = [];
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const add = (item, source) => {
|
|
21
|
+
const id = typeof item.entryId === 'string' ? item.entryId.toLowerCase() : null;
|
|
22
|
+
if (id !== null) {
|
|
23
|
+
if (seen.has(id))
|
|
24
|
+
return;
|
|
25
|
+
seen.add(id);
|
|
26
|
+
}
|
|
27
|
+
out.push({ item, source });
|
|
28
|
+
};
|
|
29
|
+
sources.forEach((src, i) => {
|
|
30
|
+
const where = `acknowledgements[${i}]`;
|
|
31
|
+
if (Array.isArray(src)) {
|
|
32
|
+
src.forEach((item, j) => {
|
|
33
|
+
if (!isItem(item))
|
|
34
|
+
throw new TypeError(`${fn}: ${where}[${j}] is not an acknowledgedRewinds item { entryId, chainPosition, createdAt, signingKeyId, coseSign1 }.`);
|
|
35
|
+
add(item, `${where}[${j}]`);
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!isRecord(src))
|
|
40
|
+
throw new TypeError(`${fn}: ${where} is not a JSON object or array.`);
|
|
41
|
+
if (isItem(src)) {
|
|
42
|
+
add(src, where);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if ('blocked' in src && 'openFindings' in src) {
|
|
46
|
+
throw new TypeError(`${fn}: ${where} is a GET /v1/admin/vault/rewind response, which reports the rewind state and carries no signed RESTORE_EPOCH entry. Give a record export whose checkpointEvidence lists the acknowledgement (GET /v1/records/{id}/audit-export, for a record the rewind covers), or the pages of a bulk export walk under a platform key, which hold the platform-ops chain.`);
|
|
47
|
+
}
|
|
48
|
+
if (isRecord(src['exportMetadata']) && Array.isArray(src['entries'])) {
|
|
49
|
+
const evidence = src['exportMetadata']['checkpointEvidence'];
|
|
50
|
+
const list = isRecord(evidence) ? evidence['acknowledgedRewinds'] : undefined;
|
|
51
|
+
if (list === undefined || list === null)
|
|
52
|
+
return;
|
|
53
|
+
if (!Array.isArray(list))
|
|
54
|
+
throw new TypeError(`${fn}: ${where}.exportMetadata.checkpointEvidence.acknowledgedRewinds is not an array.`);
|
|
55
|
+
list.forEach((item, j) => {
|
|
56
|
+
if (!isItem(item))
|
|
57
|
+
throw new TypeError(`${fn}: ${where}.exportMetadata.checkpointEvidence.acknowledgedRewinds[${j}] is not an acknowledgedRewinds item.`);
|
|
58
|
+
add(item, `${where} acknowledgedRewinds[${j}]`);
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (Array.isArray(src['data']) && isRecord(src['chainMetadata'])) {
|
|
63
|
+
src['data'].forEach((row, j) => {
|
|
64
|
+
if (!isRecord(row) || row['entryType'] !== 'RESTORE_EPOCH' || row['recordId'] !== PLATFORM_OPS_CHAIN_KEY)
|
|
65
|
+
return;
|
|
66
|
+
add({
|
|
67
|
+
entryId: row['id'],
|
|
68
|
+
chainPosition: row['chainPosition'],
|
|
69
|
+
createdAt: row['createdAt'],
|
|
70
|
+
signingKeyId: (row['signingKeyId'] ?? null),
|
|
71
|
+
coseSign1: row['coseSign1'],
|
|
72
|
+
coveredRanges: [],
|
|
73
|
+
}, `${where} data[${j}]`);
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(src['acknowledgedRewinds'])) {
|
|
78
|
+
src['acknowledgedRewinds'].forEach((item, j) => {
|
|
79
|
+
if (!isItem(item))
|
|
80
|
+
throw new TypeError(`${fn}: ${where}.acknowledgedRewinds[${j}] is not an acknowledgedRewinds item.`);
|
|
81
|
+
add(item, `${where} acknowledgedRewinds[${j}]`);
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
throw new TypeError(`${fn}: ${where} is not a record export, a bulk export page, or acknowledgedRewinds items.`);
|
|
86
|
+
});
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holding a chain to the anchor bucket: the documents the Server writes under
|
|
3
|
+
* `vault-anchors/<instanceId>/<chainKey>/<chainPosition>.json`, one per
|
|
4
|
+
* checkpoint it anchors, and the acknowledgements of lost history (signed
|
|
5
|
+
* RESTORE_EPOCH entries on the platform-ops chain) that account for an anchor
|
|
6
|
+
* the chain no longer matches.
|
|
7
|
+
*
|
|
8
|
+
* Only the signed `coseSign1` inside a document is evidence. A document is
|
|
9
|
+
* kept when that envelope verifies as a vault checkpoint of the chain under a
|
|
10
|
+
* published key, at a signed `iat` inside the key's window; every other
|
|
11
|
+
* object is reported as not comparable and is evidence of nothing. A kept
|
|
12
|
+
* document at position P is compared with the chain: P above the last entry
|
|
13
|
+
* is a cut, a signed tip that is not the entry's payloadHash at P is a
|
|
14
|
+
* rewrite, and two kept documents at one position over different tips are a
|
|
15
|
+
* fork. Each is accounted for, and is lost history an operator declared, when
|
|
16
|
+
* an acknowledgement that verifies lists `{ recordId: chainKey, lo, hi }` in
|
|
17
|
+
* its signed `coveredFindings` with lo < P <= hi and lo at or below the last
|
|
18
|
+
* entry, and was signed after the anchor.
|
|
19
|
+
*/
|
|
20
|
+
import { type CheckApplicability, type KeyRegistry, type KeyWindowPlacement, type VerificationKey } from './chain.js';
|
|
21
|
+
import type { FailureCode } from './failures.js';
|
|
22
|
+
/** The `version` of the anchor documents a Server writes. Version 1 carried a raw signature and no COSE envelope, and no Server reads it. */
|
|
23
|
+
export declare const ANCHOR_DOCUMENT_VERSION = 2;
|
|
24
|
+
/** The in-toto `predicateType` of a vault checkpoint. */
|
|
25
|
+
export declare const VAULT_CHECKPOINT_PREDICATE_TYPE = "https://agledger.ai/predicates/vault-checkpoint/v1";
|
|
26
|
+
/**
|
|
27
|
+
* How far a signed `iat` may sit outside its key's window at each edge and
|
|
28
|
+
* still be inside it: the Server's allowance for clock skew between hosts.
|
|
29
|
+
*/
|
|
30
|
+
export declare const KEY_WINDOW_CLOCK_SKEW_SECONDS = 300;
|
|
31
|
+
/** One anchor document as read from the bucket or a copy of it. */
|
|
32
|
+
export interface AnchorDocumentInput {
|
|
33
|
+
/** Where it was read from (a file path or bucket key), named in every verdict. */
|
|
34
|
+
source: string;
|
|
35
|
+
/** The parsed JSON. Anything that is not an anchor document is reported as not comparable. */
|
|
36
|
+
document: unknown;
|
|
37
|
+
/**
|
|
38
|
+
* The bucket key it was stored under, when known
|
|
39
|
+
* (`vault-anchors/<instanceId>/<chainKey>/<chainPosition>.json`). The
|
|
40
|
+
* document's own instanceId, recordId and chainPosition must name it, as
|
|
41
|
+
* the Server requires of every object it reads under a key.
|
|
42
|
+
*/
|
|
43
|
+
objectKey?: string;
|
|
44
|
+
}
|
|
45
|
+
/** The chain an anchor is compared with. */
|
|
46
|
+
export interface AnchorChainView {
|
|
47
|
+
/** The uuid the checkpoints sign as subject: the record id, a schema chain's checkpoint key, or the platform-ops key. */
|
|
48
|
+
chainKey: string;
|
|
49
|
+
/** The entries held, by chain position; at least every position an anchor names that the chain holds. */
|
|
50
|
+
entries: ReadonlyArray<{
|
|
51
|
+
chainPosition: number;
|
|
52
|
+
payloadHash: unknown;
|
|
53
|
+
}>;
|
|
54
|
+
/** The last chain position held, or null when none is. */
|
|
55
|
+
lastEntryPosition: number | null;
|
|
56
|
+
/**
|
|
57
|
+
* The latest signed `iat` (whole seconds) an anchor may carry and be judged:
|
|
58
|
+
* an export's `anchorsJudgedThroughIat`, or a dump's read time less one
|
|
59
|
+
* second. Null when no read time is known: an anchor at or below the last
|
|
60
|
+
* entry is still judged (the entry at its position was read), and one above
|
|
61
|
+
* it is reported as not comparable.
|
|
62
|
+
*/
|
|
63
|
+
judgedThroughIat: number | null;
|
|
64
|
+
/**
|
|
65
|
+
* Whether `judgedThroughIat` comes from a read time the caller gave. A read
|
|
66
|
+
* time the artifact states about itself is unsigned, and moving it earlier
|
|
67
|
+
* would set aside an anchor that shows a cut, so an anchor above the last
|
|
68
|
+
* entry held that is set aside on the artifact's own read time (or with no
|
|
69
|
+
* read time at all) is listed in `capped`: the verdict reads at best
|
|
70
|
+
* `unanchored` until the caller gives the time it read the artifact.
|
|
71
|
+
*/
|
|
72
|
+
readTimeGiven?: boolean;
|
|
73
|
+
/** The checkpoint envelopes the artifact carries for this chain, so an anchor holding the same bytes reads `same_bytes`. */
|
|
74
|
+
checkpoints?: ReadonlyArray<{
|
|
75
|
+
chainPosition: number;
|
|
76
|
+
coseSign1Sha256: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Set when the artifact holds a run of the chain rather than the chain
|
|
80
|
+
* from its first entry to its tip, as a page walk can. An anchor below
|
|
81
|
+
* `firstHeld` or above `lastHeld` (each set only when that end of the run
|
|
82
|
+
* is not the chain's own) is judged at no position and reads
|
|
83
|
+
* `chain_held_in_part`, with `reason` saying why the run ends there. Two
|
|
84
|
+
* anchors of one position over different tips are still a fork.
|
|
85
|
+
*/
|
|
86
|
+
heldInPart?: {
|
|
87
|
+
firstHeld?: number;
|
|
88
|
+
lastHeld?: number;
|
|
89
|
+
reason: string;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** One `{ recordId, lo, hi, finding }` an acknowledgement signs. */
|
|
93
|
+
export interface CoveredFinding {
|
|
94
|
+
recordId: string;
|
|
95
|
+
lo: number;
|
|
96
|
+
hi: number;
|
|
97
|
+
finding: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* A RESTORE_EPOCH acknowledgement of lost history, read from its signed
|
|
101
|
+
* envelope. `verified`: its signature verified under an anchored key inside
|
|
102
|
+
* that key's window. `uncomputable`: this host refused the check, so it
|
|
103
|
+
* accounts for nothing here and a cut it would cover is could-not-compute.
|
|
104
|
+
*/
|
|
105
|
+
export interface RewindAcknowledgement {
|
|
106
|
+
entryId: string | null;
|
|
107
|
+
/** Its position on the platform-ops chain. */
|
|
108
|
+
chainPosition: number;
|
|
109
|
+
state: 'verified' | 'uncomputable';
|
|
110
|
+
/** The signed `iat`, whole seconds. */
|
|
111
|
+
iat: number;
|
|
112
|
+
/** The signed `predicate.payload.coveredFindings`. */
|
|
113
|
+
coveredFindings: readonly CoveredFinding[];
|
|
114
|
+
/** Whether its link in the platform-ops chain was checked (a dump of that chain), or only its own envelope (an export). */
|
|
115
|
+
linkChecked: boolean;
|
|
116
|
+
}
|
|
117
|
+
/** The disagreements an anchor can show. */
|
|
118
|
+
export type AnchorDisagreementCode = 'ANCHOR_CHAIN_CUT' | 'ANCHOR_CHAIN_REWRITTEN' | 'ANCHOR_FORK';
|
|
119
|
+
/**
|
|
120
|
+
* Why a document was not compared.
|
|
121
|
+
* - `not_an_anchor_document`: not the shape the Server writes.
|
|
122
|
+
* - `unsupported_document_version`: a version other than 2 (version 1 carried no COSE envelope).
|
|
123
|
+
* - `scitt_head_document`: a SCITT tree-head anchor, which commits to an org's SCITT log, not to a chain.
|
|
124
|
+
* - `key_mismatch`: its instanceId, recordId or chainPosition do not name the key it was stored under.
|
|
125
|
+
* - `not_a_checkpoint`: its envelope does not decode as a vault checkpoint whose count, range and position agree.
|
|
126
|
+
* - `other_chain`: a checkpoint of another chain.
|
|
127
|
+
* - `unsigned_checkpoint`: the envelope carries the unsigned kid; anyone who can read the tip can make one.
|
|
128
|
+
* - `key_unknown`: its kid names no published key.
|
|
129
|
+
* - `key_unanchored`: its key is not linked to a trust anchor.
|
|
130
|
+
* - `key_distrusted`: signed by a key a distrusted-key entry sets aside at its signed iat.
|
|
131
|
+
* - `signature_invalid`: its signature does not verify.
|
|
132
|
+
* - `unsupported_algorithm`: this host refused to compute its signature; `ifVerified` says what it would show.
|
|
133
|
+
* - `outside_key_window`: its signed iat is outside its key's window.
|
|
134
|
+
* - `signed_after_read`: signed after the read time, so it may cover entries written since.
|
|
135
|
+
* - `no_read_time`: above the last entry, and no read time is known to tell a cut from growth.
|
|
136
|
+
* - `chain_not_held`: a checkpoint of a chain the artifact does not hold (an org-scoped dump).
|
|
137
|
+
* - `chain_held_in_part`: a checkpoint of a position outside the run of the chain the artifact holds (a page walk that holds the chain in part).
|
|
138
|
+
*/
|
|
139
|
+
export type AnchorNotComparableReason = 'not_an_anchor_document' | 'unsupported_document_version' | 'scitt_head_document' | 'key_mismatch' | 'not_a_checkpoint' | 'other_chain' | 'unsigned_checkpoint' | 'key_unknown' | 'key_unanchored' | 'key_distrusted' | 'signature_invalid' | 'unsupported_algorithm' | 'outside_key_window' | 'signed_after_read' | 'no_read_time' | 'chain_not_held' | 'chain_held_in_part';
|
|
140
|
+
interface AnchorVerdictBase {
|
|
141
|
+
source: string;
|
|
142
|
+
objectKey?: string;
|
|
143
|
+
/** The position the document's signed claim names, or null when none could be read. */
|
|
144
|
+
position: number | null;
|
|
145
|
+
/** The signed `iat`, or null when none could be read. */
|
|
146
|
+
iat: number | null;
|
|
147
|
+
/** The signed kid, or null when none could be read. */
|
|
148
|
+
keyId: string | null;
|
|
149
|
+
detail: string;
|
|
150
|
+
/**
|
|
151
|
+
* The document's unsigned fields (recordId, chainPosition, payloadHash,
|
|
152
|
+
* signingKeyId) that say something other than its signed claim. The signed
|
|
153
|
+
* claim is what was compared; these are listed, never judged.
|
|
154
|
+
*/
|
|
155
|
+
unsignedDisagreements: string[];
|
|
156
|
+
}
|
|
157
|
+
/** What one anchor document showed against the chain. */
|
|
158
|
+
export type AnchorVerdict = (AnchorVerdictBase & {
|
|
159
|
+
kind: 'agree';
|
|
160
|
+
how: 'same_bytes' | 'same_tip';
|
|
161
|
+
}) | (AnchorVerdictBase & {
|
|
162
|
+
kind: 'disagree';
|
|
163
|
+
code: AnchorDisagreementCode;
|
|
164
|
+
/** An acknowledgement that would account for it, whose signature this host refused to compute. */
|
|
165
|
+
acknowledgementUncomputable?: {
|
|
166
|
+
entryId: string | null;
|
|
167
|
+
chainPosition: number;
|
|
168
|
+
};
|
|
169
|
+
}) | (AnchorVerdictBase & {
|
|
170
|
+
kind: 'accounted';
|
|
171
|
+
code: AnchorDisagreementCode;
|
|
172
|
+
acknowledgement: {
|
|
173
|
+
entryId: string | null;
|
|
174
|
+
chainPosition: number;
|
|
175
|
+
linkChecked: boolean;
|
|
176
|
+
};
|
|
177
|
+
}) | (AnchorVerdictBase & {
|
|
178
|
+
kind: 'not_comparable';
|
|
179
|
+
reason: AnchorNotComparableReason;
|
|
180
|
+
ifVerified?: 'agree' | AnchorDisagreementCode;
|
|
181
|
+
});
|
|
182
|
+
/** A failure the comparison puts on the result. */
|
|
183
|
+
export interface AnchorFinding {
|
|
184
|
+
position: number;
|
|
185
|
+
code: FailureCode;
|
|
186
|
+
detail: string;
|
|
187
|
+
}
|
|
188
|
+
/** What {@link compareCheckpointAnchors} found. */
|
|
189
|
+
export interface AnchorComparison {
|
|
190
|
+
/** `skipped_no_input` with no documents, `applied` once one was compared, `not_checked` when none could be. */
|
|
191
|
+
applicability: CheckApplicability;
|
|
192
|
+
chainKey: string;
|
|
193
|
+
judgedThroughIat: number | null;
|
|
194
|
+
verdicts: AnchorVerdict[];
|
|
195
|
+
counts: {
|
|
196
|
+
agree: number;
|
|
197
|
+
disagree: number;
|
|
198
|
+
accounted: number;
|
|
199
|
+
notComparable: number;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* The failures: each unaccounted disagreement (ANCHOR_CHAIN_CUT,
|
|
203
|
+
* ANCHOR_CHAIN_REWRITTEN, ANCHOR_FORK), and CHAIN_UNSUPPORTED_ALGORITHM for
|
|
204
|
+
* each anchor or acknowledgement this host could not compute that the
|
|
205
|
+
* comparison needed.
|
|
206
|
+
*/
|
|
207
|
+
findings: AnchorFinding[];
|
|
208
|
+
/**
|
|
209
|
+
* One sentence for each anchor whose checkpoint verifies, signs a position
|
|
210
|
+
* above the last entry held, and was set aside on no read time or on a read
|
|
211
|
+
* time the caller did not give (`AnchorChainView.readTimeGiven`). Such an
|
|
212
|
+
* anchor is either growth after the read or a cut, and only the caller's
|
|
213
|
+
* read time tells which, so a result with any reads at best `unanchored`.
|
|
214
|
+
*/
|
|
215
|
+
capped: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Place an envelope in its key's window by its signed `iat` (whole seconds),
|
|
219
|
+
* allowing {@link KEY_WINDOW_CLOCK_SKEW_SECONDS} at the activation and
|
|
220
|
+
* retirement edges as the Server's offline procedure does. A distrust cutoff
|
|
221
|
+
* is held without the allowance: what a distrusted key signed at or after it
|
|
222
|
+
* counts for nothing.
|
|
223
|
+
*/
|
|
224
|
+
export declare function placeSignedIat(key: VerificationKey, iat: number, what: string): KeyWindowPlacement;
|
|
225
|
+
/**
|
|
226
|
+
* The chain key an anchor document's checkpoint signs (`cwt.sub`, lowercase),
|
|
227
|
+
* or null when the document is not a version 2 anchor document whose envelope
|
|
228
|
+
* decodes as a vault checkpoint. For sorting documents by chain before
|
|
229
|
+
* {@link compareCheckpointAnchors}, which holds each to its chain's subject
|
|
230
|
+
* digest.
|
|
231
|
+
*/
|
|
232
|
+
export declare function anchorDocumentChainKey(input: AnchorDocumentInput): string | null;
|
|
233
|
+
/** The signed `iat` of an anchor document's checkpoint, or null when it does not read. */
|
|
234
|
+
export declare function anchorDocumentIat(input: AnchorDocumentInput): number | null;
|
|
235
|
+
/**
|
|
236
|
+
* The verdict on a document {@link readDocument} could not read, for a
|
|
237
|
+
* caller sorting documents by chain before the comparison.
|
|
238
|
+
*/
|
|
239
|
+
export declare function unreadableAnchorVerdict(input: AnchorDocumentInput): AnchorVerdict | null;
|
|
240
|
+
/**
|
|
241
|
+
* Compare anchor documents with one chain.
|
|
242
|
+
*
|
|
243
|
+
* Every document gets one verdict: `agree`, `disagree` (with its code),
|
|
244
|
+
* `accounted` (a disagreement an acknowledgement that verifies covers) or
|
|
245
|
+
* `not_comparable` (with the reason). `findings` carries each unaccounted
|
|
246
|
+
* disagreement, at most one per position and code, every ANCHOR_FORK before
|
|
247
|
+
* any ANCHOR_CHAIN_CUT or ANCHOR_CHAIN_REWRITTEN (the failure order the
|
|
248
|
+
* conformance corpus states: an acknowledgement that does not verify, which
|
|
249
|
+
* the caller reports first, then a fork, then a cut or a rewrite), and a
|
|
250
|
+
* CHAIN_UNSUPPORTED_ALGORITHM for each anchor this host refused to compute
|
|
251
|
+
* and each disagreement only an acknowledgement this host refused would
|
|
252
|
+
* account for. A refused anchor is never evidence either way: in a run that
|
|
253
|
+
* assumes the host's refusals verified (`verifyAsIfHostComputed`) it is left
|
|
254
|
+
* out rather than assumed, so a disagreement it would show never fails a
|
|
255
|
+
* verdict, and an agreement never passes one.
|
|
256
|
+
*
|
|
257
|
+
* `keys` is the registry the artifact's entries are verified under, after the
|
|
258
|
+
* trust walk. `acknowledgements` are the ones already judged
|
|
259
|
+
* (`verifyRewindAcknowledgements` for an export, the platform-ops chain's
|
|
260
|
+
* RESTORE_EPOCH entries for a dump).
|
|
261
|
+
*/
|
|
262
|
+
export declare function compareCheckpointAnchors(documents: readonly AnchorDocumentInput[], chain: AnchorChainView, keys: KeyRegistry, acknowledgements?: readonly RewindAcknowledgement[]): AnchorComparison;
|
|
263
|
+
/**
|
|
264
|
+
* The acknowledgement a RESTORE_EPOCH envelope signs, read from the signed
|
|
265
|
+
* bytes alone: null when it is not a platform-ops RESTORE_EPOCH whose signed
|
|
266
|
+
* payload carries `coveredFindings` (a restore marker carries none). Its
|
|
267
|
+
* signature and link are the caller's to have checked; `state` and
|
|
268
|
+
* `linkChecked` say what the caller established.
|
|
269
|
+
*/
|
|
270
|
+
export declare function rewindAcknowledgementOf(coseSign1: Uint8Array, entryId: string | null, state: RewindAcknowledgement['state'], linkChecked: boolean): RewindAcknowledgement | null;
|
|
271
|
+
/** One `checkpointEvidence.acknowledgedRewinds` item (Server 4.0.0 and later). */
|
|
272
|
+
export interface AcknowledgedRewindInput {
|
|
273
|
+
entryId: string;
|
|
274
|
+
/** Its position on the platform-ops chain. */
|
|
275
|
+
chainPosition: number;
|
|
276
|
+
createdAt: string;
|
|
277
|
+
signingKeyId: string | null;
|
|
278
|
+
/** Base64 COSE_Sign1 of the RESTORE_EPOCH entry. */
|
|
279
|
+
coseSign1: string;
|
|
280
|
+
/** The row's unsigned copy of the signed findings naming this chain. */
|
|
281
|
+
coveredRanges: Array<{
|
|
282
|
+
lo: number;
|
|
283
|
+
hi: number;
|
|
284
|
+
finding: string;
|
|
285
|
+
}>;
|
|
286
|
+
}
|
|
287
|
+
/** What one listed acknowledgement showed. */
|
|
288
|
+
export interface AcknowledgementVerdict {
|
|
289
|
+
entryId: string | null;
|
|
290
|
+
chainPosition: number | null;
|
|
291
|
+
/**
|
|
292
|
+
* `verified`: signed under an anchored key inside its window at its signed
|
|
293
|
+
* iat, and its row and unsigned copy agree with the envelope. `accounted`:
|
|
294
|
+
* signed by a key a distrusted-key entry sets aside, so it covers nothing.
|
|
295
|
+
* `unsigned`: written before the install began signing; it covers nothing.
|
|
296
|
+
* `uncomputable`: this host refused to compute its signature. `failed`:
|
|
297
|
+
* see the finding.
|
|
298
|
+
*/
|
|
299
|
+
state: 'verified' | 'accounted' | 'unsigned' | 'uncomputable' | 'failed';
|
|
300
|
+
/** The signed findings naming this chain, when the envelope could be read. */
|
|
301
|
+
coveredFindings: CoveredFinding[];
|
|
302
|
+
detail: string;
|
|
303
|
+
}
|
|
304
|
+
/** What the export's acknowledgements showed. */
|
|
305
|
+
export interface AcknowledgementReport {
|
|
306
|
+
applicability: CheckApplicability;
|
|
307
|
+
present: number;
|
|
308
|
+
verified: number;
|
|
309
|
+
items: AcknowledgementVerdict[];
|
|
310
|
+
/**
|
|
311
|
+
* Always false on an export: each envelope is verified on its own, and its
|
|
312
|
+
* link in the platform-ops chain (its previousHash the payloadHash before
|
|
313
|
+
* it) is established only by a dump of that chain.
|
|
314
|
+
*/
|
|
315
|
+
linkChecked: false;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Hold a bulk export page's `acknowledgedRewinds` item to its envelope, as a
|
|
319
|
+
* record export's is: the Server writes its unsigned `coveredRanges` as the
|
|
320
|
+
* signed `coveredFindings` that name a chain the page holds rows of, each
|
|
321
|
+
* with its `recordId`, in signed order. The reason they differ, or null when
|
|
322
|
+
* they agree or the envelope does not decode (which the acknowledgement's
|
|
323
|
+
* own verification reports).
|
|
324
|
+
*/
|
|
325
|
+
export declare function pageAcknowledgementCopyDisagreement(item: unknown, pageChainKeys: ReadonlySet<string>): string | null;
|
|
326
|
+
/**
|
|
327
|
+
* Verify the acknowledgements of lost history an export lists for its chain:
|
|
328
|
+
* each envelope decodes as a platform-ops RESTORE_EPOCH at the position its
|
|
329
|
+
* row names, under the kid its row names, verifies under an anchored key
|
|
330
|
+
* inside that key's window at its signed `iat`, and its row's unsigned
|
|
331
|
+
* `coveredRanges` are its signed `coveredFindings` for this chain. A failure
|
|
332
|
+
* is REWIND_ACKNOWLEDGEMENT_INVALID (CHAIN_SIGNATURE_MISSING_KEY for a kid no
|
|
333
|
+
* key answers to), and the acknowledgement then covers nothing. One this host
|
|
334
|
+
* refused to compute is CHAIN_UNSUPPORTED_ALGORITHM and covers nothing here.
|
|
335
|
+
*/
|
|
336
|
+
export declare function verifyRewindAcknowledgements(items: unknown, chainKey: string, keys: KeyRegistry, signingSince: string | null, supplied?: boolean): {
|
|
337
|
+
report: AcknowledgementReport;
|
|
338
|
+
acknowledgements: RewindAcknowledgement[];
|
|
339
|
+
findings: AnchorFinding[];
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* The relative path of a file in a copy of the anchor bucket, as the key it
|
|
343
|
+
* was stored under: a path ending `vault-anchors/<instanceId>/<chainKey>/<P>.json`
|
|
344
|
+
* keeps that tail, and one that is exactly `<instanceId>/<chainKey>/<P>.json`
|
|
345
|
+
* (a copy of the `vault-anchors/` prefix) gains the prefix. Undefined for any
|
|
346
|
+
* other path, which names no key.
|
|
347
|
+
*/
|
|
348
|
+
export declare function anchorObjectKeyOfPath(relativePath: string): string | undefined;
|
|
349
|
+
export {};
|