@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.

Files changed (221) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/LICENSE +178 -0
  3. package/README.md +563 -2
  4. package/SECURITY.md +77 -0
  5. package/dist/cli/certcrypt-verify.d.ts +2 -0
  6. package/dist/cli/certcrypt-verify.js +174 -0
  7. package/dist/cli/certcrypt-verify.js.map +1 -0
  8. package/dist/core/config/certcrypt-foundation.d.ts +13 -0
  9. package/dist/core/config/certcrypt-foundation.js +123 -0
  10. package/dist/core/config/certcrypt-foundation.js.map +1 -0
  11. package/dist/core/config/default.d.ts +47 -0
  12. package/dist/core/config/default.js +93 -0
  13. package/dist/core/config/default.js.map +1 -0
  14. package/dist/core/config/test-keys.d.ts +40 -0
  15. package/dist/core/config/test-keys.js +41 -0
  16. package/dist/core/config/test-keys.js.map +1 -0
  17. package/dist/core/conformance/attestation.d.ts +4 -0
  18. package/dist/core/conformance/attestation.js +4 -0
  19. package/dist/core/conformance/attestation.js.map +1 -0
  20. package/dist/core/consistency/verify-consistency.d.ts +92 -0
  21. package/dist/core/consistency/verify-consistency.js +353 -0
  22. package/dist/core/consistency/verify-consistency.js.map +1 -0
  23. package/dist/core/crypto/canonical-json.d.ts +14 -0
  24. package/dist/core/crypto/canonical-json.js +13 -0
  25. package/dist/core/crypto/canonical-json.js.map +1 -0
  26. package/dist/core/crypto/canonical-subject.d.ts +76 -0
  27. package/dist/core/crypto/canonical-subject.js +248 -0
  28. package/dist/core/crypto/canonical-subject.js.map +1 -0
  29. package/dist/core/crypto/collection-merkle.d.ts +91 -0
  30. package/dist/core/crypto/collection-merkle.js +243 -0
  31. package/dist/core/crypto/collection-merkle.js.map +1 -0
  32. package/dist/core/crypto/composite.d.ts +73 -0
  33. package/dist/core/crypto/composite.js +206 -0
  34. package/dist/core/crypto/composite.js.map +1 -0
  35. package/dist/core/crypto/digest.d.ts +18 -0
  36. package/dist/core/crypto/digest.js +37 -0
  37. package/dist/core/crypto/digest.js.map +1 -0
  38. package/dist/core/crypto/ecdsa-p256.d.ts +12 -0
  39. package/dist/core/crypto/ecdsa-p256.js +70 -0
  40. package/dist/core/crypto/ecdsa-p256.js.map +1 -0
  41. package/dist/core/crypto/ed25519.d.ts +10 -0
  42. package/dist/core/crypto/ed25519.js +28 -0
  43. package/dist/core/crypto/ed25519.js.map +1 -0
  44. package/dist/core/crypto/holder-keyset.d.ts +23 -0
  45. package/dist/core/crypto/holder-keyset.js +64 -0
  46. package/dist/core/crypto/holder-keyset.js.map +1 -0
  47. package/dist/core/crypto/jcs.d.ts +9 -0
  48. package/dist/core/crypto/jcs.js +59 -0
  49. package/dist/core/crypto/jcs.js.map +1 -0
  50. package/dist/core/crypto/merkle.d.ts +34 -0
  51. package/dist/core/crypto/merkle.js +147 -0
  52. package/dist/core/crypto/merkle.js.map +1 -0
  53. package/dist/core/crypto/ml-dsa.d.ts +25 -0
  54. package/dist/core/crypto/ml-dsa.js +104 -0
  55. package/dist/core/crypto/ml-dsa.js.map +1 -0
  56. package/dist/core/crypto/provider/bytes.d.ts +31 -0
  57. package/dist/core/crypto/provider/bytes.js +106 -0
  58. package/dist/core/crypto/provider/bytes.js.map +1 -0
  59. package/dist/core/crypto/provider/index.d.ts +45 -0
  60. package/dist/core/crypto/provider/index.js +60 -0
  61. package/dist/core/crypto/provider/index.js.map +1 -0
  62. package/dist/core/crypto/provider/node.d.ts +2 -0
  63. package/dist/core/crypto/provider/node.js +96 -0
  64. package/dist/core/crypto/provider/node.js.map +1 -0
  65. package/dist/core/crypto/provider/register-node.d.ts +11 -0
  66. package/dist/core/crypto/provider/register-node.js +16 -0
  67. package/dist/core/crypto/provider/register-node.js.map +1 -0
  68. package/dist/core/crypto/provider/types.d.ts +77 -0
  69. package/dist/core/crypto/provider/types.js +16 -0
  70. package/dist/core/crypto/provider/types.js.map +1 -0
  71. package/dist/core/crypto/provider/web.d.ts +2 -0
  72. package/dist/core/crypto/provider/web.js +122 -0
  73. package/dist/core/crypto/provider/web.js.map +1 -0
  74. package/dist/core/crypto/pseudonym.d.ts +25 -0
  75. package/dist/core/crypto/pseudonym.js +37 -0
  76. package/dist/core/crypto/pseudonym.js.map +1 -0
  77. package/dist/core/crypto/subject-json-preconditions.d.ts +47 -0
  78. package/dist/core/crypto/subject-json-preconditions.js +373 -0
  79. package/dist/core/crypto/subject-json-preconditions.js.map +1 -0
  80. package/dist/core/domain/verify-domain.d.ts +13 -0
  81. package/dist/core/domain/verify-domain.js +39 -0
  82. package/dist/core/domain/verify-domain.js.map +1 -0
  83. package/dist/core/foundation/anti-equivocation.d.ts +87 -0
  84. package/dist/core/foundation/anti-equivocation.js +0 -0
  85. package/dist/core/foundation/anti-equivocation.js.map +1 -0
  86. package/dist/core/foundation/verify-foundation.d.ts +36 -0
  87. package/dist/core/foundation/verify-foundation.js +559 -0
  88. package/dist/core/foundation/verify-foundation.js.map +1 -0
  89. package/dist/core/independent/anti-replay.d.ts +15 -0
  90. package/dist/core/independent/anti-replay.js +27 -0
  91. package/dist/core/independent/anti-replay.js.map +1 -0
  92. package/dist/core/independent/anti-splicing.d.ts +16 -0
  93. package/dist/core/independent/anti-splicing.js +54 -0
  94. package/dist/core/independent/anti-splicing.js.map +1 -0
  95. package/dist/core/independent/capacity-binding.d.ts +26 -0
  96. package/dist/core/independent/capacity-binding.js +57 -0
  97. package/dist/core/independent/capacity-binding.js.map +1 -0
  98. package/dist/core/independent/capacity-evidence.d.ts +38 -0
  99. package/dist/core/independent/capacity-evidence.js +286 -0
  100. package/dist/core/independent/capacity-evidence.js.map +1 -0
  101. package/dist/core/independent/effective-units.d.ts +42 -0
  102. package/dist/core/independent/effective-units.js +147 -0
  103. package/dist/core/independent/effective-units.js.map +1 -0
  104. package/dist/core/independent/issuance-participation.d.ts +13 -0
  105. package/dist/core/independent/issuance-participation.js +24 -0
  106. package/dist/core/independent/issuance-participation.js.map +1 -0
  107. package/dist/core/independent/leaf-binding.d.ts +5 -0
  108. package/dist/core/independent/leaf-binding.js +135 -0
  109. package/dist/core/independent/leaf-binding.js.map +1 -0
  110. package/dist/core/independent/operator-recognition-registry.d.ts +33 -0
  111. package/dist/core/independent/operator-recognition-registry.js +116 -0
  112. package/dist/core/independent/operator-recognition-registry.js.map +1 -0
  113. package/dist/core/independent/proof-structure.d.ts +8 -0
  114. package/dist/core/independent/proof-structure.js +167 -0
  115. package/dist/core/independent/proof-structure.js.map +1 -0
  116. package/dist/core/independent/proof-views.d.ts +26 -0
  117. package/dist/core/independent/proof-views.js +58 -0
  118. package/dist/core/independent/proof-views.js.map +1 -0
  119. package/dist/core/independent/settlement.d.ts +18 -0
  120. package/dist/core/independent/settlement.js +548 -0
  121. package/dist/core/independent/settlement.js.map +1 -0
  122. package/dist/core/independent/verify-independent.d.ts +30 -0
  123. package/dist/core/independent/verify-independent.js +123 -0
  124. package/dist/core/independent/verify-independent.js.map +1 -0
  125. package/dist/core/independent/verify-operator-recognition.d.ts +26 -0
  126. package/dist/core/independent/verify-operator-recognition.js +60 -0
  127. package/dist/core/independent/verify-operator-recognition.js.map +1 -0
  128. package/dist/core/independent/verify-proof-signature.d.ts +20 -0
  129. package/dist/core/independent/verify-proof-signature.js +97 -0
  130. package/dist/core/independent/verify-proof-signature.js.map +1 -0
  131. package/dist/core/input/fs-bridge.d.ts +30 -0
  132. package/dist/core/input/fs-bridge.js +35 -0
  133. package/dist/core/input/fs-bridge.js.map +1 -0
  134. package/dist/core/input/load-artifacts.d.ts +2 -0
  135. package/dist/core/input/load-artifacts.js +80 -0
  136. package/dist/core/input/load-artifacts.js.map +1 -0
  137. package/dist/core/input/load-original-material.d.ts +11 -0
  138. package/dist/core/input/load-original-material.js +126 -0
  139. package/dist/core/input/load-original-material.js.map +1 -0
  140. package/dist/core/input/register-node-fs.d.ts +1 -0
  141. package/dist/core/input/register-node-fs.js +24 -0
  142. package/dist/core/input/register-node-fs.js.map +1 -0
  143. package/dist/core/input/resolve-target.d.ts +16 -0
  144. package/dist/core/input/resolve-target.js +43 -0
  145. package/dist/core/input/resolve-target.js.map +1 -0
  146. package/dist/core/input/strict-json.d.ts +25 -0
  147. package/dist/core/input/strict-json.js +167 -0
  148. package/dist/core/input/strict-json.js.map +1 -0
  149. package/dist/core/input/validate.d.ts +7 -0
  150. package/dist/core/input/validate.js +83 -0
  151. package/dist/core/input/validate.js.map +1 -0
  152. package/dist/core/issued/verify-collection-element.d.ts +66 -0
  153. package/dist/core/issued/verify-collection-element.js +137 -0
  154. package/dist/core/issued/verify-collection-element.js.map +1 -0
  155. package/dist/core/issued/verify-issued.d.ts +15 -0
  156. package/dist/core/issued/verify-issued.js +361 -0
  157. package/dist/core/issued/verify-issued.js.map +1 -0
  158. package/dist/core/issued/verify-original-material.d.ts +35 -0
  159. package/dist/core/issued/verify-original-material.js +418 -0
  160. package/dist/core/issued/verify-original-material.js.map +1 -0
  161. package/dist/core/package/verify-package.d.ts +34 -0
  162. package/dist/core/package/verify-package.js +109 -0
  163. package/dist/core/package/verify-package.js.map +1 -0
  164. package/dist/core/public-api.d.ts +178 -0
  165. package/dist/core/public-api.js +182 -0
  166. package/dist/core/public-api.js.map +1 -0
  167. package/dist/core/result/builder.d.ts +92 -0
  168. package/dist/core/result/builder.js +408 -0
  169. package/dist/core/result/builder.js.map +1 -0
  170. package/dist/core/rules/verify-corpus.d.ts +88 -0
  171. package/dist/core/rules/verify-corpus.js +165 -0
  172. package/dist/core/rules/verify-corpus.js.map +1 -0
  173. package/dist/core/rules/verify-rules.d.ts +14 -0
  174. package/dist/core/rules/verify-rules.js +62 -0
  175. package/dist/core/rules/verify-rules.js.map +1 -0
  176. package/dist/core/testing/validate-against-schema.d.ts +31 -0
  177. package/dist/core/testing/validate-against-schema.js +93 -0
  178. package/dist/core/testing/validate-against-schema.js.map +1 -0
  179. package/dist/core/types/artifacts.d.ts +224 -0
  180. package/dist/core/types/artifacts.js +2 -0
  181. package/dist/core/types/artifacts.js.map +1 -0
  182. package/dist/core/types/capacity-evidence.d.ts +85 -0
  183. package/dist/core/types/capacity-evidence.js +51 -0
  184. package/dist/core/types/capacity-evidence.js.map +1 -0
  185. package/dist/core/types/check.d.ts +61 -0
  186. package/dist/core/types/check.js +2 -0
  187. package/dist/core/types/check.js.map +1 -0
  188. package/dist/core/types/config.d.ts +97 -0
  189. package/dist/core/types/config.js +2 -0
  190. package/dist/core/types/config.js.map +1 -0
  191. package/dist/core/types/foundation.d.ts +121 -0
  192. package/dist/core/types/foundation.js +25 -0
  193. package/dist/core/types/foundation.js.map +1 -0
  194. package/dist/core/types/index.d.ts +9 -0
  195. package/dist/core/types/index.js +2 -0
  196. package/dist/core/types/index.js.map +1 -0
  197. package/dist/core/types/operator-recognition.d.ts +71 -0
  198. package/dist/core/types/operator-recognition.js +24 -0
  199. package/dist/core/types/operator-recognition.js.map +1 -0
  200. package/dist/core/types/proof.d.ts +94 -0
  201. package/dist/core/types/proof.js +2 -0
  202. package/dist/core/types/proof.js.map +1 -0
  203. package/dist/core/types/request.d.ts +59 -0
  204. package/dist/core/types/request.js +2 -0
  205. package/dist/core/types/request.js.map +1 -0
  206. package/dist/core/types/result.d.ts +164 -0
  207. package/dist/core/types/result.js +2 -0
  208. package/dist/core/types/result.js.map +1 -0
  209. package/dist/core/types/settlement-material.d.ts +130 -0
  210. package/dist/core/types/settlement-material.js +2 -0
  211. package/dist/core/types/settlement-material.js.map +1 -0
  212. package/dist/core/verify-node.d.ts +14 -0
  213. package/dist/core/verify-node.js +17 -0
  214. package/dist/core/verify-node.js.map +1 -0
  215. package/dist/core/verify-web.d.ts +1 -0
  216. package/dist/core/verify-web.js +25 -0
  217. package/dist/core/verify-web.js.map +1 -0
  218. package/dist/core/verify.d.ts +18 -0
  219. package/dist/core/verify.js +183 -0
  220. package/dist/core/verify.js.map +1 -0
  221. package/package.json +71 -4
@@ -0,0 +1,408 @@
1
+ import { SUBJECT_COLLECTION } from "../crypto/canonical-subject.js";
2
+ const ISSUED_REQUIRED_CHECKS = [
3
+ "INPUT_TARGET_SUPPORTED",
4
+ "INPUT_MODE_SUPPORTED",
5
+ "INPUT_COMBINATION_VALID",
6
+ "BASE_CERTIFICATE_PRESENT",
7
+ "BASE_CERTIFICATE_STRUCTURE_VALID",
8
+ "BASE_CERTIFICATE_AUTHENTIC",
9
+ ];
10
+ const INDEPENDENT_REQUIRED_CHECKS = [
11
+ ...ISSUED_REQUIRED_CHECKS,
12
+ "PROOF_PRESENT",
13
+ "PROOF_VERSION_SUPPORTED",
14
+ "PROOF_STRUCTURE_VALID",
15
+ "RULES_DOMAIN_EXACT",
16
+ "SYSTEM_DOMAIN_EXACT",
17
+ "SYSTEM_ROOT_BINDING_VALID",
18
+ "LEAF_BINDING_VALID",
19
+ "SETTLEMENT_REF_VALID",
20
+ "FINALITY_SUFFICIENT",
21
+ "CAPACITY_BINDING_VALID",
22
+ "CAPACITY_NOT_RECONSTRUCTED",
23
+ "EFFECTIVE_UNITS_BINDING_VALID",
24
+ "INCLUSION_PROOF_VALID",
25
+ "AGGREGATED_INTERPRETATION_UNIQUE",
26
+ "ISSUANCE_PARTICIPATION_VALID",
27
+ // Mandatory under every rules domain (independence.proof/1 §10.13).
28
+ "PROOF_SIGNATURE_VALID",
29
+ "NON_REPLAY_VALID",
30
+ "ANTI_SPLICING_VALID",
31
+ "CLONE_OR_FORK_REJECTED",
32
+ ];
33
+ /** Classification priority: higher index = higher priority for final result */
34
+ const CLASSIFICATION_PRIORITY = [
35
+ "ISSUED_VALID",
36
+ "INDEPENDENT_VALID",
37
+ "INDEPENDENT_INVALID",
38
+ "ISSUED_INVALID",
39
+ "UNSUPPORTED",
40
+ "INCOMPLETE",
41
+ "REJECTED",
42
+ ];
43
+ export class ResultBuilder {
44
+ request;
45
+ resolvedTarget = null;
46
+ checks = [];
47
+ missingArtifacts = [];
48
+ diagnosticsList = [];
49
+ earlyExit = false;
50
+ _productionVerification = true;
51
+ // Structural lineage — populated by settlement verification
52
+ _settlementProfileId = null;
53
+ _subtreeRoot = null;
54
+ _settlementRef = null;
55
+ _batchRoot = null;
56
+ _batchIndex = null;
57
+ _batchSize = null;
58
+ // Foundation lineage — populated by foundation verification
59
+ _foundationProfileId = null;
60
+ _foundationStatementId = null;
61
+ _foundationPublicationRef = null;
62
+ // Node attestation of the proof, recorded once PROOF_SIGNATURE_VALID passed.
63
+ _attestedNode = null;
64
+ // Per-subject verdict scope — populated once the base certificate is parsed.
65
+ _subjectScope = null;
66
+ // ML-DSA-65 component outcome (normative, attributed to BASE_CERTIFICATE_AUTHENTIC),
67
+ // surfaced separately — populated by verify-issued whenever the composite runs
68
+ _pqcResult = {
69
+ performed: false,
70
+ algorithm: "ML-DSA-65",
71
+ passed: null,
72
+ reason: "not_attempted",
73
+ };
74
+ // Original-material (complete verification) plane — opt-in. Stays
75
+ // performed=false until verify-original-material actually runs the comparison
76
+ // (i.e. material was delivered); then it reflects the real outcome so a caller
77
+ // can tell "material verified" from "material not supplied / not performed".
78
+ _completeMaterialPerformed = false;
79
+ _completeMaterialPassed = false;
80
+ constructor(request) {
81
+ this.request = request;
82
+ }
83
+ setResolvedTarget(target) {
84
+ this.resolvedTarget = target;
85
+ }
86
+ /** Record the proof's node attestation; reported only on INDEPENDENT_VALID. */
87
+ setAttestedNode(attestation) {
88
+ this._attestedNode = attestation
89
+ ? { node_id: attestation.node_id, recognized_at: attestation.recognized_at }
90
+ : null;
91
+ }
92
+ setLineage(lineage) {
93
+ if (lineage.settlement_profile_id)
94
+ this._settlementProfileId = lineage.settlement_profile_id;
95
+ if (lineage.subtree_root)
96
+ this._subtreeRoot = lineage.subtree_root;
97
+ if (lineage.settlement_ref)
98
+ this._settlementRef = lineage.settlement_ref;
99
+ if (lineage.batch_root)
100
+ this._batchRoot = lineage.batch_root;
101
+ if (lineage.batch_index !== undefined)
102
+ this._batchIndex = lineage.batch_index;
103
+ if (lineage.batch_size)
104
+ this._batchSize = lineage.batch_size;
105
+ }
106
+ setFoundationLineage(lineage) {
107
+ if (lineage.foundation_profile_id)
108
+ this._foundationProfileId = lineage.foundation_profile_id;
109
+ if (lineage.foundation_statement_id)
110
+ this._foundationStatementId = lineage.foundation_statement_id;
111
+ if (lineage.foundation_publication_ref)
112
+ this._foundationPublicationRef = lineage.foundation_publication_ref;
113
+ }
114
+ setPqcResult(result) {
115
+ this._pqcResult = result;
116
+ }
117
+ /**
118
+ * Record the per-subject verdict scope from the base certificate's anchor
119
+ * subjects, in order. Only `subject.collection/1` declares its elements
120
+ * (`opaque: false`); every other profile is a single opaque subject whose
121
+ * internal contents the proof does NOT cover. Called once the base certificate
122
+ * is parsed. Makes an `INDEPENDENT_VALID` over an opaque subject (e.g. a ZIP as
123
+ * `subject.binary/1`) distinguishable, in the result, from one over a declared
124
+ * collection — closing the "container covers its children" over-read.
125
+ */
126
+ setSubjectScope(subjectProfiles) {
127
+ this._subjectScope = subjectProfiles.map((profile) => ({
128
+ profile,
129
+ opaque: profile !== SUBJECT_COLLECTION,
130
+ }));
131
+ }
132
+ /** Record that the complete-verification-against-material plane ran, and
133
+ * its outcome. Called by verify-original-material when material is delivered. */
134
+ setCompleteMaterialResult(performed, passed) {
135
+ this._completeMaterialPerformed = performed;
136
+ this._completeMaterialPassed = passed;
137
+ }
138
+ addCheck(result) {
139
+ this.checks.push(result);
140
+ }
141
+ pass(checkId, message) {
142
+ this.checks.push({ check_id: checkId, passed: true, message });
143
+ }
144
+ fail(checkId, classification, message) {
145
+ this.checks.push({
146
+ check_id: checkId,
147
+ passed: false,
148
+ failure_classification: classification,
149
+ message,
150
+ });
151
+ this.addDiagnostic("error", message ?? `Check ${checkId} failed`, checkId);
152
+ }
153
+ addMissingArtifact(artifactName) {
154
+ if (!this.missingArtifacts.includes(artifactName)) {
155
+ this.missingArtifacts.push(artifactName);
156
+ }
157
+ }
158
+ addDiagnostic(level, message, checkId) {
159
+ this.diagnosticsList.push({
160
+ level,
161
+ message,
162
+ check_id: checkId ?? null,
163
+ });
164
+ }
165
+ hasFailure() {
166
+ return this.checks.some((c) => !c.passed);
167
+ }
168
+ /** True when the named check has run and failed. */
169
+ hasFailed(checkId) {
170
+ return this.checks.some((c) => c.check_id === checkId && !c.passed);
171
+ }
172
+ /**
173
+ * Returns the current check count. Used to create a checkpoint so that
174
+ * downstream logic can detect failures added after a certain point
175
+ * without being affected by earlier failures (e.g., Issued UNSUPPORTED
176
+ * should not prevent Independent checks from running).
177
+ */
178
+ checkpoint() {
179
+ return this.checks.length;
180
+ }
181
+ /**
182
+ * Returns true if any check added after the given checkpoint failed.
183
+ */
184
+ hasFailureSince(checkpoint) {
185
+ return this.checks.slice(checkpoint).some((c) => !c.passed);
186
+ }
187
+ markEarlyExit() {
188
+ this.earlyExit = true;
189
+ }
190
+ /**
191
+ * Mark that verification ran under a configuration other than the published
192
+ * production profile. Surfaced as `production_verification: false` so a
193
+ * *_VALID result cannot be mistaken for a verdict about the production domain.
194
+ */
195
+ markNonProductionVerification() {
196
+ this._productionVerification = false;
197
+ }
198
+ build() {
199
+ // Before the target is resolved (an input that fails first) the result
200
+ // reports the target the request named: a request for `independent` that
201
+ // is refused at the input is not an Issued verification. `auto` names no
202
+ // route yet, and reports Issued, the route that claims less.
203
+ const target = this.resolvedTarget ??
204
+ (this.request.verification_target_requested === "independent" ? "Independent" : "Issued");
205
+ const failedChecks = this.checks.filter((c) => !c.passed);
206
+ const failedCheckIds = failedChecks.map((c) => c.check_id);
207
+ // Determine result code
208
+ let resultCode;
209
+ if (failedChecks.length === 0 && !this.earlyExit) {
210
+ // Check that all required checks for this target were actually executed
211
+ const requiredChecks = [
212
+ ...(target === "Independent"
213
+ ? this.requiredIndependentChecks()
214
+ : ISSUED_REQUIRED_CHECKS),
215
+ // A package is read only after its structure and its declarations were
216
+ // checked (verifier-toolkit/1 §11.1, §11.2 steps 1–2).
217
+ ...(this.request.input_mode === "package"
218
+ ? ["PACKAGE_STRUCTURE_VALID", "PACKAGE_CONTEXT_COHERENT"]
219
+ : []),
220
+ ];
221
+ const executedCheckIds = new Set(this.checks.map((c) => c.check_id));
222
+ const missingRequired = requiredChecks.filter((id) => !executedCheckIds.has(id));
223
+ if (missingRequired.length > 0) {
224
+ // Fail-closed: required checks not executed
225
+ resultCode = "INCOMPLETE";
226
+ for (const missing of missingRequired) {
227
+ failedCheckIds.push(missing);
228
+ this.diagnosticsList.push({
229
+ level: "error",
230
+ message: `Required check ${missing} was not executed`,
231
+ check_id: missing,
232
+ });
233
+ }
234
+ }
235
+ else {
236
+ resultCode =
237
+ target === "Independent" ? "INDEPENDENT_VALID" : "ISSUED_VALID";
238
+ }
239
+ }
240
+ else {
241
+ // Find highest-priority failure classification
242
+ resultCode = this.deriveFailureCode(failedChecks, target);
243
+ }
244
+ // Derive per-axis booleans
245
+ const passedIds = new Set(this.checks.filter((c) => c.passed).map((c) => c.check_id));
246
+ const failedIds = new Set(failedCheckIds);
247
+ const domainValid = passedIds.has("SYSTEM_DOMAIN_EXACT") &&
248
+ passedIds.has("SYSTEM_ROOT_BINDING_VALID") &&
249
+ !failedIds.has("CLONE_OR_FORK_REJECTED");
250
+ const rulesDomainValid = passedIds.has("RULES_DOMAIN_EXACT");
251
+ const issuedValid = passedIds.has("BASE_CERTIFICATE_STRUCTURE_VALID") &&
252
+ passedIds.has("BASE_CERTIFICATE_AUTHENTIC");
253
+ /**
254
+ * The Independent AXIS, derived from its own checks — not copied from
255
+ * `result_code`.
256
+ *
257
+ * These booleans are per-axis by design (see the comment above), and this one
258
+ * is computed from `passedIds` like every other. It does not follow
259
+ * `result_code`: a check outside the axis must not collapse it. Supplying
260
+ * original material for some subjects but not all fails
261
+ * ORIGINAL_MATERIAL_COMPARISON_VALID and makes `result_code` INCOMPLETE, yet
262
+ * ORIGINAL_MATERIAL_COMPARISON_VALID is NOT in INDEPENDENT_REQUIRED_CHECKS
263
+ * (nor in the operational variant): the axis does not depend on material, so
264
+ * adding information never appears to invalidate independence.
265
+ *
266
+ * `result_code` keeps INCOMPLETE in that case, because a
267
+ * comparison WAS requested and could not be finished (`verifier-toolkit/1`
268
+ * §8.5.1 fixes that outcome so toolkits converge). The two answer different
269
+ * questions — "does the independence plane hold?" and "did everything asked for
270
+ * complete?" — and only the second one is affected by partial material.
271
+ *
272
+ * Requires the target to BE Independent: on an Issued-only run the axis was
273
+ * never evaluated, and reporting true would claim a plane nobody checked.
274
+ */
275
+ const independentValid = target === "Independent" &&
276
+ this.requiredIndependentChecks().every((id) => passedIds.has(id) && !failedIds.has(id));
277
+ const proofComplete = passedIds.has("PROOF_PRESENT") &&
278
+ passedIds.has("PROOF_STRUCTURE_VALID") &&
279
+ this.missingArtifacts.length === 0;
280
+ // Extract system info from checks
281
+ const systemId = this.extractSystemId();
282
+ const systemRootIdentifier = this.extractSystemRootIdentifier();
283
+ const rulesVersion = this.extractRulesVersion();
284
+ // Failure reason
285
+ const failureReason = failedChecks.length > 0
286
+ ? failedChecks.map((c) => c.message ?? c.check_id).join("; ")
287
+ : null;
288
+ // Derive certcrypt_lineage from existing checks and fields only
289
+ const certcryptLineage = this.deriveCertcryptLineage(independentValid, domainValid, passedIds, systemId, rulesVersion, systemRootIdentifier);
290
+ return {
291
+ result_code: resultCode,
292
+ verification_target_requested: this.request.verification_target_requested,
293
+ verification_target_resolved: target,
294
+ verification_target: target,
295
+ input_mode: this.request.input_mode,
296
+ production_verification: this._productionVerification,
297
+ domain_valid: domainValid,
298
+ rules_domain_valid: rulesDomainValid,
299
+ issued_valid: issuedValid,
300
+ independent_valid: independentValid,
301
+ proof_complete: proofComplete,
302
+ complete_verification_against_original_material_performed: this._completeMaterialPerformed,
303
+ complete_verification_against_original_material_passed: this._completeMaterialPassed,
304
+ failure_reason: failureReason,
305
+ failed_check_ids: [...new Set(failedCheckIds)],
306
+ required_artifacts_missing: [...this.missingArtifacts],
307
+ applicable_rules_version: rulesVersion,
308
+ system_id: systemId,
309
+ system_root_identifier: systemRootIdentifier,
310
+ settlement_profile_id: this._settlementProfileId,
311
+ subtree_root: this._subtreeRoot,
312
+ settlement_ref: this._settlementRef,
313
+ batch_root: this._batchRoot,
314
+ batch_index: this._batchIndex,
315
+ batch_size: this._batchSize,
316
+ foundation_profile_id: this._foundationProfileId,
317
+ foundation_statement_id: this._foundationStatementId,
318
+ foundation_publication_ref: this._foundationPublicationRef,
319
+ subject_scope: this._subjectScope,
320
+ attested_node: resultCode === "INDEPENDENT_VALID" ? this._attestedNode : null,
321
+ diagnostics: this.diagnosticsList,
322
+ certcrypt_lineage: certcryptLineage,
323
+ additional_verifications: {
324
+ pqc_base_certificate_authentic: this._pqcResult,
325
+ },
326
+ };
327
+ }
328
+ requiredIndependentChecks() {
329
+ return INDEPENDENT_REQUIRED_CHECKS;
330
+ }
331
+ /**
332
+ * Derive certcrypt_lineage block from existing checks and fields.
333
+ * No new verification logic — purely a projection of already-validated state.
334
+ */
335
+ deriveCertcryptLineage(independentValid, domainValid, passedIds, systemId, rulesVersion, systemRootIdentifier) {
336
+ const certcryptDomainBound = domainValid;
337
+ const independenceUnderCertcryptRules = independentValid;
338
+ const settlementBound = passedIds.has("SETTLEMENT_REF_VALID") &&
339
+ passedIds.has("FINALITY_SUFFICIENT") &&
340
+ passedIds.has("INCLUSION_PROOF_VALID") &&
341
+ passedIds.has("AGGREGATED_INTERPRETATION_UNIQUE");
342
+ const capacityConsumptionBound = passedIds.has("CAPACITY_BINDING_VALID") &&
343
+ passedIds.has("CAPACITY_NOT_RECONSTRUCTED");
344
+ const historyBoundUnderCertcrypt = certcryptDomainBound &&
345
+ settlementBound &&
346
+ capacityConsumptionBound &&
347
+ independenceUnderCertcryptRules;
348
+ return {
349
+ certcrypt_domain_bound: certcryptDomainBound,
350
+ independence_under_certcrypt_rules: independenceUnderCertcryptRules,
351
+ settlement_bound: settlementBound,
352
+ capacity_consumption_bound: capacityConsumptionBound,
353
+ history_bound_under_certcrypt: historyBoundUnderCertcrypt,
354
+ system_id: systemId,
355
+ rules_version: rulesVersion,
356
+ system_root_fingerprint: systemRootIdentifier,
357
+ settlement_profile_id: this._settlementProfileId,
358
+ subtree_root: this._subtreeRoot,
359
+ settlement_ref: this._settlementRef,
360
+ foundation_profile_id: this._foundationProfileId,
361
+ foundation_statement_id: this._foundationStatementId,
362
+ };
363
+ }
364
+ deriveFailureCode(failedChecks, target) {
365
+ // Priority (verifier-toolkit/1 §9.5): REJECTED > INCOMPLETE > UNSUPPORTED >
366
+ // ISSUED_INVALID > INDEPENDENT_INVALID
367
+ let highestPriority = -1;
368
+ let highestCode = target === "Independent" ? "INDEPENDENT_INVALID" : "ISSUED_INVALID";
369
+ for (const check of failedChecks) {
370
+ let classification = check.failure_classification ?? highestCode;
371
+ // An Issued verification never reports a code of the Independent route.
372
+ if (target === "Issued" && classification === "INDEPENDENT_INVALID") {
373
+ classification = "ISSUED_INVALID";
374
+ }
375
+ const priority = CLASSIFICATION_PRIORITY.indexOf(classification);
376
+ if (priority > highestPriority) {
377
+ highestPriority = priority;
378
+ highestCode = classification;
379
+ }
380
+ }
381
+ return highestCode;
382
+ }
383
+ extractSystemId() {
384
+ for (const d of this.diagnosticsList) {
385
+ if (d.check_id === "SYSTEM_DOMAIN_EXACT" && d.message.includes("system_id=")) {
386
+ return d.message.split("system_id=")[1]?.split(";")[0] ?? null;
387
+ }
388
+ }
389
+ return null;
390
+ }
391
+ extractSystemRootIdentifier() {
392
+ for (const d of this.diagnosticsList) {
393
+ if (d.check_id === "SYSTEM_ROOT_BINDING_VALID" && d.message.includes("root=")) {
394
+ return d.message.split("root=")[1]?.split(";")[0] ?? null;
395
+ }
396
+ }
397
+ return null;
398
+ }
399
+ extractRulesVersion() {
400
+ for (const d of this.diagnosticsList) {
401
+ if (d.check_id === "RULES_DOMAIN_EXACT" && d.message.includes("rules_version=")) {
402
+ return d.message.split("rules_version=")[1]?.split(";")[0] ?? null;
403
+ }
404
+ }
405
+ return null;
406
+ }
407
+ }
408
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version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K,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YAC5D,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,mBAAmB;QACzB,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACrC,IAAI,CAAC,CAAC,QAAQ,KAAK,oBAAoB,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAChF,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;YACrE,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,88 @@
1
+ import type { SystemDomainConfig, VerifierRequest, VerifierResult } from "../types/index.js";
2
+ /** One document of a rules domain, in the order its corpus proof certifies it. */
3
+ export interface RulesCorpusDocument {
4
+ /** Where the document was read from. Reported, never committed: the leaf binds content and order. */
5
+ path?: string;
6
+ bytes: Uint8Array;
7
+ }
8
+ export interface RulesCorpusResult {
9
+ /** True only when every link of the chain holds. */
10
+ valid: boolean;
11
+ /** One line per broken link, in the order they were checked. Empty when valid. */
12
+ failures: string[];
13
+ rules_version: string | null;
14
+ /** The corpus proof's anchored `subtree_root` — the value a conforming verifier carries. */
15
+ subtree_root: string | null;
16
+ /** The collection root the corpus certificate signs over the documents. */
17
+ collection_root: string | null;
18
+ declared_cardinality: number | null;
19
+ /** The ordinary verdict on the corpus proof itself. */
20
+ verdict: VerifierResult;
21
+ }
22
+ /**
23
+ * Establish that a set of documents is the exact ruleset a corpus proof certifies
24
+ * (`rules-domain/1` §13.3), without a live CERTCRYPT service and without trusting
25
+ * where the documents or the proof came from.
26
+ *
27
+ * The chain, link by link:
28
+ *
29
+ * 1. The corpus proof verifies as an ordinary proof: `INDEPENDENT_VALID` under
30
+ * `config`, for the `rules_version` it certifies.
31
+ * 2. Its anchored `subtree_root` is the commitment `config` carries for that
32
+ * `rules_version`. That pins the one proof: a second emission over the same text
33
+ * has another `subtree_root` and does not pass (§13.3.2; `independence.proof/1`
34
+ * §12.9).
35
+ * 3. Its certificate commits to exactly one `subject.collection/1` whose leaves are
36
+ * all `subject.text/1`, as many as the documents supplied.
37
+ * 4. Each document, canonicalized under `subject.text/1` and salted with the
38
+ * certificate's anchor `nonce_hex` (`subject.collection/1` §8), reproduces its
39
+ * leaf, and the leaves fold to the signed collection root.
40
+ *
41
+ * Link 4 is what binds the text; links 1–2 are what make that binding the one the
42
+ * verifier trusts. Establishing authenticity of the text says nothing about whether
43
+ * the rules are right — only that they are the ones that govern.
44
+ */
45
+ export declare function verifyRulesCorpus(request: VerifierRequest, documents: RulesCorpusDocument[], config: SystemDomainConfig): RulesCorpusResult;
46
+ export interface CertifiedFilesResult {
47
+ /** True only when every link of the chain holds. */
48
+ valid: boolean;
49
+ /** One line per broken link, in the order they were checked. Empty when valid. */
50
+ failures: string[];
51
+ /** The rules version the certifying proof was issued under. */
52
+ rules_version: string | null;
53
+ /** The certifying proof's anchored `subtree_root`. */
54
+ subtree_root: string | null;
55
+ /** The collection root the certificate signs over the files. */
56
+ collection_root: string | null;
57
+ declared_cardinality: number | null;
58
+ /** The ordinary verdict on the certifying proof itself. */
59
+ verdict: VerifierResult;
60
+ }
61
+ export interface CertifiedFile {
62
+ /** The file's path in the repository. Reported, never committed: the leaf binds content and order. */
63
+ path?: string;
64
+ /** The file's exact bytes. */
65
+ bytes: Uint8Array;
66
+ }
67
+ /**
68
+ * Establish that a set of files is exactly what one publication certificate of a
69
+ * repository certifies — each file byte for byte, in the order the certificate
70
+ * lists them — without a live CERTCRYPT service and without trusting where the
71
+ * files or the proof came from.
72
+ *
73
+ * The chain of `verifyRulesCorpus` without its commitment link, and with
74
+ * `subject.binary/1` leaves: no verifier carries a commitment for a file, so the
75
+ * anchor is the proof itself; and a file is certified as its exact bytes, with no
76
+ * normalization, so the file that verifies is the file that was published.
77
+ *
78
+ * 1. The proof verifies as an ordinary proof: `INDEPENDENT_VALID` under
79
+ * `config`, for a `rules_version` the configuration supports.
80
+ * 2. Its certificate commits to exactly one `subject.collection/1` whose leaves
81
+ * are all `subject.binary/1`, as many as the files supplied.
82
+ * 3. Each file, salted with the certificate's anchor `nonce_hex`, reproduces its
83
+ * leaf, and the leaves fold to the signed collection root.
84
+ *
85
+ * It establishes that the files existed, exactly so, when the proof settled — not
86
+ * that their content is correct.
87
+ */
88
+ export declare function verifyCertifiedFiles(request: VerifierRequest, files: CertifiedFile[], config: SystemDomainConfig): CertifiedFilesResult;