@certcrypt/verifier-toolkit 0.0.0-stage → 1.0.1
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.
Potentially problematic release.
This version of @certcrypt/verifier-toolkit might be problematic. Click here for more details.
- package/CHANGELOG.md +72 -0
- package/LICENSE +178 -0
- package/README.md +563 -2
- package/SECURITY.md +77 -0
- package/dist/cli/certcrypt-verify.d.ts +2 -0
- package/dist/cli/certcrypt-verify.js +174 -0
- package/dist/cli/certcrypt-verify.js.map +1 -0
- package/dist/core/config/certcrypt-foundation.d.ts +13 -0
- package/dist/core/config/certcrypt-foundation.js +123 -0
- package/dist/core/config/certcrypt-foundation.js.map +1 -0
- package/dist/core/config/default.d.ts +47 -0
- package/dist/core/config/default.js +93 -0
- package/dist/core/config/default.js.map +1 -0
- package/dist/core/config/test-keys.d.ts +40 -0
- package/dist/core/config/test-keys.js +41 -0
- package/dist/core/config/test-keys.js.map +1 -0
- package/dist/core/conformance/attestation.d.ts +4 -0
- package/dist/core/conformance/attestation.js +4 -0
- package/dist/core/conformance/attestation.js.map +1 -0
- package/dist/core/consistency/verify-consistency.d.ts +92 -0
- package/dist/core/consistency/verify-consistency.js +353 -0
- package/dist/core/consistency/verify-consistency.js.map +1 -0
- package/dist/core/crypto/canonical-json.d.ts +14 -0
- package/dist/core/crypto/canonical-json.js +13 -0
- package/dist/core/crypto/canonical-json.js.map +1 -0
- package/dist/core/crypto/canonical-subject.d.ts +76 -0
- package/dist/core/crypto/canonical-subject.js +248 -0
- package/dist/core/crypto/canonical-subject.js.map +1 -0
- package/dist/core/crypto/collection-merkle.d.ts +91 -0
- package/dist/core/crypto/collection-merkle.js +243 -0
- package/dist/core/crypto/collection-merkle.js.map +1 -0
- package/dist/core/crypto/composite.d.ts +73 -0
- package/dist/core/crypto/composite.js +206 -0
- package/dist/core/crypto/composite.js.map +1 -0
- package/dist/core/crypto/digest.d.ts +18 -0
- package/dist/core/crypto/digest.js +37 -0
- package/dist/core/crypto/digest.js.map +1 -0
- package/dist/core/crypto/ecdsa-p256.d.ts +12 -0
- package/dist/core/crypto/ecdsa-p256.js +70 -0
- package/dist/core/crypto/ecdsa-p256.js.map +1 -0
- package/dist/core/crypto/ed25519.d.ts +10 -0
- package/dist/core/crypto/ed25519.js +28 -0
- package/dist/core/crypto/ed25519.js.map +1 -0
- package/dist/core/crypto/holder-keyset.d.ts +23 -0
- package/dist/core/crypto/holder-keyset.js +64 -0
- package/dist/core/crypto/holder-keyset.js.map +1 -0
- package/dist/core/crypto/jcs.d.ts +9 -0
- package/dist/core/crypto/jcs.js +59 -0
- package/dist/core/crypto/jcs.js.map +1 -0
- package/dist/core/crypto/merkle.d.ts +34 -0
- package/dist/core/crypto/merkle.js +147 -0
- package/dist/core/crypto/merkle.js.map +1 -0
- package/dist/core/crypto/ml-dsa.d.ts +25 -0
- package/dist/core/crypto/ml-dsa.js +104 -0
- package/dist/core/crypto/ml-dsa.js.map +1 -0
- package/dist/core/crypto/provider/bytes.d.ts +31 -0
- package/dist/core/crypto/provider/bytes.js +106 -0
- package/dist/core/crypto/provider/bytes.js.map +1 -0
- package/dist/core/crypto/provider/index.d.ts +45 -0
- package/dist/core/crypto/provider/index.js +60 -0
- package/dist/core/crypto/provider/index.js.map +1 -0
- package/dist/core/crypto/provider/node.d.ts +2 -0
- package/dist/core/crypto/provider/node.js +96 -0
- package/dist/core/crypto/provider/node.js.map +1 -0
- package/dist/core/crypto/provider/register-node.d.ts +11 -0
- package/dist/core/crypto/provider/register-node.js +16 -0
- package/dist/core/crypto/provider/register-node.js.map +1 -0
- package/dist/core/crypto/provider/types.d.ts +77 -0
- package/dist/core/crypto/provider/types.js +16 -0
- package/dist/core/crypto/provider/types.js.map +1 -0
- package/dist/core/crypto/provider/web.d.ts +2 -0
- package/dist/core/crypto/provider/web.js +122 -0
- package/dist/core/crypto/provider/web.js.map +1 -0
- package/dist/core/crypto/pseudonym.d.ts +25 -0
- package/dist/core/crypto/pseudonym.js +37 -0
- package/dist/core/crypto/pseudonym.js.map +1 -0
- package/dist/core/crypto/subject-json-preconditions.d.ts +47 -0
- package/dist/core/crypto/subject-json-preconditions.js +373 -0
- package/dist/core/crypto/subject-json-preconditions.js.map +1 -0
- package/dist/core/domain/verify-domain.d.ts +13 -0
- package/dist/core/domain/verify-domain.js +39 -0
- package/dist/core/domain/verify-domain.js.map +1 -0
- package/dist/core/foundation/anti-equivocation.d.ts +87 -0
- package/dist/core/foundation/anti-equivocation.js +0 -0
- package/dist/core/foundation/anti-equivocation.js.map +1 -0
- package/dist/core/foundation/verify-foundation.d.ts +36 -0
- package/dist/core/foundation/verify-foundation.js +559 -0
- package/dist/core/foundation/verify-foundation.js.map +1 -0
- package/dist/core/independent/anti-replay.d.ts +15 -0
- package/dist/core/independent/anti-replay.js +27 -0
- package/dist/core/independent/anti-replay.js.map +1 -0
- package/dist/core/independent/anti-splicing.d.ts +16 -0
- package/dist/core/independent/anti-splicing.js +54 -0
- package/dist/core/independent/anti-splicing.js.map +1 -0
- package/dist/core/independent/capacity-binding.d.ts +26 -0
- package/dist/core/independent/capacity-binding.js +57 -0
- package/dist/core/independent/capacity-binding.js.map +1 -0
- package/dist/core/independent/capacity-evidence.d.ts +38 -0
- package/dist/core/independent/capacity-evidence.js +286 -0
- package/dist/core/independent/capacity-evidence.js.map +1 -0
- package/dist/core/independent/effective-units.d.ts +42 -0
- package/dist/core/independent/effective-units.js +147 -0
- package/dist/core/independent/effective-units.js.map +1 -0
- package/dist/core/independent/issuance-participation.d.ts +13 -0
- package/dist/core/independent/issuance-participation.js +24 -0
- package/dist/core/independent/issuance-participation.js.map +1 -0
- package/dist/core/independent/leaf-binding.d.ts +5 -0
- package/dist/core/independent/leaf-binding.js +135 -0
- package/dist/core/independent/leaf-binding.js.map +1 -0
- package/dist/core/independent/operator-recognition-registry.d.ts +33 -0
- package/dist/core/independent/operator-recognition-registry.js +116 -0
- package/dist/core/independent/operator-recognition-registry.js.map +1 -0
- package/dist/core/independent/proof-structure.d.ts +8 -0
- package/dist/core/independent/proof-structure.js +167 -0
- package/dist/core/independent/proof-structure.js.map +1 -0
- package/dist/core/independent/proof-views.d.ts +26 -0
- package/dist/core/independent/proof-views.js +58 -0
- package/dist/core/independent/proof-views.js.map +1 -0
- package/dist/core/independent/settlement.d.ts +18 -0
- package/dist/core/independent/settlement.js +548 -0
- package/dist/core/independent/settlement.js.map +1 -0
- package/dist/core/independent/verify-independent.d.ts +30 -0
- package/dist/core/independent/verify-independent.js +123 -0
- package/dist/core/independent/verify-independent.js.map +1 -0
- package/dist/core/independent/verify-operator-recognition.d.ts +26 -0
- package/dist/core/independent/verify-operator-recognition.js +60 -0
- package/dist/core/independent/verify-operator-recognition.js.map +1 -0
- package/dist/core/independent/verify-proof-signature.d.ts +20 -0
- package/dist/core/independent/verify-proof-signature.js +97 -0
- package/dist/core/independent/verify-proof-signature.js.map +1 -0
- package/dist/core/input/fs-bridge.d.ts +30 -0
- package/dist/core/input/fs-bridge.js +35 -0
- package/dist/core/input/fs-bridge.js.map +1 -0
- package/dist/core/input/load-artifacts.d.ts +2 -0
- package/dist/core/input/load-artifacts.js +80 -0
- package/dist/core/input/load-artifacts.js.map +1 -0
- package/dist/core/input/load-original-material.d.ts +11 -0
- package/dist/core/input/load-original-material.js +126 -0
- package/dist/core/input/load-original-material.js.map +1 -0
- package/dist/core/input/register-node-fs.d.ts +1 -0
- package/dist/core/input/register-node-fs.js +24 -0
- package/dist/core/input/register-node-fs.js.map +1 -0
- package/dist/core/input/resolve-target.d.ts +16 -0
- package/dist/core/input/resolve-target.js +43 -0
- package/dist/core/input/resolve-target.js.map +1 -0
- package/dist/core/input/strict-json.d.ts +25 -0
- package/dist/core/input/strict-json.js +167 -0
- package/dist/core/input/strict-json.js.map +1 -0
- package/dist/core/input/validate.d.ts +7 -0
- package/dist/core/input/validate.js +83 -0
- package/dist/core/input/validate.js.map +1 -0
- package/dist/core/issued/verify-collection-element.d.ts +66 -0
- package/dist/core/issued/verify-collection-element.js +137 -0
- package/dist/core/issued/verify-collection-element.js.map +1 -0
- package/dist/core/issued/verify-issued.d.ts +15 -0
- package/dist/core/issued/verify-issued.js +361 -0
- package/dist/core/issued/verify-issued.js.map +1 -0
- package/dist/core/issued/verify-original-material.d.ts +35 -0
- package/dist/core/issued/verify-original-material.js +418 -0
- package/dist/core/issued/verify-original-material.js.map +1 -0
- package/dist/core/package/verify-package.d.ts +34 -0
- package/dist/core/package/verify-package.js +109 -0
- package/dist/core/package/verify-package.js.map +1 -0
- package/dist/core/public-api.d.ts +178 -0
- package/dist/core/public-api.js +182 -0
- package/dist/core/public-api.js.map +1 -0
- package/dist/core/result/builder.d.ts +92 -0
- package/dist/core/result/builder.js +408 -0
- package/dist/core/result/builder.js.map +1 -0
- package/dist/core/rules/verify-corpus.d.ts +88 -0
- package/dist/core/rules/verify-corpus.js +165 -0
- package/dist/core/rules/verify-corpus.js.map +1 -0
- package/dist/core/rules/verify-rules.d.ts +14 -0
- package/dist/core/rules/verify-rules.js +62 -0
- package/dist/core/rules/verify-rules.js.map +1 -0
- package/dist/core/testing/validate-against-schema.d.ts +31 -0
- package/dist/core/testing/validate-against-schema.js +93 -0
- package/dist/core/testing/validate-against-schema.js.map +1 -0
- package/dist/core/types/artifacts.d.ts +224 -0
- package/dist/core/types/artifacts.js +2 -0
- package/dist/core/types/artifacts.js.map +1 -0
- package/dist/core/types/capacity-evidence.d.ts +85 -0
- package/dist/core/types/capacity-evidence.js +51 -0
- package/dist/core/types/capacity-evidence.js.map +1 -0
- package/dist/core/types/check.d.ts +61 -0
- package/dist/core/types/check.js +2 -0
- package/dist/core/types/check.js.map +1 -0
- package/dist/core/types/config.d.ts +97 -0
- package/dist/core/types/config.js +2 -0
- package/dist/core/types/config.js.map +1 -0
- package/dist/core/types/foundation.d.ts +121 -0
- package/dist/core/types/foundation.js +25 -0
- package/dist/core/types/foundation.js.map +1 -0
- package/dist/core/types/index.d.ts +9 -0
- package/dist/core/types/index.js +2 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/types/operator-recognition.d.ts +71 -0
- package/dist/core/types/operator-recognition.js +24 -0
- package/dist/core/types/operator-recognition.js.map +1 -0
- package/dist/core/types/proof.d.ts +94 -0
- package/dist/core/types/proof.js +2 -0
- package/dist/core/types/proof.js.map +1 -0
- package/dist/core/types/request.d.ts +59 -0
- package/dist/core/types/request.js +2 -0
- package/dist/core/types/request.js.map +1 -0
- package/dist/core/types/result.d.ts +164 -0
- package/dist/core/types/result.js +2 -0
- package/dist/core/types/result.js.map +1 -0
- package/dist/core/types/settlement-material.d.ts +130 -0
- package/dist/core/types/settlement-material.js +2 -0
- package/dist/core/types/settlement-material.js.map +1 -0
- package/dist/core/verify-node.d.ts +14 -0
- package/dist/core/verify-node.js +17 -0
- package/dist/core/verify-node.js.map +1 -0
- package/dist/core/verify-web.d.ts +1 -0
- package/dist/core/verify-web.js +25 -0
- package/dist/core/verify-web.js.map +1 -0
- package/dist/core/verify.d.ts +18 -0
- package/dist/core/verify.js +183 -0
- package/dist/core/verify.js.map +1 -0
- package/package.json +71 -4
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { verify } from "../verify.js";
|
|
2
|
+
import { PENDING_CORPUS_PROOF } from "../config/default.js";
|
|
3
|
+
import { collectionLeafHash, collectionMerkleRoot } from "../crypto/collection-merkle.js";
|
|
4
|
+
import { canonicalBytesForSubject } from "../crypto/canonical-subject.js";
|
|
5
|
+
import { loadArtifacts } from "../input/load-artifacts.js";
|
|
6
|
+
const COLLECTION_PROFILE = "subject.collection/1";
|
|
7
|
+
const TEXT_PROFILE = "subject.text/1";
|
|
8
|
+
const BINARY_PROFILE = "subject.binary/1";
|
|
9
|
+
/**
|
|
10
|
+
* Establish that a set of documents is the exact ruleset a corpus proof certifies
|
|
11
|
+
* (`rules-domain/1` §13.3), without a live CERTCRYPT service and without trusting
|
|
12
|
+
* where the documents or the proof came from.
|
|
13
|
+
*
|
|
14
|
+
* The chain, link by link:
|
|
15
|
+
*
|
|
16
|
+
* 1. The corpus proof verifies as an ordinary proof: `INDEPENDENT_VALID` under
|
|
17
|
+
* `config`, for the `rules_version` it certifies.
|
|
18
|
+
* 2. Its anchored `subtree_root` is the commitment `config` carries for that
|
|
19
|
+
* `rules_version`. That pins the one proof: a second emission over the same text
|
|
20
|
+
* has another `subtree_root` and does not pass (§13.3.2; `independence.proof/1`
|
|
21
|
+
* §12.9).
|
|
22
|
+
* 3. Its certificate commits to exactly one `subject.collection/1` whose leaves are
|
|
23
|
+
* all `subject.text/1`, as many as the documents supplied.
|
|
24
|
+
* 4. Each document, canonicalized under `subject.text/1` and salted with the
|
|
25
|
+
* certificate's anchor `nonce_hex` (`subject.collection/1` §8), reproduces its
|
|
26
|
+
* leaf, and the leaves fold to the signed collection root.
|
|
27
|
+
*
|
|
28
|
+
* Link 4 is what binds the text; links 1–2 are what make that binding the one the
|
|
29
|
+
* verifier trusts. Establishing authenticity of the text says nothing about whether
|
|
30
|
+
* the rules are right — only that they are the ones that govern.
|
|
31
|
+
*/
|
|
32
|
+
export function verifyRulesCorpus(request, documents, config) {
|
|
33
|
+
const failures = [];
|
|
34
|
+
const verdict = verify(request, config);
|
|
35
|
+
const { baseCertificate, independenceProof } = loadArtifacts(request);
|
|
36
|
+
const rulesVersion = independenceProof?.rules_version ?? null;
|
|
37
|
+
const subtreeRoot = independenceProof?.subtree_root ?? null;
|
|
38
|
+
// 1. The proof itself.
|
|
39
|
+
if (verdict.result_code !== "INDEPENDENT_VALID") {
|
|
40
|
+
failures.push(`the corpus proof does not verify as independent: ${verdict.result_code}` +
|
|
41
|
+
(verdict.failure_reason ? ` — ${verdict.failure_reason}` : ""));
|
|
42
|
+
}
|
|
43
|
+
if (rulesVersion === null || !config.supported_rules_versions.includes(rulesVersion)) {
|
|
44
|
+
failures.push(`the corpus proof certifies rules_version "${rulesVersion}", which this configuration does not support`);
|
|
45
|
+
}
|
|
46
|
+
// 2. The commitment the verifier carries.
|
|
47
|
+
const carried = rulesVersion === null ? undefined : config.rules_corpus_roots?.[rulesVersion];
|
|
48
|
+
if (typeof carried !== "string" || carried.length === 0 || carried === PENDING_CORPUS_PROOF) {
|
|
49
|
+
failures.push(`this configuration carries no corpus commitment for "${rulesVersion}", so no corpus proof can be ` +
|
|
50
|
+
"accepted for it (rules-domain/1 §13.3.1)");
|
|
51
|
+
}
|
|
52
|
+
else if (carried !== subtreeRoot) {
|
|
53
|
+
failures.push(`the corpus proof's subtree_root ${subtreeRoot} is not the commitment this configuration carries ` +
|
|
54
|
+
`(${carried}): it is not the proof that certifies this rules domain`);
|
|
55
|
+
}
|
|
56
|
+
// 3 and 4. The certified subject and the documents themselves.
|
|
57
|
+
const certified = checkCertifiedCollection(baseCertificate, documents);
|
|
58
|
+
failures.push(...certified.failures);
|
|
59
|
+
const declared = certified.declared;
|
|
60
|
+
const collection = { root: certified.collectionRoot };
|
|
61
|
+
return {
|
|
62
|
+
valid: failures.length === 0,
|
|
63
|
+
failures,
|
|
64
|
+
rules_version: rulesVersion,
|
|
65
|
+
subtree_root: subtreeRoot,
|
|
66
|
+
collection_root: collection.root,
|
|
67
|
+
declared_cardinality: declared,
|
|
68
|
+
verdict,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Links 3 and 4 of a corpus check, shared by every kind of certified collection:
|
|
73
|
+
* the certificate commits to exactly one `subject.collection/1` whose leaves all
|
|
74
|
+
* carry `leafProfile`, as many as the documents supplied, and each document reproduces its
|
|
75
|
+
* leaf and the leaves fold to the signed root.
|
|
76
|
+
*/
|
|
77
|
+
function checkCertifiedCollection(baseCertificate, documents, leafProfile = TEXT_PROFILE) {
|
|
78
|
+
const failures = [];
|
|
79
|
+
// The certified subject.
|
|
80
|
+
const subjects = baseCertificate?.payload?.anchor?.subjects ?? [];
|
|
81
|
+
const collection = subjects.length === 1 ? subjects[0].collection : undefined;
|
|
82
|
+
const leaves = collection?.leaves ?? [];
|
|
83
|
+
const declared = collection ? Number(collection.declared_cardinality) : null;
|
|
84
|
+
if (subjects.length !== 1 || subjects[0].profile !== COLLECTION_PROFILE || !collection) {
|
|
85
|
+
failures.push(`the corpus certificate must commit to exactly one ${COLLECTION_PROFILE} subject ` +
|
|
86
|
+
`(found ${subjects.length} subject(s): ${subjects.map((s) => s.profile).join(", ") || "none"})`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const foreign = leaves.filter((leaf) => leaf.profile !== leafProfile);
|
|
90
|
+
if (foreign.length > 0) {
|
|
91
|
+
failures.push(`every leaf of this collection is ${leafProfile}; ${foreign.length} is/are not ` +
|
|
92
|
+
`(${[...new Set(foreign.map((l) => l.profile))].join(", ")})`);
|
|
93
|
+
}
|
|
94
|
+
if (declared !== leaves.length || declared !== documents.length) {
|
|
95
|
+
failures.push(`cardinality mismatch: the certificate declares ${collection.declared_cardinality} document(s), ` +
|
|
96
|
+
`lists ${leaves.length} leaf/leaves, and ${documents.length} document(s) were supplied`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// The documents themselves.
|
|
100
|
+
// Each leaf is recomputed under the profile it declares, exactly as any verifier
|
|
101
|
+
// recomputes a collection; link 3 has already required that profile.
|
|
102
|
+
const nonceHex = baseCertificate?.payload?.anchor?.nonce_hex;
|
|
103
|
+
const comparable = collection && declared === leaves.length && declared === documents.length;
|
|
104
|
+
if (comparable && typeof nonceHex === "string" && nonceHex.length > 0) {
|
|
105
|
+
const salt = new TextEncoder().encode(nonceHex);
|
|
106
|
+
const recomputed = documents.map((doc, i) => collectionLeafHash(salt, leaves[i].profile, canonicalBytesForSubject(leaves[i].profile, doc.bytes)));
|
|
107
|
+
const mismatched = recomputed.flatMap((hash, i) => (hash === leaves[i].commitment_digest_hex ? [] : [i]));
|
|
108
|
+
for (const i of mismatched) {
|
|
109
|
+
failures.push(`document ${i}${documents[i].path ? ` (${documents[i].path})` : ""} is not the content leaf ${i} certifies`);
|
|
110
|
+
}
|
|
111
|
+
if (mismatched.length === 0 && collectionMerkleRoot(recomputed) !== collection.root) {
|
|
112
|
+
failures.push("the documents do not fold to the collection root the certificate signs");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (collection && (typeof nonceHex !== "string" || nonceHex.length === 0)) {
|
|
116
|
+
failures.push("the corpus certificate carries no anchor nonce_hex, so its collection salt is unknown");
|
|
117
|
+
}
|
|
118
|
+
return { failures, collectionRoot: collection?.root ?? null, declared };
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Establish that a set of files is exactly what one publication certificate of a
|
|
122
|
+
* repository certifies — each file byte for byte, in the order the certificate
|
|
123
|
+
* lists them — without a live CERTCRYPT service and without trusting where the
|
|
124
|
+
* files or the proof came from.
|
|
125
|
+
*
|
|
126
|
+
* The chain of `verifyRulesCorpus` without its commitment link, and with
|
|
127
|
+
* `subject.binary/1` leaves: no verifier carries a commitment for a file, so the
|
|
128
|
+
* anchor is the proof itself; and a file is certified as its exact bytes, with no
|
|
129
|
+
* normalization, so the file that verifies is the file that was published.
|
|
130
|
+
*
|
|
131
|
+
* 1. The proof verifies as an ordinary proof: `INDEPENDENT_VALID` under
|
|
132
|
+
* `config`, for a `rules_version` the configuration supports.
|
|
133
|
+
* 2. Its certificate commits to exactly one `subject.collection/1` whose leaves
|
|
134
|
+
* are all `subject.binary/1`, as many as the files supplied.
|
|
135
|
+
* 3. Each file, salted with the certificate's anchor `nonce_hex`, reproduces its
|
|
136
|
+
* leaf, and the leaves fold to the signed collection root.
|
|
137
|
+
*
|
|
138
|
+
* It establishes that the files existed, exactly so, when the proof settled — not
|
|
139
|
+
* that their content is correct.
|
|
140
|
+
*/
|
|
141
|
+
export function verifyCertifiedFiles(request, files, config) {
|
|
142
|
+
const failures = [];
|
|
143
|
+
const verdict = verify(request, config);
|
|
144
|
+
const { baseCertificate, independenceProof } = loadArtifacts(request);
|
|
145
|
+
const rulesVersion = independenceProof?.rules_version ?? null;
|
|
146
|
+
if (verdict.result_code !== "INDEPENDENT_VALID") {
|
|
147
|
+
failures.push(`the certifying proof does not verify as independent: ${verdict.result_code}` +
|
|
148
|
+
(verdict.failure_reason ? ` — ${verdict.failure_reason}` : ""));
|
|
149
|
+
}
|
|
150
|
+
if (rulesVersion === null || !config.supported_rules_versions.includes(rulesVersion)) {
|
|
151
|
+
failures.push(`the certifying proof was issued under rules_version "${rulesVersion}", which this configuration does not support`);
|
|
152
|
+
}
|
|
153
|
+
const certified = checkCertifiedCollection(baseCertificate, files, BINARY_PROFILE);
|
|
154
|
+
failures.push(...certified.failures.map((f) => f.replace(/^document /, "file ")));
|
|
155
|
+
return {
|
|
156
|
+
valid: failures.length === 0,
|
|
157
|
+
failures,
|
|
158
|
+
rules_version: rulesVersion,
|
|
159
|
+
subtree_root: independenceProof?.subtree_root ?? null,
|
|
160
|
+
collection_root: certified.collectionRoot,
|
|
161
|
+
declared_cardinality: certified.declared,
|
|
162
|
+
verdict,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=verify-corpus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-corpus.js","sourceRoot":"","sources":["../../../core/rules/verify-corpus.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC1F,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAClD,MAAM,YAAY,GAAG,gBAAgB,CAAC;AACtC,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAwB1C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAwB,EACxB,SAAgC,EAChC,MAA0B;IAE1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Y;QAC3B,YAAY,EAAE,iBAAiB,EAAE,YAAY,IAAI,IAAI;QACrD,eAAe,EAAE,SAAS,CAAC,cAAc;QACzC,oBAAoB,EAAE,SAAS,CAAC,QAAQ;QACxC,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IndependenceProof, BaseCertificate, SystemDomainConfig } from "../types/index.js";
|
|
2
|
+
import { ResultBuilder } from "../result/builder.js";
|
|
3
|
+
/**
|
|
4
|
+
* Verify rules-domain selection.
|
|
5
|
+
*
|
|
6
|
+
* Check: RULES_DOMAIN_EXACT
|
|
7
|
+
*
|
|
8
|
+
* Per rules-domain/1:
|
|
9
|
+
* - rules_version must be present and non-empty
|
|
10
|
+
* - rules_version must be in supported_rules_versions
|
|
11
|
+
* - Cross-check with base certificate if it declares rules_version
|
|
12
|
+
* - No fallback, no fuzzy match, no compatible substitution
|
|
13
|
+
*/
|
|
14
|
+
export declare function verifyRulesDomain(proof: IndependenceProof, baseCert: BaseCertificate, config: SystemDomainConfig, builder: ResultBuilder): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { PENDING_CORPUS_PROOF } from "../config/default.js";
|
|
2
|
+
/**
|
|
3
|
+
* Verify rules-domain selection.
|
|
4
|
+
*
|
|
5
|
+
* Check: RULES_DOMAIN_EXACT
|
|
6
|
+
*
|
|
7
|
+
* Per rules-domain/1:
|
|
8
|
+
* - rules_version must be present and non-empty
|
|
9
|
+
* - rules_version must be in supported_rules_versions
|
|
10
|
+
* - Cross-check with base certificate if it declares rules_version
|
|
11
|
+
* - No fallback, no fuzzy match, no compatible substitution
|
|
12
|
+
*/
|
|
13
|
+
export function verifyRulesDomain(proof, baseCert, config, builder) {
|
|
14
|
+
if (!proof.rules_version || proof.rules_version.length === 0) {
|
|
15
|
+
builder.fail("RULES_DOMAIN_EXACT", "REJECTED", "rules_version is missing or empty in independence_proof");
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Cross-check with base certificate — read from signed payload
|
|
19
|
+
const certRulesVersion = baseCert.payload?.rules_version;
|
|
20
|
+
if (certRulesVersion &&
|
|
21
|
+
certRulesVersion !== proof.rules_version) {
|
|
22
|
+
builder.fail("RULES_DOMAIN_EXACT", "REJECTED", `rules_version mismatch: proof="${proof.rules_version}", payload="${certRulesVersion}"`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!config.supported_rules_versions.includes(proof.rules_version)) {
|
|
26
|
+
builder.fail("RULES_DOMAIN_EXACT", "UNSUPPORTED", `rules_version "${proof.rules_version}" is not supported; supported: ${config.supported_rules_versions.join(", ")}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// The rules domain is selected. Whether this verifier can be trusted to have
|
|
30
|
+
// been built against its authentic text is a separate question, and this is
|
|
31
|
+
// where it is answered.
|
|
32
|
+
//
|
|
33
|
+
// rules-domain/1 §13.3.1 requires a conforming verifier to carry the certified
|
|
34
|
+
// corpus commitment of every rules domain it declares support for. The
|
|
35
|
+
// parameters below are compiled in and never read from the published corpus at
|
|
36
|
+
// evaluation time, so this value is what lets a third party confirm those
|
|
37
|
+
// parameters are the ones the published rules text actually states — that this
|
|
38
|
+
// build was not made against an altered registry entry.
|
|
39
|
+
//
|
|
40
|
+
// Declaring support without carrying the commitment is non-conformance, not a
|
|
41
|
+
// gap to tolerate: absence MUST NOT be read as permission.
|
|
42
|
+
// The pending-corpus-proof marker is a declared absence, not a commitment: a non-empty
|
|
43
|
+
// string that commits to nothing. Accepting it would let a build vouch for a
|
|
44
|
+
// rules text no certified corpus backs, which is a fail-open.
|
|
45
|
+
const corpusCommitment = config.rules_corpus_roots?.[proof.rules_version];
|
|
46
|
+
if (typeof corpusCommitment !== "string" ||
|
|
47
|
+
corpusCommitment.length === 0 ||
|
|
48
|
+
corpusCommitment === PENDING_CORPUS_PROOF) {
|
|
49
|
+
builder.fail("RULES_CORPUS_COMMITMENT_PRESENT", "REJECTED", (corpusCommitment === PENDING_CORPUS_PROOF
|
|
50
|
+
? `the corpus commitment for rules_version "${proof.rules_version}" is ` +
|
|
51
|
+
"still the pending-corpus-proof marker: its rules text has not been certified yet. A "
|
|
52
|
+
: `no corpus commitment for rules_version "${proof.rules_version}". A `) +
|
|
53
|
+
"conforming verifier carries the certified corpus commitment of every " +
|
|
54
|
+
"rules domain it supports (rules-domain/1 §13.3.1); without it, this " +
|
|
55
|
+
"build cannot be shown to have been made against the authentic rules text");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
builder.pass("RULES_CORPUS_COMMITMENT_PRESENT");
|
|
59
|
+
builder.pass("RULES_DOMAIN_EXACT");
|
|
60
|
+
builder.addDiagnostic("info", `rules_version=${proof.rules_version}`, "RULES_DOMAIN_EXACT");
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=verify-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-rules.js","sourceRoot":"","sources":["../../../core/rules/verify-rules.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,KAAwB,EACxB,QAAyB,EACzB,MAA0B,EAC1B,OAAsB;IAEtB,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,OAAO,CAAC,IAAI,CACV,oBAAoB,EACpB,UAAU,EACV,yDAAyD,CAC1D,CAAC;QACF,OAAO;IACT,CAAC;IAED,+DAA+D;IAC/D,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IACzD,IACE,gBAAgB;QAChB,gBAAgB,KAAK,KAAK,CAAC,aAAa,EACxC,CAAC;QACD,OAAO,CAAC,IAAI,CACV,oBAAoB,EACpB,UAAU,EACV,kCAAkC,KAAK,CAAC,aAAa,eAAe,gBAA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ACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free JSON Schema validator — just enough of Draft 2020-12
|
|
3
|
+
* to gate the VerifierResult against the frozen normative schema at
|
|
4
|
+
* `certcrypt-conformance/schemas/output/verifier-result.schema.json` on every
|
|
5
|
+
* `npm test`, WITHOUT adding a JSON-schema engine (ajv, etc.) to a toolkit
|
|
6
|
+
* that keeps its runtime dependencies to the audited @noble primitives.
|
|
7
|
+
*
|
|
8
|
+
* Supports exactly the keywords the CERTCRYPT schemas use: `type` (string,
|
|
9
|
+
* boolean, object, array, null, and unions thereof), `enum`, `required`,
|
|
10
|
+
* `properties`, `additionalProperties: false`, `items`, `uniqueItems`. Anything
|
|
11
|
+
* outside that surface throws — so a schema that grows a keyword we don't handle
|
|
12
|
+
* fails loudly rather than validating vacuously. This is a TEST-ONLY helper (it
|
|
13
|
+
* lives under core/testing and is never imported by the verifier itself).
|
|
14
|
+
*/
|
|
15
|
+
type Json = unknown;
|
|
16
|
+
interface Schema {
|
|
17
|
+
type?: string | string[];
|
|
18
|
+
enum?: Json[];
|
|
19
|
+
const?: Json;
|
|
20
|
+
required?: string[];
|
|
21
|
+
properties?: Record<string, Schema>;
|
|
22
|
+
additionalProperties?: boolean;
|
|
23
|
+
items?: Schema;
|
|
24
|
+
uniqueItems?: boolean;
|
|
25
|
+
$schema?: string;
|
|
26
|
+
$id?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function validateAgainstSchema(value: Json, schema: Schema, path?: string): string[];
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free JSON Schema validator — just enough of Draft 2020-12
|
|
3
|
+
* to gate the VerifierResult against the frozen normative schema at
|
|
4
|
+
* `certcrypt-conformance/schemas/output/verifier-result.schema.json` on every
|
|
5
|
+
* `npm test`, WITHOUT adding a JSON-schema engine (ajv, etc.) to a toolkit
|
|
6
|
+
* that keeps its runtime dependencies to the audited @noble primitives.
|
|
7
|
+
*
|
|
8
|
+
* Supports exactly the keywords the CERTCRYPT schemas use: `type` (string,
|
|
9
|
+
* boolean, object, array, null, and unions thereof), `enum`, `required`,
|
|
10
|
+
* `properties`, `additionalProperties: false`, `items`, `uniqueItems`. Anything
|
|
11
|
+
* outside that surface throws — so a schema that grows a keyword we don't handle
|
|
12
|
+
* fails loudly rather than validating vacuously. This is a TEST-ONLY helper (it
|
|
13
|
+
* lives under core/testing and is never imported by the verifier itself).
|
|
14
|
+
*/
|
|
15
|
+
const KNOWN_KEYWORDS = new Set([
|
|
16
|
+
// Constraining keywords — each one is actually enforced below.
|
|
17
|
+
"type", "enum", "const", "required", "properties", "additionalProperties",
|
|
18
|
+
"items", "uniqueItems",
|
|
19
|
+
// Annotations and envelope keys — see the note on the interface above.
|
|
20
|
+
"$schema", "$id", "title", "description",
|
|
21
|
+
]);
|
|
22
|
+
function typeOf(value) {
|
|
23
|
+
if (value === null)
|
|
24
|
+
return "null";
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return "array";
|
|
27
|
+
return typeof value; // "object" | "string" | "boolean" | "number"
|
|
28
|
+
}
|
|
29
|
+
function matchesType(value, type) {
|
|
30
|
+
if (type === "object")
|
|
31
|
+
return typeOf(value) === "object";
|
|
32
|
+
return typeOf(value) === type;
|
|
33
|
+
}
|
|
34
|
+
export function validateAgainstSchema(value, schema, path = "$") {
|
|
35
|
+
const errors = [];
|
|
36
|
+
for (const kw of Object.keys(schema)) {
|
|
37
|
+
if (!KNOWN_KEYWORDS.has(kw)) {
|
|
38
|
+
throw new Error(`validate-against-schema: unsupported keyword "${kw}" at ${path} — ` +
|
|
39
|
+
`extend the validator before relying on it`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (schema.type !== undefined) {
|
|
43
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
44
|
+
if (!types.some((t) => matchesType(value, t))) {
|
|
45
|
+
errors.push(`${path}: expected type ${types.join("|")}, got ${typeOf(value)}`);
|
|
46
|
+
return errors; // type mismatch — deeper checks are meaningless
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (schema.enum !== undefined) {
|
|
50
|
+
if (!schema.enum.some((e) => e === value)) {
|
|
51
|
+
errors.push(`${path}: value ${JSON.stringify(value)} not in enum`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (schema.const !== undefined) {
|
|
55
|
+
if (value !== schema.const) {
|
|
56
|
+
errors.push(`${path}: value ${JSON.stringify(value)} !== const ${JSON.stringify(schema.const)}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (typeOf(value) === "object") {
|
|
60
|
+
const obj = value;
|
|
61
|
+
for (const req of schema.required ?? []) {
|
|
62
|
+
if (!(req in obj))
|
|
63
|
+
errors.push(`${path}: missing required property "${req}"`);
|
|
64
|
+
}
|
|
65
|
+
if (schema.additionalProperties === false && schema.properties) {
|
|
66
|
+
for (const key of Object.keys(obj)) {
|
|
67
|
+
if (!(key in schema.properties)) {
|
|
68
|
+
errors.push(`${path}: additional property "${key}" not allowed`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (schema.properties) {
|
|
73
|
+
for (const [key, sub] of Object.entries(schema.properties)) {
|
|
74
|
+
if (key in obj) {
|
|
75
|
+
errors.push(...validateAgainstSchema(obj[key], sub, `${path}.${key}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (typeOf(value) === "array" && schema.items) {
|
|
81
|
+
const arr = value;
|
|
82
|
+
arr.forEach((item, i) => {
|
|
83
|
+
errors.push(...validateAgainstSchema(item, schema.items, `${path}[${i}]`));
|
|
84
|
+
});
|
|
85
|
+
if (schema.uniqueItems) {
|
|
86
|
+
const seen = new Set(arr.map((x) => JSON.stringify(x)));
|
|
87
|
+
if (seen.size !== arr.length)
|
|
88
|
+
errors.push(`${path}: items are not unique`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return errors;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=validate-against-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-against-schema.js","sourceRoot":"","sources":["../../../core/testing/validate-against-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAyBH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,sBAAsB;IACzE,OAAO,EAAE,aAAa;IACtB,uEAAuE;IACvE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa;CACzC,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,KAAW;IACzB,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC;IACzC,OAAO,OAAO,KAAK,CAAC,CAAC,6CAA6C;AACpE,CAAC;AAED,SAAS,WAAW,CAAC,KAAW,EAAE,IAAY;IAC5C,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC;IACzD,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,qBAAqB,CACnC,KAAW,EACX,MAAc,EACd,IAAI,GAAG,GAAG;IAEV,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,i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,CAAC,GAAG,qBAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,KAAM,EAAE,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACxD,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,MAAM;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,wBAAwB,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import type { ComponentSignature } from "../crypto/composite.js";
|
|
2
|
+
import type { IndependenceProof } from "./proof.js";
|
|
3
|
+
import type { SettlementMaterial, CommitmentInclusionProof } from "./settlement-material.js";
|
|
4
|
+
import type { SystemFoundation } from "./foundation.js";
|
|
5
|
+
import type { CapacityEvidence } from "./capacity-evidence.js";
|
|
6
|
+
/**
|
|
7
|
+
* A `subject.collection/1` material entry: the ordered list of leaf materials
|
|
8
|
+
* that reconstruct its root, optionally with a copy of the collection
|
|
9
|
+
* descriptor (verifier-toolkit/1).
|
|
10
|
+
*/
|
|
11
|
+
export interface CollectionMaterial {
|
|
12
|
+
/**
|
|
13
|
+
* Optional delivered copy of the collection descriptor. The AUTHORITATIVE descriptor
|
|
14
|
+
* is the one signed in `subjects[i].collection`; when this is present it MUST match
|
|
15
|
+
* it canonically, so a stale copy fails loudly instead of overriding the signed one.
|
|
16
|
+
*/
|
|
17
|
+
collection?: unknown;
|
|
18
|
+
/** Ordered leaf materials, exactly `declared_cardinality` of them. */
|
|
19
|
+
leaves: Uint8Array[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A subject whose canonical digest was computed OUTSIDE this library, incrementally, and
|
|
23
|
+
* whose bytes are therefore not retained.
|
|
24
|
+
*
|
|
25
|
+
* This exists for one reason: a browser cannot hold a multi-gigabyte file in a single
|
|
26
|
+
* `ArrayBuffer`, so the caller streams it, hashes it chunk by chunk, and hands over the
|
|
27
|
+
* digest instead of the bytes. The verdict is identical either way — the commitment is
|
|
28
|
+
* computed from `subject_local_digest_hex`, and that hex string is all this carries.
|
|
29
|
+
*
|
|
30
|
+
* **Valid ONLY for `subject.binary/1`.** That profile alone defines canonical_bytes as the
|
|
31
|
+
* exact input bytes, which makes a chunk-by-chunk digest equal to the whole-buffer digest.
|
|
32
|
+
* Every other profile transforms the material first — `subject.text/1` normalizes line
|
|
33
|
+
* endings, `subject.email/1` unfolds headers, the JSON-object profiles re-serialize the
|
|
34
|
+
* PARSED value under JCS — and none of those transformations is chunk-local. A prehashed
|
|
35
|
+
* entry on any other profile is REJECTED rather than trusted: accepting it would let a
|
|
36
|
+
* caller substitute a digest of the raw bytes for a digest of the canonical bytes, which is
|
|
37
|
+
* a different value, and the mismatch would look like a verification failure of the
|
|
38
|
+
* material rather than a misuse of this type.
|
|
39
|
+
*/
|
|
40
|
+
export interface PrehashedMaterial {
|
|
41
|
+
/**
|
|
42
|
+
* Discriminant. Present so the shape cannot be produced by accident: a caller reaching
|
|
43
|
+
* for this must name it, and `instanceof Uint8Array` checks elsewhere keep working.
|
|
44
|
+
*/
|
|
45
|
+
readonly prehashed: true;
|
|
46
|
+
/** Lowercase hex SHA3-256 of the subject's canonical bytes — for binary/1, of the file. */
|
|
47
|
+
readonly subject_local_digest_hex: string;
|
|
48
|
+
/**
|
|
49
|
+
* Byte length of the material that was hashed. Not used in the commitment; carried so a
|
|
50
|
+
* caller can report what it read, and so a zero-length stream is distinguishable from an
|
|
51
|
+
* unread one.
|
|
52
|
+
*/
|
|
53
|
+
readonly byte_length?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A `subject.ai-decision/1` material entry that also carries any disclosed input
|
|
57
|
+
* or output parts, keyed by the id that is unique within the matched record.
|
|
58
|
+
*
|
|
59
|
+
* The record is compared against the certificate before `materials` is inspected.
|
|
60
|
+
* Each delivered part is canonicalized under the profile declared by the matched
|
|
61
|
+
* record. A binary part may instead carry a verifier-local streamed digest.
|
|
62
|
+
*/
|
|
63
|
+
export interface AiDecisionMaterial {
|
|
64
|
+
record: Uint8Array;
|
|
65
|
+
materials: Map<string, Uint8Array | PrehashedMaterial>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Verifier-local subject-material map: zero-based subject index → that subject's
|
|
69
|
+
* material. A collection subject maps to `CollectionMaterial`; an AI-decision subject
|
|
70
|
+
* maps to its record bytes or to an `AiDecisionMaterial`; any other profile maps to its
|
|
71
|
+
* raw bytes, or to a `PrehashedMaterial` when the caller streamed it.
|
|
72
|
+
* Verifier-local apparatus — never published.
|
|
73
|
+
*/
|
|
74
|
+
export type SubjectMaterialMap = Map<number, Uint8Array | CollectionMaterial | PrehashedMaterial | AiDecisionMaterial>;
|
|
75
|
+
/**
|
|
76
|
+
* CCSP/1-conformant base certificate model.
|
|
77
|
+
*
|
|
78
|
+
* Per CCSP/1: payload is the sole carrier of normative semantics.
|
|
79
|
+
* Normative cross-artifact fields (system_id, rules_version) live inside the
|
|
80
|
+
* signed payload. Under the leaf=subtree hybrid binding the leaf-bound value
|
|
81
|
+
* is NOT carried in the cert (the link is SHA3(cert)==certificate_commitment_
|
|
82
|
+
* digest + commitment_id∈subtree_root, verified in the Independent path).
|
|
83
|
+
* PQC dual-sign uses a second entry in signatures[], not top-level fields.
|
|
84
|
+
*/
|
|
85
|
+
export interface BaseCertificate {
|
|
86
|
+
schema?: string;
|
|
87
|
+
metadata?: Record<string, unknown>;
|
|
88
|
+
payload: CertificatePayload;
|
|
89
|
+
signatures: CertificateSignature[];
|
|
90
|
+
payload_canon_digest_hex?: string;
|
|
91
|
+
extensions?: Record<string, unknown>;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* CCSP/1 payload — the signed content.
|
|
96
|
+
* Per CCSP/1 and CCCP/1.
|
|
97
|
+
*/
|
|
98
|
+
export interface CertificatePayload {
|
|
99
|
+
anchor: CertificateAnchor;
|
|
100
|
+
/** CCCP/1: SHA3-256(ASCII(nonce_hex) || ASCII(SHA3-256(JCS(anchor)))) */
|
|
101
|
+
anchor_commitment_digest_hex?: string;
|
|
102
|
+
/** Normative system identity — MUST be inside signed payload */
|
|
103
|
+
system_id?: string;
|
|
104
|
+
/** Normative rules version — MUST be inside signed payload */
|
|
105
|
+
rules_version?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* CCSP/1 anchor — issuance anchor object.
|
|
110
|
+
* Per CCSP/1.
|
|
111
|
+
*/
|
|
112
|
+
export interface CertificateAnchor {
|
|
113
|
+
/** RFC 3339 UTC timestamp */
|
|
114
|
+
issued_at: string;
|
|
115
|
+
/** Lowercase hex, 64 chars, per-certificate CSPRNG nonce */
|
|
116
|
+
nonce_hex: string;
|
|
117
|
+
/** Array of subject commitment objects */
|
|
118
|
+
subjects: SubjectCommitment[];
|
|
119
|
+
/** Optional issuance-time root participation reference */
|
|
120
|
+
root_id?: string;
|
|
121
|
+
[key: string]: unknown;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* CCSP/1 subject commitment entry.
|
|
125
|
+
* Per CCSP/1.
|
|
126
|
+
*/
|
|
127
|
+
export interface SubjectCommitment {
|
|
128
|
+
profile: string;
|
|
129
|
+
commitment_digest_hex: string;
|
|
130
|
+
/**
|
|
131
|
+
* `subject.collection/1` only: the signed collection descriptor. CCSP/1 §7.3.2 permits
|
|
132
|
+
* additional members whose meaning a referenced normative spec defines; this is that
|
|
133
|
+
* case. It rides inside the subject so each leaf's profile enters the signature —
|
|
134
|
+
* the profile decides how a leaf canonicalizes, so an unsigned one would be forgeable.
|
|
135
|
+
*/
|
|
136
|
+
collection?: CollectionDescriptor;
|
|
137
|
+
}
|
|
138
|
+
/** The signed `subject.collection/1` descriptor — four members (§7). */
|
|
139
|
+
export interface CollectionDescriptor {
|
|
140
|
+
commitment_scheme: string;
|
|
141
|
+
root: string;
|
|
142
|
+
declared_cardinality: string;
|
|
143
|
+
/** Ordered; the position IS the leaf index. Each entry declares its own profile (§7.4). */
|
|
144
|
+
leaves: {
|
|
145
|
+
profile: string;
|
|
146
|
+
commitment_digest_hex: string;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* CCSP/1 signature entry — composite (CERTCRYPT Composite Signature Profile), canonical profile P-256 + ML-DSA.
|
|
151
|
+
*
|
|
152
|
+
* The issuer signature is a single composite entry (`alg` =
|
|
153
|
+
* "certcrypt-composite-p256-mldsa65-v1") carrying its ordered component
|
|
154
|
+
* signatures (classical first, ML-DSA second) in `signatures[]`. All sign the
|
|
155
|
+
* same domain-separated M' (see crypto/composite.ts); verification is AND. The
|
|
156
|
+
* composite is the one normative emission signature — there is no standalone
|
|
157
|
+
* classical or ML-DSA-65 issuer entry.
|
|
158
|
+
*/
|
|
159
|
+
export interface CertificateSignature {
|
|
160
|
+
role: string;
|
|
161
|
+
sig_target: string;
|
|
162
|
+
/** Composite profile id, e.g. "certcrypt-composite-p256-mldsa65-v1". */
|
|
163
|
+
alg: string;
|
|
164
|
+
/** Composite mode (always "AND"). */
|
|
165
|
+
mode: string;
|
|
166
|
+
/** Ordered component signatures (classical first, ML-DSA second). */
|
|
167
|
+
signatures: ComponentSignature[];
|
|
168
|
+
signer: {
|
|
169
|
+
id: string;
|
|
170
|
+
/** ECDSA P-256 component public key (SEC1, base64). */
|
|
171
|
+
pub_p256_b64: string;
|
|
172
|
+
/** ML-DSA-65 component public key (base64). */
|
|
173
|
+
pub_mldsa_b64: string;
|
|
174
|
+
};
|
|
175
|
+
kid?: string;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A `verification_package` (verification-package/1 §22.1): one JSON object with
|
|
179
|
+
* a closed member set. Original material is never a member (§10).
|
|
180
|
+
*/
|
|
181
|
+
export interface VerificationPackage {
|
|
182
|
+
base_certificate: BaseCertificate;
|
|
183
|
+
verification_context: {
|
|
184
|
+
rules_version: string;
|
|
185
|
+
system_id: string;
|
|
186
|
+
};
|
|
187
|
+
independence_proof?: IndependenceProof;
|
|
188
|
+
capacity_evidence?: CapacityEvidence;
|
|
189
|
+
commitment_inclusion_proof?: CommitmentInclusionProof;
|
|
190
|
+
settlement_material?: SettlementMaterial;
|
|
191
|
+
settlement_reference?: string;
|
|
192
|
+
}
|
|
193
|
+
export interface LoadedArtifacts {
|
|
194
|
+
baseCertificate: BaseCertificate | null;
|
|
195
|
+
independenceProof: IndependenceProof | null;
|
|
196
|
+
settlementMaterial: SettlementMaterial | null;
|
|
197
|
+
/**
|
|
198
|
+
* Zero-data capacity evidence for the certificate under verification. The
|
|
199
|
+
* verifier runs the capacity proof for itself (`verifyCapacityEvidence`) and
|
|
200
|
+
* binds it to the consumed commitment by requiring its digest to equal that
|
|
201
|
+
* commitment's `commitment_id` (`capacity.evidence/1`).
|
|
202
|
+
*/
|
|
203
|
+
capacityEvidence: CapacityEvidence | null;
|
|
204
|
+
/**
|
|
205
|
+
* Per-commitment inclusion proof (`commitment → subtree_root`) for the
|
|
206
|
+
* certificate under verification (leaf=subtree). Consumed by the hybrid
|
|
207
|
+
* emission binding (LEAF_BINDING_VALID step 2). Null when not supplied, which
|
|
208
|
+
* leaves an Independent verification INCOMPLETE.
|
|
209
|
+
*/
|
|
210
|
+
commitmentInclusionProof: CommitmentInclusionProof | null;
|
|
211
|
+
verificationPackage: VerificationPackage | null;
|
|
212
|
+
originalMaterialPath: string | null;
|
|
213
|
+
/**
|
|
214
|
+
* Verifier-local subject-material map (verifier-toolkit/1): zero-based
|
|
215
|
+
* subject index → that subject's material. For a `subject.collection/1`
|
|
216
|
+
* subject the value is `{ leaves[], collection? }` (the ordered leaf materials,
|
|
217
|
+
* optionally with a copy of the signed descriptor); for any other profile it is
|
|
218
|
+
* the subject's raw bytes, a `PrehashedMaterial` or an `AiDecisionMaterial`. Loaded by the input layer from `originalMaterialPath`
|
|
219
|
+
* (or supplied directly). Null when no original material is provided — the
|
|
220
|
+
* complete-verification plane is then simply not performed.
|
|
221
|
+
*/
|
|
222
|
+
originalMaterial: SubjectMaterialMap | null;
|
|
223
|
+
systemFoundation: SystemFoundation | null;
|
|
224
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../core/types/artifacts.ts"],"names":[],"mappings":""}
|