@agledger/verify-core 1.4.2 → 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/LICENSE +10 -14
- package/README.md +316 -12
- package/dist/audit-export.d.ts +150 -37
- package/dist/audit-export.js +204 -39
- package/dist/chain.d.ts +262 -22
- package/dist/chain.js +369 -60
- package/dist/failures.d.ts +47 -2
- package/dist/failures.js +67 -6
- package/dist/index.d.ts +9 -5
- package/dist/index.js +5 -2
- package/dist/instant.d.ts +23 -0
- package/dist/instant.js +50 -0
- package/dist/key-statements.d.ts +429 -0
- package/dist/key-statements.js +1325 -0
- package/dist/options.d.ts +7 -0
- package/dist/options.js +29 -0
- package/dist/primitives.d.ts +133 -6
- package/dist/primitives.js +255 -43
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -17,16 +17,13 @@ Licensor grants you a limited, non-exclusive, non-transferable, revocable
|
|
|
17
17
|
license to install and use the Software solely for the purpose of integrating
|
|
18
18
|
with a self-hosted AGLedger deployment operated by you or your organization, or
|
|
19
19
|
by a third party on your behalf with your authorization. The Software is not
|
|
20
|
-
|
|
21
|
-
AGLedger operates the AGLedger software on a self-hosted model; there is no
|
|
22
|
-
hosted AGLedger API.
|
|
20
|
+
licensed for use with any AGLedger-hosted service.
|
|
23
21
|
|
|
24
|
-
AGLedger LLC
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
LLC receives no usage data or other data from your self-hosted deployment.
|
|
22
|
+
AGLedger LLC does not receive, access, inspect, or judge the data you process
|
|
23
|
+
through your self-hosted deployment, and does not use any such data to train,
|
|
24
|
+
fine-tune, evaluate, or benchmark any machine-learning or artificial-
|
|
25
|
+
intelligence model, or to develop any product or service. AGLedger LLC does not
|
|
26
|
+
collect product usage information from your self-hosted deployment.
|
|
30
27
|
|
|
31
28
|
2. RESTRICTIONS
|
|
32
29
|
|
|
@@ -103,14 +100,13 @@ or trade-control laws.
|
|
|
103
100
|
|
|
104
101
|
7. TRADEMARKS
|
|
105
102
|
|
|
106
|
-
AGLedger
|
|
107
|
-
|
|
108
|
-
respective owners.
|
|
103
|
+
AGLedger and Settlement Signal are trademarks of AGLedger LLC. All other
|
|
104
|
+
trademarks are the property of their respective owners.
|
|
109
105
|
|
|
110
106
|
8. PATENTS
|
|
111
107
|
|
|
112
|
-
The Software is covered by one or more U.S.
|
|
113
|
-
|
|
108
|
+
The Software is covered by one or more issued or pending U.S. patents in
|
|
109
|
+
AGLedger LLC's patent portfolio.
|
|
114
110
|
|
|
115
111
|
9. RELATIONSHIP TO OTHER AGLEDGER AGREEMENTS
|
|
116
112
|
|
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
|
-
|
|
39
|
-
|
|
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 (
|
|
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
|
-
//
|
|
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.
|
|
@@ -57,6 +64,285 @@ if (!result.valid) {
|
|
|
57
64
|
- **Envelope signature**: over the reconstructed `Sig_structure`, against the
|
|
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`).
|
|
67
|
+
- **Signed-kid binding**: the row's `signingKeyId` names the key the protected
|
|
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.
|
|
79
|
+
- **Payload binding**: each entry's human-readable `payload` still matches the
|
|
80
|
+
predicate inside the signed bytes, so a rewritten view of the record fails
|
|
81
|
+
`CHAIN_PAYLOAD_BINDING_MISMATCH`.
|
|
82
|
+
- **OIDC actor**: the row's `actorOidcIss` / `actorOidcSub` match the identity
|
|
83
|
+
signed in `predicate.on_behalf_of`.
|
|
84
|
+
- **Actor attribution**: the row's `actorId`, `actorRole` and `actorOwnerId`,
|
|
85
|
+
the attribution an export's own guide tells an auditor to rely on, match the
|
|
86
|
+
actor claim signed in the protected header, so an export re-attributed to
|
|
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).
|
|
91
|
+
- **Key validity windows**: each entry was written inside its signing key's
|
|
92
|
+
activation window. With `trustAnchors`, the window is the one the key
|
|
93
|
+
statements sign.
|
|
94
|
+
- **Agent signatures**, when you supply the agent's cert key (below).
|
|
95
|
+
|
|
96
|
+
The payload, OIDC, attribution and key-window checks run when the export
|
|
97
|
+
carries their inputs, which every current Server does. The result's `optionalChecks` says
|
|
98
|
+
which ran, so "not checked" never reads as "passed".
|
|
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
|
+
|
|
309
|
+
## Agent signatures
|
|
310
|
+
|
|
311
|
+
An agent that authenticates with an ephemeral cert can sign each request body
|
|
312
|
+
it sends. The Server checks that signature, then seals it into the chain entry
|
|
313
|
+
as `predicate.on_behalf_of.agent_signature`, beside the RFC 7638 thumbprint of
|
|
314
|
+
the cert's public key. The envelope signature proves the Server wrote that. To
|
|
315
|
+
prove the agent itself signed, without taking the Server's word for it,
|
|
316
|
+
re-verify the agent signature against the cert's public key.
|
|
317
|
+
|
|
318
|
+
The export does not carry cert public keys. Supply them as the Ed25519 JWK the
|
|
319
|
+
agent sent to `POST /v1/auth/oidc/cert` (the same key is the `cnf.jwk` claim
|
|
320
|
+
inside the `certJws` it got back):
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
import { verifyAuditExport } from '@agledger/verify-core';
|
|
324
|
+
|
|
325
|
+
const agentKey = { kty: 'OKP', crv: 'Ed25519', x: 'BKOgK3KibE8BZH8SXTX9dmAXcwgocTMHIv-R_eRB2lo' } as const;
|
|
326
|
+
const result = verifyAuditExport(exportDocument, { agentKeys: [agentKey] });
|
|
327
|
+
|
|
328
|
+
console.log(result.optionalChecks.agent_signature); // 'applied'
|
|
329
|
+
console.log(result.agentSignatures); // e.g. { present: 6, verified: 6 }
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
A key is matched to an entry only through the thumbprint that entry signed, so
|
|
333
|
+
a key for some other cert is never checked against it and where the key came
|
|
334
|
+
from needs no trust. `present` counts entries carrying an agent signature and
|
|
335
|
+
`verified` those re-checked and found good; `present > verified` on a valid
|
|
336
|
+
result means some were not checked, never that they failed. One that does not
|
|
337
|
+
verify fails `CHAIN_AGENT_SIGNATURE_INVALID`. The check runs only where
|
|
338
|
+
`on_behalf_of.validated` is `true`: on a caller-asserted identity the two fields
|
|
339
|
+
may be passthrough from an older Server, and the export cannot tell which.
|
|
340
|
+
|
|
341
|
+
The Server's own chain verification also compares each sealed cert against its
|
|
342
|
+
live cert record (`cert_missing`, `cert_actor_drift`, `cert_window_drift`,
|
|
343
|
+
`cert_expired`). That record is not exported, so those checks have no offline
|
|
344
|
+
counterpart; the signed bytes already fix the cert id, thumbprint and expiry an
|
|
345
|
+
entry sealed.
|
|
60
346
|
|
|
61
347
|
## Verifying on a FIPS-locked host
|
|
62
348
|
|
|
@@ -99,19 +385,35 @@ console.log(describeUnsupportedAlgorithm(spkiBase64));
|
|
|
99
385
|
that refuses to *load* a key of some algorithm produces no key object to
|
|
100
386
|
resolve, which is exactly when the question matters most.
|
|
101
387
|
|
|
102
|
-
##
|
|
388
|
+
## Supplied keys
|
|
103
389
|
|
|
104
|
-
`options.publicKeys` accepts
|
|
390
|
+
`options.publicKeys` accepts these shapes:
|
|
105
391
|
|
|
106
392
|
- a **`Record<keyId, base64SpkiDer>`** map (compact, keyed by key id), or
|
|
107
|
-
-
|
|
393
|
+
- a **`SuppliedKeyEntry[]`** array, the natural shape returned by
|
|
108
394
|
`client.verificationKeys.list().data` and SCITT COSE_KeySet listings, where
|
|
109
|
-
each entry is `{ keyId, publicKey, activatedAt?, retiredAt? }`
|
|
110
|
-
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`.
|
|
111
398
|
|
|
112
399
|
Both are normalized at the boundary; anything else throws `TypeError`
|
|
113
400
|
(fail-closed: the verifier never silently falls back to embedded keys).
|
|
114
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
|
+
|
|
115
417
|
## Canonical failure taxonomy
|
|
116
418
|
|
|
117
419
|
Every failure is a canonical SCREAMING_SNAKE `FailureCode`. Importing the
|
|
@@ -121,9 +423,11 @@ chain was checked by the SDK, the CLI, the MCP tool, or `@agledger/verify`.
|
|
|
121
423
|
|
|
122
424
|
## Key provenance
|
|
123
425
|
|
|
124
|
-
The result distinguishes keys supplied
|
|
125
|
-
|
|
126
|
-
|
|
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.
|
|
127
431
|
|
|
128
432
|
## License
|
|
129
433
|
|