@charter-agreement-protocol/verifier 0.5.0 → 0.7.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/CHANGELOG.md +261 -0
- package/README.md +100 -11
- package/SECURITY.md +89 -0
- package/conformance/cases/acceptance-equivocation.json +1 -1
- package/conformance/cases/acceptance-verify.json +1 -1
- package/conformance/cases/base64url-decode.json +1 -1
- package/conformance/cases/canonicalization-encode.json +1 -1
- package/conformance/cases/chain-verify.json +1 -1
- package/conformance/cases/chain-verify_profile.json +1 -1
- package/conformance/cases/charter_revision-decode.json +1 -1
- package/conformance/cases/descriptor_chain-verify.json +1 -1
- package/conformance/cases/digest-hash.json +1 -1
- package/conformance/cases/governing_revision.json +1 -1
- package/conformance/cases/json-decode.json +1 -1
- package/conformance/cases/party_descriptor-verify.json +1 -1
- package/conformance/cases/receipt-verify.json +1 -1
- package/conformance/cases/schema-validate.json +1 -1
- package/conformance/cases/signing-prepare.json +1 -0
- package/conformance/cases/termination-verify.json +1 -1
- package/conformance/index.json +1 -1
- package/dist/cli.js +1 -1
- package/dist/core.d.ts +75 -15
- package/dist/core.js +1734 -507
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,267 @@
|
|
|
3
3
|
All notable public changes to `@charter-agreement-protocol/verifier` are
|
|
4
4
|
documented here.
|
|
5
5
|
|
|
6
|
+
## [0.7.0] — 2026-10-14
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `prepareSigning`, `finishSigning`, `SigningPlan`, `SigningKind`, and
|
|
11
|
+
`SigningOptions` support checks before signing and retain the artifact's
|
|
12
|
+
verification context, limits, and profile
|
|
13
|
+
for completion. The plan exposes the signing input and whether its key is
|
|
14
|
+
`matched` or `unnamed` (a receipt against a bare revision).
|
|
15
|
+
Acceptance and termination profiles cover the revision, the signing party's
|
|
16
|
+
descriptor history, and the new artifact. The full profile checks the rest of
|
|
17
|
+
the set; caller limits cover every artifact read. Receipt profiles cover the
|
|
18
|
+
whole retained set; descriptor profiles cover predecessor history.
|
|
19
|
+
Plans can only be constructed through preparation. Context arrays are copied
|
|
20
|
+
before use, and completion accepts `Uint8Array` signatures from any realm.
|
|
21
|
+
Malformed contexts return `invalid_type`; cyclic signing claims return
|
|
22
|
+
`signing_input_invalid`.
|
|
23
|
+
- `signing_key_invalid` reports an invalid snapshot key encoding or shape.
|
|
24
|
+
`signing_key_mismatch` reports a snapshot that does not match an active candidate
|
|
25
|
+
in the holder's own view.
|
|
26
|
+
- The certified corpus now contains 541 cases in 16 case files, including
|
|
27
|
+
`signing.prepare`. Its runner calls public `prepareSigning`; tests cover
|
|
28
|
+
its 107 preparation cases, closed runner options, and both compiled class floors.
|
|
29
|
+
- `SECURITY.md` ships in the npm package with supported versions, scope,
|
|
30
|
+
reproduction commands and private reporting through GitHub's Security tab.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- `capabilities().verifiable` requires a declared key type, a passing known-answer
|
|
35
|
+
vector, and rejection of a tampered vector. Verification and preparation cache
|
|
36
|
+
that result once per key algorithm.
|
|
37
|
+
- `verifyDescriptor` returns `invalid_type` for a predecessor with missing, null,
|
|
38
|
+
empty, or non-string lineage, matching the reference.
|
|
39
|
+
- `verifyReceipt` returns `invalid_type` for a context such as `null`, `42`, `[]`,
|
|
40
|
+
or `["x"]`, instead of `chain_invalid`.
|
|
41
|
+
- `acceptanceSigningInput`, `terminationSigningInput`, `acceptanceRefusal`, and
|
|
42
|
+
`terminationRefusal` preserve `verifyChain`'s error for a bad set. For example, a
|
|
43
|
+
malformed descriptor now returns `compact_invalid` instead of `chain_invalid`.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Ed25519 public keys and signature `R` use the same point rule: canonical
|
|
48
|
+
`y`, a curve point, and not small order. Mixed order is accepted. Decoding
|
|
49
|
+
uses one modular exponentiation per point, with a faster fixed addition chain.
|
|
50
|
+
- The corpus runner checks limits first, then the profile, then operation inputs.
|
|
51
|
+
Malformed limits return `invalid_limits`; malformed profiles and revision bounds
|
|
52
|
+
return `invalid_profile`. A missing profile or axis uses the full profile or axis;
|
|
53
|
+
an empty profile uses both full axes. An explicit null profile or axis returns
|
|
54
|
+
`invalid_profile` on every surface. Malformed runner inputs return typed errors.
|
|
55
|
+
- JSON decoding checks limits validity, input type, byte size, then streaming
|
|
56
|
+
syntax and limits. It reads the syntax needed to start a container before
|
|
57
|
+
checking depth: `{` is `invalid_syntax` at depth zero, while `[bad` is
|
|
58
|
+
`limit_exceeded`. The runner rejects malformed base64url input before JSON decoding.
|
|
59
|
+
Byte input follows parser order too: `[` followed by an invalid UTF-8 byte
|
|
60
|
+
hits depth zero first, and an invalid byte after `[1]` is `trailing_bytes`.
|
|
61
|
+
- Revision projections return a null binding when the binding list is empty.
|
|
62
|
+
Governing queries and predecessor histories retain errors from context reads.
|
|
63
|
+
- Receipt verification and signing preparation apply the caller's limits to
|
|
64
|
+
the retained chain context. The receipt corpus runner passes these limits through.
|
|
65
|
+
- The source CLI finds its bundled corpus without an explicit path, as the
|
|
66
|
+
built CLI does.
|
|
67
|
+
- The public verdict functions return typed results for malformed inputs,
|
|
68
|
+
throwing getters, and Proxies: `verifyDescriptor`, `verifyDescriptorChain`,
|
|
69
|
+
`verifyAcceptance`, `verifyTermination`, `verifyChain`, `verifyReceipt`,
|
|
70
|
+
`prepareSigning`, `finishSigning`, `governingRevision`, `decodeArtifact`,
|
|
71
|
+
`decodeCharterRevision`, `revisionDigest`, `decodePartyDescriptor`,
|
|
72
|
+
`descriptorDigest`, `checkSigningClaims`, `acceptanceRefusal`,
|
|
73
|
+
`terminationRefusal`, all four signing-input producers, `assembleCompact`, and
|
|
74
|
+
`decodeJsonText`. `verifySignature` returns `false` for malformed inputs.
|
|
75
|
+
`canonical`, `jsonProjection`, `encodeBase64url`, `taggedDigest`, `loadCorpus`,
|
|
76
|
+
and `reportFor` retain their existing return shapes and can throw on invalid
|
|
77
|
+
caller input, corpus failures, or unavailable corpus verification.
|
|
78
|
+
- Options use ordinary property reads, including inherited and getter values,
|
|
79
|
+
once at entry. Claims use own enumerable JSON members. Context copies read
|
|
80
|
+
only the members the entry point uses and check all chain list types before
|
|
81
|
+
bounds. Array lengths and typed byte lengths are checked before allocating
|
|
82
|
+
their copies. Other typed arrays are rejected before enumeration. JSON copies
|
|
83
|
+
retain at most the selected member count, count expanded bytes and depth,
|
|
84
|
+
and stop at the selected limits. Deep and shared signing claims return
|
|
85
|
+
`signing_input_invalid` without overflowing the stack or expanding unboundedly.
|
|
86
|
+
Reported array lengths must fit the unsigned 32-bit array range; all malformed
|
|
87
|
+
lengths return `invalid_type` before reading any items.
|
|
88
|
+
- Empty revision lists read descriptors before topology checks. The runner
|
|
89
|
+
handles null and incomplete sets, nontext predecessors, and null receipt
|
|
90
|
+
chains with typed errors. Case JSON preserves float lexemes during integrity
|
|
91
|
+
checks and execution: `protocol_revision: 2.0` returns `signing_input_invalid`
|
|
92
|
+
during signing preparation, and float profile bounds return `invalid_profile`.
|
|
93
|
+
- The corpus runner validates codepoints, integer text, tagged integer members,
|
|
94
|
+
digest domains and byte encodings, and schema member shapes. Case JSON retains
|
|
95
|
+
large integer tokens without rounding. Kind and value types must match.
|
|
96
|
+
Case chain views contain exactly the four artifact lists; limits come from
|
|
97
|
+
the case's top level.
|
|
98
|
+
- Integer claims reject float tokens before canonical encoding, including
|
|
99
|
+
integral floats such as `1.0`. Signing returns `signing_input_invalid`;
|
|
100
|
+
artifact verification and revision decoding return `invalid_type`.
|
|
101
|
+
- The signature guard requires canonical base64url public keys and accepts plain
|
|
102
|
+
and cross-realm `Uint8Array` messages and signatures.
|
|
103
|
+
- The workshop passes only the signing party's descriptor history to acceptance
|
|
104
|
+
verification. The extracted flow is tested with the site's browser shims and
|
|
105
|
+
real WebCrypto and noble keys, and the bundle uses this repository's verifier
|
|
106
|
+
throughout. Evidence checks reject unknown kinds. CI also checks the site's
|
|
107
|
+
types and build.
|
|
108
|
+
|
|
109
|
+
## [0.6.0] — 2026-10-13
|
|
110
|
+
|
|
111
|
+
### Breaking
|
|
112
|
+
|
|
113
|
+
- `verifyDescriptor` requires a predecessor with retained signed `lineage`;
|
|
114
|
+
the former `{ digest, claims }` shape returns `descriptor_chain_invalid`.
|
|
115
|
+
`DescriptorPredecessor` is now exported. Pass verified facts to the next call:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { verifyDescriptor, type DescriptorPredecessor } from "@charter-agreement-protocol/verifier";
|
|
119
|
+
const root = verifyDescriptor(genesisCompact);
|
|
120
|
+
if (root.ok) {
|
|
121
|
+
const previous: DescriptorPredecessor = root.facts;
|
|
122
|
+
const next = verifyDescriptor(successorCompact, previous);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A genesis descriptor given a predecessor now returns
|
|
127
|
+
`descriptor_chain_invalid` instead of verifying successfully. Both supplied
|
|
128
|
+
digest aliases must match the reverified lineage. A lone successor with a
|
|
129
|
+
noncanonical identity digest returns `descriptor_invalid` before the missing
|
|
130
|
+
predecessor reports `descriptor_chain_invalid`.
|
|
131
|
+
|
|
132
|
+
### Changed
|
|
133
|
+
|
|
134
|
+
- Browser bundles using the shipped crypto shim now verify valid Ed25519
|
|
135
|
+
signatures instead of returning `algorithm_unsupported_on_substrate`.
|
|
136
|
+
ML-DSA still reports that code on this substrate. `capabilities()` no
|
|
137
|
+
longer throws in a page that has no `process` object; it reports an empty
|
|
138
|
+
`linkedCrypto` there.
|
|
139
|
+
- A runtime whose ML-DSA key objects do not report their key type, such as
|
|
140
|
+
Bun, now verifies ML-DSA signatures instead of returning
|
|
141
|
+
`algorithm_unsupported_on_substrate`. The runtime is asked once through the
|
|
142
|
+
known-answer vector, which must verify while a tampered message must not,
|
|
143
|
+
and the answer is kept. CI runs the test suite with Bun installed.
|
|
144
|
+
- Profile rejections were reported under another code in some cases,
|
|
145
|
+
matching a change in the reference. An acceptance, termination, descriptor
|
|
146
|
+
or receipt outside the profile whose `kid` names no key returned the key
|
|
147
|
+
lookup code (`acceptance_invalid`, `termination_invalid`,
|
|
148
|
+
`descriptor_key_invalid`) or, for a receipt in a chain view,
|
|
149
|
+
`signature_invalid`; the envelope is now admitted before the key is looked
|
|
150
|
+
up, so it returns the profile code. `verifyDescriptor` given
|
|
151
|
+
a predecessor outside the profile returned `descriptor_chain_invalid`; it
|
|
152
|
+
now returns the profile code, as `verifyDescriptorChain` does, and a
|
|
153
|
+
predecessor whose signature the runtime cannot check returns
|
|
154
|
+
`algorithm_unsupported_on_substrate`.
|
|
155
|
+
- Standalone acceptance and termination profiles now admit the supplied
|
|
156
|
+
revision first, then every descriptor in the supplied history, then the
|
|
157
|
+
signed artifact. Receipt profiles reach the whole reverified chain view.
|
|
158
|
+
Excluded context now returns `algorithm_outside_profile` or
|
|
159
|
+
`revision_outside_profile` before artifact decoding, claims or signature
|
|
160
|
+
errors that previously took precedence, or instead of a successful result.
|
|
161
|
+
The supplied revision is checked against the profile before the supplied
|
|
162
|
+
descriptors are decoded, so an excluded revision beside a malformed
|
|
163
|
+
descriptor returns `revision_outside_profile`.
|
|
164
|
+
- `verifyReceipt(compact, revisionText, options)` now accepts a canonical
|
|
165
|
+
revision as context. Recognized claims return `governing_match: "undetermined"`
|
|
166
|
+
and `chain_conflict: "none"`; `not_verified` includes `signature` because this
|
|
167
|
+
context names no signing key. The receipt envelope is still admitted against
|
|
168
|
+
the profile. Excluded revisions or envelopes return `revision_outside_profile`
|
|
169
|
+
or `algorithm_outside_profile`; mismatched claims return
|
|
170
|
+
`receipt_claims_mismatch`. Previously text context returned `chain_invalid`.
|
|
171
|
+
- Omitted artifact lists, and lists given as `null`, a string, an object or an
|
|
172
|
+
array holding a non-string, now return `invalid_type` through
|
|
173
|
+
`governingRevision`, `acceptanceRefusal`, `terminationRefusal`,
|
|
174
|
+
`acceptanceSigningInput` and `terminationSigningInput`, replacing
|
|
175
|
+
`chain_invalid`. `verifyChain` and
|
|
176
|
+
`verifyReceipt` also require all four lists, including explicit empty lists.
|
|
177
|
+
- All producer build failures now return `signing_input_invalid`, including
|
|
178
|
+
malformed claims, extra members, invalid timestamps and unsupported emission
|
|
179
|
+
algorithms. This replaces leaked schema and artifact codes, including
|
|
180
|
+
`unknown_member`, `missing_required`, `nested_invalid`, `constraint_violation`,
|
|
181
|
+
`cardinality_violation`, `descriptor_invalid`, `acceptance_invalid`,
|
|
182
|
+
`termination_invalid`, `receipt_invalid`, `timestamp_invalid`, `invalid_type`
|
|
183
|
+
and `algorithm_unsupported`. An explicit null algorithm now rejects with
|
|
184
|
+
`signing_input_invalid` instead of selecting the default algorithm.
|
|
185
|
+
- `npm run build` removes `dist/` before compiling, so obsolete modules are
|
|
186
|
+
removed from the compiled package.
|
|
187
|
+
- Year 0000, including February 29, now passes timestamp parsing on every
|
|
188
|
+
artifact, indexed observation and governing query, matching RFC 3339 and
|
|
189
|
+
the reference. The self-check now asserts acceptance of year zero.
|
|
190
|
+
- Revisions repeating a party descriptor now return `revision_invalid`.
|
|
191
|
+
Views with both parties in one descriptor history, or a supplied history
|
|
192
|
+
that no revision names, now return `chain_invalid`. Missing descriptors
|
|
193
|
+
are skipped when comparing histories, as in the reference.
|
|
194
|
+
- Noncanonical signed digests now return `acceptance_invalid`,
|
|
195
|
+
`termination_invalid` or `receipt_invalid`, including optional detail and
|
|
196
|
+
nested receipt digests. A correctly signed receipt with a noncanonical
|
|
197
|
+
revision digest no longer verifies successfully.
|
|
198
|
+
- Malformed termination and receipt timestamps now return
|
|
199
|
+
`timestamp_invalid`; reversed valid times keep their artifact-specific
|
|
200
|
+
errors. Acceptance timestamps precede predecessor-shape checks, and
|
|
201
|
+
revision timestamps precede binding-digest checks.
|
|
202
|
+
- Descriptor key encodings that fit the schema but fail canonical encoding
|
|
203
|
+
or the selected algorithm's byte length now return `descriptor_invalid`.
|
|
204
|
+
Duplicate key IDs and the absence of an active key reject before extension
|
|
205
|
+
and timestamp checks. Noncanonical descriptor identity digests also
|
|
206
|
+
return `descriptor_invalid`.
|
|
207
|
+
- Chain routing checks the expected envelope type and both routing
|
|
208
|
+
coordinates before artifact claims: wrong types now report
|
|
209
|
+
`protected_header_invalid`, while missing signer coordinates or signer
|
|
210
|
+
histories report `chain_invalid`. Missing artifact lists now report
|
|
211
|
+
`invalid_type`; callers must supply empty lists explicitly.
|
|
212
|
+
- Successor descriptor links precede key selection. An incorrect link with
|
|
213
|
+
an unknown key now reports `descriptor_chain_invalid`.
|
|
214
|
+
`verifyDescriptor` re-verifies the predecessor's retained `lineage`,
|
|
215
|
+
ignoring caller key claims. Predecessors without valid lineage reject
|
|
216
|
+
with `descriptor_chain_invalid`; null claims no longer cause a crash.
|
|
217
|
+
Successful descriptor facts include lineage for subsequent calls.
|
|
218
|
+
- Producers reject extra termination members, including `extensions`,
|
|
219
|
+
with `signing_input_invalid`. Assembly re-decodes the complete artifact; framed
|
|
220
|
+
inputs with invalid claims now return `signing_input_invalid`.
|
|
221
|
+
- Runtime file imports can no longer replace verification or substrate
|
|
222
|
+
checks. The mutable test hook is removed from source and compiled output.
|
|
223
|
+
Normal signature verification asks the runtime about key support without
|
|
224
|
+
running signature vectors; only a crypto exception reruns the selected
|
|
225
|
+
vector. A failing signature vector no longer overrides a successful
|
|
226
|
+
normal crypto call.
|
|
227
|
+
- JSON limits count duplicate members after accepting the separator or closer
|
|
228
|
+
following each value. Malformed containers now report `invalid_syntax` before
|
|
229
|
+
`limit_exceeded`, `invalid_number` or `number_not_double_expressible` when
|
|
230
|
+
that separator is missing or invalid. Numeric conversion errors are delayed
|
|
231
|
+
until a container separator or the end of the root value is accepted.
|
|
232
|
+
An excess duplicate member now reports `limit_exceeded`; an invalid value
|
|
233
|
+
beyond an item or member bound reports its parse error first.
|
|
234
|
+
Nontext revision inputs now report `invalid_type`. A root number whose
|
|
235
|
+
fraction or exponent starts without digits, such as `1.` or `1e+`, reports
|
|
236
|
+
`invalid_syntax` instead of `trailing_bytes`, as the reference does.
|
|
237
|
+
- `verifySignature` returns false for messages over 1 MiB under default
|
|
238
|
+
limits. Explicit null artifact lists report `invalid_type`.
|
|
239
|
+
The exported `Profile` type accepts `algorithms` or `revisions` alone,
|
|
240
|
+
with the omitted axis using the full supported range.
|
|
241
|
+
|
|
242
|
+
Several inputs that verified under 0.5.0 now reject: revision JSON with
|
|
243
|
+
whitespace or duplicate members; revisions with invalid member types,
|
|
244
|
+
constraints, timestamps or party counts; unknown signed claims or extra
|
|
245
|
+
members in closed nested objects; descriptor histories mixing parties or
|
|
246
|
+
successors with a missing or different party ID; chain views with fewer or
|
|
247
|
+
more than two party histories; malformed indexed pricing terms or receipt
|
|
248
|
+
observations; and artifact lists or byte totals exceeding caller limits.
|
|
249
|
+
|
|
250
|
+
- Public `verify*` functions gain optional trailing limits and profile
|
|
251
|
+
arguments. Existing call signatures continue to work. `Limits`,
|
|
252
|
+
`VerificationOptions`, `DEFAULT_LIMITS` and `MAXIMUM_LIMITS` are exported.
|
|
253
|
+
- Verified terminations close governing views at their effective instant
|
|
254
|
+
when bound to the revision governing then; later receipts report a
|
|
255
|
+
governing mismatch.
|
|
256
|
+
- Facts include `not_verified` and artifact metadata (`protocol_revision`
|
|
257
|
+
and `alg` for signed artifacts). Framing decode adds `signature` to the
|
|
258
|
+
unverified scope.
|
|
259
|
+
- Unavailable crypto substrates report `algorithm_unsupported_on_substrate`
|
|
260
|
+
separately from invalid signatures, outside corpus verdict reports.
|
|
261
|
+
- JSON projections preserve input member order, including numeric-looking
|
|
262
|
+
names. The float boxing seam used by the differential gate is unchanged.
|
|
263
|
+
- The vendored certified corpus contains 163 cases for verification semantics
|
|
264
|
+
5 and uses the reference's expanded applicability floor. The registry digest
|
|
265
|
+
and package version remain unchanged.
|
|
266
|
+
|
|
6
267
|
## [0.5.0] — 2026-09-24
|
|
7
268
|
|
|
8
269
|
The CAP 0.4.0 release-identity act, mirrored: the capability profile, the
|
package/README.md
CHANGED
|
@@ -58,21 +58,102 @@ cannot verify green.
|
|
|
58
58
|
| `loadCorpus(root)` | Integrity-checked corpus load (canonical index, digests, file set, applicability floor, certified index pin) |
|
|
59
59
|
| `selfChecks()` | The self-check battery: SHA-256 known answers, canonical ordering, strict base64url, timestamp and limit invariants |
|
|
60
60
|
| `canonical(value)` | RFC 8785 canonical JSON serialization |
|
|
61
|
-
| `decodeJsonText(text)` | Strict I-JSON decode (duplicates, noncharacters, lone surrogates, number round-tripping rejected) |
|
|
62
|
-
| `jsonProjection(value)` | The tagged projection used by reports |
|
|
61
|
+
| `decodeJsonText(text, limits?)` | Strict I-JSON decode (duplicates, noncharacters, lone surrogates, number round-tripping rejected) |
|
|
62
|
+
| `jsonProjection(value)` | The tagged projection used by reports; object members retain text order |
|
|
63
|
+
| `Limits`, `DEFAULT_LIMITS`, `MAXIMUM_LIMITS` | Closed limits type, reference defaults and compiled maximum values; overrides must be nonnegative integers within the maximums |
|
|
64
|
+
| `ChainInput` | A chain view with `revisions`, `acceptances`, `descriptors`, and `terminations` string arrays |
|
|
65
|
+
| `VerificationOptions` | Optional `{ limits?: Partial<Limits>, profile?: { algorithms: string[]; revisions: { min: number; max: number } } }` for public verification |
|
|
66
|
+
| `SigningOptions` | Verification options plus an optional `algorithm` for `prepareSigning` |
|
|
67
|
+
| `capabilities()` / `algorithmRegistryDigest()` | Runtime known-answer results per signature registry row, and the signature registry digest |
|
|
63
68
|
| `CERTIFIED_INDEX_SHA256_BASE64URL`, `CERTIFIED_REGISTRY_DIGEST` | The certified identity pins this build carries |
|
|
64
|
-
| `verifyDescriptor(compact, predecessor?)` / `verifyDescriptorChain(compacts)` | Artifact-level verification: one party descriptor (with optional predecessor facts), or a full descriptor chain |
|
|
65
|
-
| `verifyAcceptance(compact, revisionText, descriptorCompacts)` / `verifyTermination(compact, revisionText, descriptorCompacts)` | Artifact-level verification of an acceptance / termination notice against the named revision and the signing party's descriptor chain |
|
|
66
|
-
| `verifyChain(chainInput)` / `verifyReceipt(compact, chainInput)` | Full chain-view verification (facts include
|
|
69
|
+
| `verifyDescriptor(compact, predecessor?, options?)` / `verifyDescriptorChain(compacts, options?)` | Artifact-level verification: one party descriptor (with optional predecessor facts), or a full descriptor chain |
|
|
70
|
+
| `verifyAcceptance(compact, revisionText, descriptorCompacts, options?)` / `verifyTermination(compact, revisionText, descriptorCompacts, options?)` | Artifact-level verification of an acceptance / termination notice against the named revision and the signing party's descriptor chain |
|
|
71
|
+
| `verifyChain(chainInput, options?)` / `verifyReceipt(compact, chainInput, options?)` | Full chain-view verification (facts include topology, verified acceptances and termination notices); receipt verification against the verified chain |
|
|
67
72
|
| `checkSigningClaims(kind, claims)` | The producer build gate's claims half (the reference `decode_for_signing`): the claims-only schema checks per kind — `descriptor \| acceptance \| termination \| receipt` — shared with the verify paths; holder-side signers run it before any key is used |
|
|
68
|
-
| `decodeArtifact(compact)` / `verifySignature(message, signature, publicKey, alg)` | Framing
|
|
73
|
+
| `decodeArtifact(compact)` / `verifySignature(message, signature, publicKey, alg, options?)` | Framing decode and the strict signature primitive; the latter retains its boolean result with optional limits and algorithm filtering |
|
|
69
74
|
| `descriptorSigningInput(kid, claims, alg?)` / `receiptSigningInput(kid, claims, alg?)` | The build-only producers: the exact RFC 7515 signing input per kind (emission pair gated, claims schema gated, provisional decode) — no key, no signature |
|
|
70
75
|
| `acceptanceSigningInput(kid, claims, chainInput, alg?)` / `terminationSigningInput(kid, claims, chainInput, alg?)` | The set-aware producers: build first, then the R1–R3 refusal checks at the reference ordering |
|
|
76
|
+
| `prepareSigning(kind, kid, claims, publicKey, context, options?)` | Check framing, claims, context, profile, limits, and the holder's own signing key before signing; return a `SigningPlan` |
|
|
77
|
+
| `finishSigning(plan, signature)` | Assemble under the plan's limits and run public verification with its retained context |
|
|
78
|
+
| `SigningPlan` / `SigningKind` | The plan class exposes `kind`, `input`, and `key` (`matched` or `unnamed`); kinds are `descriptor`, `acceptance`, `termination`, and `receipt` |
|
|
71
79
|
| `assembleCompact(signingInput, signature)` | Assemble a validated signing input and its exact raw signature (registry-row length, framing re-decode, size gate) |
|
|
72
|
-
| `governingRevision(chainInput, at)` | The unique governing revision at one UTC instant — a digest, or `contested`/`none`,
|
|
73
|
-
| `decodeCharterRevision(text)` / `revisionDigest(text)` | Decode one canonical unsigned Charter Revision (claims + content digest over the exact text bytes) |
|
|
80
|
+
| `governingRevision(chainInput, at, options?)` | The unique governing revision at one UTC instant — a digest, or `contested`/`none`, including verified termination closing |
|
|
81
|
+
| `decodeCharterRevision(text, options?)` / `revisionDigest(text, options?)` | Decode one canonical unsigned Charter Revision (claims + content digest over the exact text bytes) |
|
|
74
82
|
| `decodePartyDescriptor(compact)` / `descriptorDigest(compact)` | Decode one Party Descriptor's claims and digest without verifying its signature |
|
|
75
|
-
| `acceptanceRefusal(claims, chainInput)` / `terminationRefusal(claims, chainInput)` | The honest-signer refusal checks (R1–R3: claims-truth, no-equivocation, ancestry/governing coverage) over the caller's own view
|
|
83
|
+
| `acceptanceRefusal(claims, chainInput)` / `terminationRefusal(claims, chainInput)` | The honest-signer refusal checks (R1–R3: claims-truth, no-equivocation, ancestry/governing coverage) over the caller's own view return `{ok: true}`, `signing_refused`, `signing_input_invalid`, or the set verification error. Holder-side signers run these before any key is used; the rule that fired is deliberately not surfaced |
|
|
84
|
+
|
|
85
|
+
`prepareSigning` accepts a predecessor or `null` for a descriptor, a chain view
|
|
86
|
+
(`revisions`, `acceptances`, `descriptors`, `terminations` arrays) for acceptance
|
|
87
|
+
and termination, and a chain view or bare revision text for a receipt. Pass a
|
|
88
|
+
canonical base64url public key. Its options are `algorithm`, `limits`, and
|
|
89
|
+
`profile`. Limits cover every artifact read, including the entire set. For
|
|
90
|
+
acceptance and termination, the profile covers the revision, the signing party's
|
|
91
|
+
descriptor history, and the new artifact; the full profile checks the rest of
|
|
92
|
+
the set. A receipt's profile covers the whole retained set and the new artifact.
|
|
93
|
+
A descriptor's profile includes its predecessor history.
|
|
94
|
+
|
|
95
|
+
Sign `plan.input.message`, then pass the raw `Uint8Array` signature to
|
|
96
|
+
`finishSigning`. Both signature functions accept plain and cross-realm
|
|
97
|
+
`Uint8Array` bytes, including Node Buffers. `verifySignature` returns `false` for
|
|
98
|
+
`ArrayBuffer` and `DataView` inputs; `finishSigning` returns `invalid_type` for
|
|
99
|
+
them. A bare-revision receipt has `key: "unnamed"`; public receipt
|
|
100
|
+
verification leaves its signature unchecked. `signing_key_invalid` means the
|
|
101
|
+
snapshot key fails the encoding or shape check; `signing_key_mismatch` means it
|
|
102
|
+
matches no active candidate in the holder's own view. The plan retains private
|
|
103
|
+
copies of its input, context arrays, limits, and profile. The existing producers
|
|
104
|
+
and `assembleCompact` continue to use default limits; use the plan API for caller
|
|
105
|
+
limits and the check before signing. A non-set passed to the existing set-aware
|
|
106
|
+
producers still returns `signing_input_invalid`.
|
|
107
|
+
|
|
108
|
+
The following public functions return typed results for malformed input and
|
|
109
|
+
unreadable getters or Proxies: `verifyDescriptor`, `verifyDescriptorChain`,
|
|
110
|
+
`verifyAcceptance`, `verifyTermination`, `verifyChain`, `verifyReceipt`,
|
|
111
|
+
`prepareSigning`, `finishSigning`, `governingRevision`, `decodeArtifact`,
|
|
112
|
+
`decodeCharterRevision`, `revisionDigest`, `decodePartyDescriptor`,
|
|
113
|
+
`descriptorDigest`, `checkSigningClaims`, `acceptanceRefusal`,
|
|
114
|
+
`terminationRefusal`, `descriptorSigningInput`, `receiptSigningInput`,
|
|
115
|
+
`acceptanceSigningInput`, `terminationSigningInput`, `assembleCompact`, and
|
|
116
|
+
`decodeJsonText`. `verifySignature` returns `false` for malformed input.
|
|
117
|
+
`canonical`, `jsonProjection`, `encodeBase64url`, `taggedDigest`, `loadCorpus`,
|
|
118
|
+
and `reportFor` retain their existing return shapes and can throw on invalid
|
|
119
|
+
caller input, corpus failures, or unavailable corpus verification.
|
|
120
|
+
|
|
121
|
+
Known option members are read once at entry with ordinary property reads;
|
|
122
|
+
inherited values and getters count. Claims use own enumerable JSON members.
|
|
123
|
+
Copies check array lengths and byte sizes before allocation and bound expanded
|
|
124
|
+
bytes and depth. Deep or excessively shared signing claims return
|
|
125
|
+
`signing_input_invalid`.
|
|
126
|
+
|
|
127
|
+
Verification options default to the full algorithm registry, revisions 1..3,
|
|
128
|
+
and `DEFAULT_LIMITS`. Profiles apply to each signed artifact after its local
|
|
129
|
+
checks and before crypto; unsigned charter revisions use only the revision
|
|
130
|
+
axis. Public acceptance, termination, and receipt calls re-verify their
|
|
131
|
+
supplied context and check the artifact under the requested profile. `verifyChain` applies it throughout
|
|
132
|
+
the view. Malformed options return `invalid_limits` or `invalid_profile`;
|
|
133
|
+
excluded artifacts return `algorithm_outside_profile` or
|
|
134
|
+
`revision_outside_profile`.
|
|
135
|
+
|
|
136
|
+
Profiles may supply either `algorithms` or `revisions`; the omitted axis uses
|
|
137
|
+
the full supported range. A descriptor predecessor must retain its signed
|
|
138
|
+
`lineage`: pass the facts from a successful `verifyDescriptor` call to the
|
|
139
|
+
next call. The verifier rechecks those bytes and uses the resulting keys.
|
|
140
|
+
|
|
141
|
+
Chain views must supply all four artifact lists, using `[]` for empty lists.
|
|
142
|
+
The revision parties must be distinct descriptors and resolve to different
|
|
143
|
+
histories, and every supplied history must be named by some revision.
|
|
144
|
+
|
|
145
|
+
Each of the view's four artifact lists is bounded by
|
|
146
|
+
`max_artifact_set_items`; `max_artifact_set_bytes` bounds their combined
|
|
147
|
+
UTF-8 byte lengths before decoding. Corpus chain inputs can also supply
|
|
148
|
+
`limits`; receipt cases supply them inside the nested chain input.
|
|
149
|
+
|
|
150
|
+
Every facts record includes the reference's `not_verified` floor. Signed
|
|
151
|
+
records include `protocol_revision` and `alg`; unsigned revisions have
|
|
152
|
+
`alg: null`, and aggregate records have `protocol_revision: null`.
|
|
153
|
+
`decodeArtifact` also includes `signature` in `not_verified`. Artifact
|
|
154
|
+
verification can return `algorithm_unsupported_on_substrate` after its
|
|
155
|
+
deterministic checks. Corpus reporting stops with a diagnostic when the
|
|
156
|
+
substrate cannot verify, keeping that local result outside verdict reports.
|
|
76
157
|
|
|
77
158
|
## Evidence
|
|
78
159
|
|
|
@@ -84,6 +165,13 @@ cannot verify green.
|
|
|
84
165
|
harness and a 25-mutation red-required battery.
|
|
85
166
|
- **The certified corpus** ships in this package (`conformance/`), pinned by
|
|
86
167
|
a raw index SHA-256 asserted at load.
|
|
168
|
+
- **Ed25519 key and R admission.** After `npm run build`, run
|
|
169
|
+
`npm run check:ed25519 -- /path/to/elixir/repository` to compare the source
|
|
170
|
+
and built predicates with Elixir at `911d84b` on 10,000 seeded inputs and
|
|
171
|
+
51 named edges for each role. The check compiles Elixir in a temporary copy
|
|
172
|
+
of that commit, exposing its private R check by changing only its visibility.
|
|
173
|
+
Run `npm run bench:ed25519` for admission and native signature costs, plus
|
|
174
|
+
a valid chain with 80 descriptors, 200 revisions, and 400 acceptances.
|
|
87
175
|
- **This package never publishes verdict claims that were not recomputed
|
|
88
176
|
from raw bytes.**
|
|
89
177
|
|
|
@@ -98,8 +186,9 @@ cross-verifies TypeScript-signed artifacts from raw bytes):
|
|
|
98
186
|
- **This package** — `@charter-agreement-protocol/verifier`: verification
|
|
99
187
|
and the pure producer surface (signing inputs, refusal guards, assembly).
|
|
100
188
|
- [`@charter-agreement-protocol/signer`](https://www.npmjs.com/package/@charter-agreement-protocol/signer)
|
|
101
|
-
— the holder-side companion: key custody
|
|
102
|
-
|
|
189
|
+
— the holder-side companion: key custody and the wrong-key guard. It
|
|
190
|
+
calls `prepareSigning` before the key is used and `finishSigning` after,
|
|
191
|
+
so every protocol check stays in this package.
|
|
103
192
|
|
|
104
193
|
The pair releases together: the signer depends on this package, so a
|
|
105
194
|
verifier release stages first and the signer locks and releases against
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
| Version | Security fixes |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| 0.7.x | yes, once 0.7.0 is released, in a new 0.7 patch release |
|
|
8
|
+
| 0.6.x and earlier | no; upgrade to 0.7.x once released |
|
|
9
|
+
|
|
10
|
+
The [changelog](CHANGELOG.md) describes verification changes between releases.
|
|
11
|
+
Keep the package version with stored verification results so you can check
|
|
12
|
+
them again when upgrading.
|
|
13
|
+
|
|
14
|
+
## Reporting a vulnerability
|
|
15
|
+
|
|
16
|
+
Report it privately through the repository's Security tab, then
|
|
17
|
+
"Report a vulnerability", for
|
|
18
|
+
[`baselabs/charter_agreement_protocol_typescript`](https://github.com/baselabs/charter_agreement_protocol_typescript/security/advisories/new).
|
|
19
|
+
|
|
20
|
+
Never put an exploit, credential, private key, production data or an
|
|
21
|
+
unfixed vulnerability's details in a public issue, pull request or discussion.
|
|
22
|
+
|
|
23
|
+
A useful report names:
|
|
24
|
+
|
|
25
|
+
- the package version or commit and the Node version;
|
|
26
|
+
- the property that fails, such as a modified artifact verifying or a limit
|
|
27
|
+
not being enforced;
|
|
28
|
+
- the smallest reproduction, using test keys and synthetic data;
|
|
29
|
+
- the result you expected, usually a typed `{ ok: false, code: "..." }`.
|
|
30
|
+
|
|
31
|
+
## What happens after you report
|
|
32
|
+
|
|
33
|
+
| Step | Target |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| We confirm we received the report | within 3 business days |
|
|
36
|
+
| We tell you whether we can reproduce it and how serious it is | within 10 business days |
|
|
37
|
+
| We ship a fix in a patch release | as soon as it is ready, within 90 days of the report |
|
|
38
|
+
| We publish an advisory crediting you, unless you ask us not to | when the fix is on npm |
|
|
39
|
+
|
|
40
|
+
If a fix needs longer than 90 days, we agree on a new date with you before
|
|
41
|
+
the 90 days run out. Please keep the details private until the advisory is
|
|
42
|
+
published.
|
|
43
|
+
|
|
44
|
+
## Scope
|
|
45
|
+
|
|
46
|
+
In scope: everything shipped in the npm package
|
|
47
|
+
`@charter-agreement-protocol/verifier`.
|
|
48
|
+
|
|
49
|
+
- Decoding, canonicalization, digests, signature checks, descriptor, chain,
|
|
50
|
+
acceptance, termination and receipt verification, and the facts they return.
|
|
51
|
+
- Signing input helpers, compact assembly, `prepareSigning` and `finishSigning`.
|
|
52
|
+
The caller supplies the context, time, limits, public key and signature.
|
|
53
|
+
- The corpus loader and CLI, including filesystem checks. They cap a corpus
|
|
54
|
+
at 64 files and 32 MiB and reject symlinks and other entries that are neither
|
|
55
|
+
regular files nor directories.
|
|
56
|
+
- The shipped conformance corpus and package documentation.
|
|
57
|
+
|
|
58
|
+
Out of scope here:
|
|
59
|
+
|
|
60
|
+
- What your application does with the facts. CAP verifies and never
|
|
61
|
+
authorizes; the [README](README.md) describes the `not_verified` fields.
|
|
62
|
+
- Key custody and signing callbacks. Report companion signer issues to
|
|
63
|
+
[charter_agreement_signer_typescript](https://github.com/baselabs/charter_agreement_signer_typescript).
|
|
64
|
+
- The Elixir reference. Report its issues to
|
|
65
|
+
[charter_agreement_protocol](https://github.com/baselabs/charter_agreement_protocol).
|
|
66
|
+
|
|
67
|
+
The workshop is maintained in this repository but is outside the npm package.
|
|
68
|
+
Report a flaw in its signing or verification flow through the same private
|
|
69
|
+
reporting form.
|
|
70
|
+
|
|
71
|
+
## Reproducing a report
|
|
72
|
+
|
|
73
|
+
Use Node 24.8.0 or later. From a source checkout:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
npm ci
|
|
77
|
+
npm test
|
|
78
|
+
npm run typecheck
|
|
79
|
+
npm run typecheck:web
|
|
80
|
+
npm run self-checks
|
|
81
|
+
npm run build
|
|
82
|
+
npm run build:site
|
|
83
|
+
node cli.ts --corpus conformance
|
|
84
|
+
node dist/cli.js --corpus conformance
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For an installed package, run `cap-verifier --corpus DIRECTORY` to check a
|
|
88
|
+
corpus directory. Include the command, its output and the synthetic input
|
|
89
|
+
that reproduces the problem in your private report.
|