@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,147 @@
1
+ import { SUBJECT_COLLECTION } from "../crypto/canonical-subject.js";
2
+ /**
3
+ * EFFECTIVE_UNITS_BINDING_VALID — bind the issuer-declared per-subject economic
4
+ * quantity to the subjects actually certified.
5
+ *
6
+ * Normative rule (capacity.commitment/1, submission-set/1):
7
+ * the effective declared units of a leaf MUST EQUAL the sum of the effective
8
+ * declared units of every certified subject bound into that leaf, where
9
+ * - a `subject.collection/1` subject contributes exactly its `declared_cardinality`, and
10
+ * - any other subject contributes exactly `1`
11
+ * (the default `1` applies even where the subject carries no cardinality field).
12
+ *
13
+ * This check binds declared effective units to the certified subjects;
14
+ * under-declaration is rejected: a base certificate that certifies N subjects
15
+ * while its capacity evidence declares `declared_effective_units = "1"` fails.
16
+ * No server-side actor can check this under the zero-data profile — the
17
+ * submission-set carries evidence digests, not the base certificate or its subjects. The offline verifier is
18
+ * the only actor holding BOTH the subjects (from the base certificate anchor)
19
+ * AND `declared_effective_units` (from the capacity evidence), so the
20
+ * enforcement lives here and is fail-closed (INDEPENDENT_INVALID on mismatch).
21
+ *
22
+ * Cardinality source. A collection subject carries its `subject.collection/1`
23
+ * descriptor inside the signed anchor (`subjects[i].collection`), so its
24
+ * `declared_cardinality` is normally read from there and the exact sum is known
25
+ * offline, with no original material. Only when the signed subject carries no
26
+ * readable descriptor is a descriptor delivered with the original material used
27
+ * instead. So:
28
+ * - every subject contributes a known LOWER BOUND of 1 (collections ≥ 1);
29
+ * - when a collection's `declared_cardinality` resolves (signed descriptor
30
+ * first, delivered material otherwise), that subject's exact contribution
31
+ * is used instead of the lower bound.
32
+ * If the exact sum is fully known (no collections, or all collections resolved)
33
+ * we enforce strict equality. If a collection is present but its cardinality is
34
+ * unresolved, we can still enforce the lower bound (an
35
+ * under-declaration below the subject count is always caught), and we defer the
36
+ * exact-equality assertion with an informational diagnostic rather than
37
+ * asserting an equality we cannot compute.
38
+ */
39
+ export function verifyEffectiveUnitsBinding(baseCertificate, capacityEvidence, originalMaterial, builder) {
40
+ // No capacity evidence means there is no declared_effective_units to bind. A null capacityEvidence never reaches
41
+ // INDEPENDENT_VALID anyway — the leaf-binding, settlement, and capacity-binding
42
+ // steps each fail closed (INCOMPLETE) before build() could pass — so not
43
+ // emitting this check here does not weaken the fail-closed posture.
44
+ if (!capacityEvidence) {
45
+ return;
46
+ }
47
+ const subjects = baseCertificate?.payload?.anchor?.subjects;
48
+ if (!Array.isArray(subjects) || subjects.length === 0) {
49
+ builder.fail("EFFECTIVE_UNITS_BINDING_VALID", "INDEPENDENT_INVALID", "base certificate anchor carries no subjects to bind declared_effective_units to");
50
+ return;
51
+ }
52
+ const declaredStr = capacityEvidence.projected_commitment.declared_effective_units;
53
+ // Canonical unsigned-integer string (submission-set/1: canonical
54
+ // decimal string, never a JSON number).
55
+ if (typeof declaredStr !== "string" || !/^[1-9][0-9]*$/.test(declaredStr)) {
56
+ builder.fail("EFFECTIVE_UNITS_BINDING_VALID", "REJECTED", `declared_effective_units must be a canonical positive integer string, got ${JSON.stringify(declaredStr)}`);
57
+ return;
58
+ }
59
+ const declared = BigInt(declaredStr);
60
+ // Sum the effective units over the anchor subjects. `lowerBound` is what we
61
+ // can prove without material (each subject ≥ 1). `exact` is the true sum,
62
+ // valid only when `exactKnown` stays true (every collection resolved).
63
+ let lowerBound = 0n;
64
+ let exact = 0n;
65
+ let exactKnown = true;
66
+ for (let i = 0; i < subjects.length; i++) {
67
+ const s = subjects[i];
68
+ if (s?.profile === SUBJECT_COLLECTION) {
69
+ lowerBound += 1n; // a collection contributes ≥ 1
70
+ const card = resolveDeclaredCardinality(s, originalMaterial?.get(i));
71
+ if (card === null) {
72
+ // declared_cardinality not available offline without original material.
73
+ exactKnown = false;
74
+ }
75
+ else if (card <= 0n) {
76
+ builder.fail("EFFECTIVE_UNITS_BINDING_VALID", "REJECTED", `subject index ${i}: collection declared_cardinality must be a positive integer`);
77
+ return;
78
+ }
79
+ else {
80
+ exact += card;
81
+ }
82
+ }
83
+ else {
84
+ // capacity.commitment/1: any non-collection subject contributes
85
+ // exactly 1, even if it carries no cardinality field.
86
+ lowerBound += 1n;
87
+ exact += 1n;
88
+ }
89
+ }
90
+ if (exactKnown) {
91
+ if (exact !== declared) {
92
+ builder.fail("EFFECTIVE_UNITS_BINDING_VALID", "INDEPENDENT_INVALID", `declared_effective_units="${declaredStr}" does not equal the sum of ` +
93
+ `per-subject effective units (Σ=${exact.toString()} over ${subjects.length} ` +
94
+ `certified subject(s); capacity.commitment/1)`);
95
+ return;
96
+ }
97
+ builder.pass("EFFECTIVE_UNITS_BINDING_VALID");
98
+ return;
99
+ }
100
+ // Exact sum is unknown because a collection's declared_cardinality was not
101
+ // supplied (no original material). We can still fail closed when the declared
102
+ // value is below the provable lower bound — the under-declaration attack the
103
+ // check exists to stop is always caught.
104
+ if (declared < lowerBound) {
105
+ builder.fail("EFFECTIVE_UNITS_BINDING_VALID", "INDEPENDENT_INVALID", `declared_effective_units="${declaredStr}" is below the minimum ` +
106
+ `${lowerBound.toString()} implied by ${subjects.length} certified subject(s) ` +
107
+ `(each subject contributes ≥ 1; capacity.commitment/1)`);
108
+ return;
109
+ }
110
+ // Lower bound satisfied but exact equality cannot be asserted offline without
111
+ // the collection material. Pass the lower-bound check; note that exact
112
+ // equality was deferred (parallels the opt-in complete-material plane).
113
+ builder.addDiagnostic("info", `EFFECTIVE_UNITS_BINDING_VALID: exact per-subject sum not recomputed — a ` +
114
+ `subject.collection/1 declared_cardinality was not supplied (no original ` +
115
+ `material). Enforced lower bound ${lowerBound.toString()} ≤ declared_effective_units ` +
116
+ `="${declaredStr}"; supply original material to enforce strict equality.`, "EFFECTIVE_UNITS_BINDING_VALID");
117
+ builder.pass("EFFECTIVE_UNITS_BINDING_VALID");
118
+ }
119
+ /**
120
+ * Extract a collection subject's `declared_cardinality` from its signed
121
+ * descriptor or, failing that, from its verifier-local material entry; null when
122
+ * neither carries one.
123
+ * Validates the canonical positive-integer string form (subject.collection/1).
124
+ */
125
+ function resolveDeclaredCardinality(subject, entry) {
126
+ // Preferred source: the descriptor signed inside the subject, which makes the
127
+ // exact sum available offline, with no original material.
128
+ const signed = subject?.collection?.declared_cardinality;
129
+ if (typeof signed === "string" && /^[1-9][0-9]*$/.test(signed)) {
130
+ return BigInt(signed);
131
+ }
132
+ // Otherwise: a descriptor delivered with the original material, if any. A prehashed
133
+ // entry or an AI-decision entry never carries a collection descriptor.
134
+ if (!entry || entry instanceof Uint8Array || "prehashed" in entry || "record" in entry) {
135
+ return null;
136
+ }
137
+ const collection = entry.collection;
138
+ if (typeof collection !== "object" || collection === null) {
139
+ return null;
140
+ }
141
+ const card = collection.declared_cardinality;
142
+ if (typeof card !== "string" || !/^[1-9][0-9]*$/.test(card)) {
143
+ return null;
144
+ }
145
+ return BigInt(card);
146
+ }
147
+ //# sourceMappingURL=effective-units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effective-units.js","sourceRoot":"","sources":["../../../core/independent/effective-units.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,2BAA2B,CACzC,eAAuC,EACvC,gBAAyC,EACzC,gBAA2C,EAC3C,OAAsB;IAEtB,iHAAiH;IACjH,gFAAgF;IAChF,yEAAyE;IACzE,oEAAoE;IACpE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,QAAQ,GAAG,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC5D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtD,OAAO,CAAC,IAAI,CACV,+BAA+B,EAC/B,qBAAqB,EACrB,iFAAiF,CAClF,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,wBAAw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AAC;QAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC;IACD,oFAAoF;IACpF,uEAAuE;IACvE,IAAI,CAAC,KAAK,IAAI,KAAK,YAAY,UAAU,IAAI,WAAW,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,EAAE,CAAC;QACvF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAI,KAA4B,CAAC,UAAU,CAAC;IAC5D,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAI,UAAiD,CAAC,oBAAoB,CAAC;IACrF,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { IndependenceProof, BaseCertificate, SystemDomainConfig } from "../types/index.js";
2
+ import { ResultBuilder } from "../result/builder.js";
3
+ /**
4
+ * Verify issuance-time participation.
5
+ *
6
+ * Check: ISSUANCE_PARTICIPATION_VALID
7
+ *
8
+ * Per independence.proof/1 section 11.9:
9
+ * - payload.anchor.root_id must be present and non-empty
10
+ * - payload.anchor.root_id must equal proof.system_root_fingerprint
11
+ * - No post-hoc repair permitted
12
+ */
13
+ export declare function verifyIssuanceParticipation(proof: IndependenceProof, baseCert: BaseCertificate, config: SystemDomainConfig, builder: ResultBuilder): void;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Verify issuance-time participation.
3
+ *
4
+ * Check: ISSUANCE_PARTICIPATION_VALID
5
+ *
6
+ * Per independence.proof/1 section 11.9:
7
+ * - payload.anchor.root_id must be present and non-empty
8
+ * - payload.anchor.root_id must equal proof.system_root_fingerprint
9
+ * - No post-hoc repair permitted
10
+ */
11
+ export function verifyIssuanceParticipation(proof, baseCert, config, builder) {
12
+ const rootId = baseCert.payload?.anchor?.root_id;
13
+ if (!rootId || rootId.length === 0) {
14
+ builder.fail("ISSUANCE_PARTICIPATION_VALID", "INDEPENDENT_INVALID", "base_certificate.payload.anchor.root_id is missing or empty — " +
15
+ "issuance-time participation cannot be established");
16
+ return;
17
+ }
18
+ if (rootId !== proof.system_root_fingerprint) {
19
+ builder.fail("ISSUANCE_PARTICIPATION_VALID", "INDEPENDENT_INVALID", `payload.anchor.root_id="${rootId}" does not match proof.system_root_fingerprint="${proof.system_root_fingerprint}"`);
20
+ return;
21
+ }
22
+ builder.pass("ISSUANCE_PARTICIPATION_VALID");
23
+ }
24
+ //# sourceMappingURL=issuance-participation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issuance-participation.js","sourceRoot":"","sources":["../../../core/independent/issuance-participation.ts"],"names":[],"mappings":"AAOA;;;;;;;;;GASG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAwB,EACxB,QAAyB,EACzB,MAA0B,EAC1B,OAAsB;IAEtB,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC;IAEjD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,OAAO,CAAC,IAAI,CACV,8BAA8B,EAC9B,qBAAqB,EACrB,gEAAgE;YAC9D,mDAAmD,CACtD,CAAC;QACF,OAAO;IACT,CAAC;IAED,IAAI,MAAM,KAAK,KAAK,CAAC,uBAAuB,EAAE,CAAC;QAC7C,OAAO,CAAC,IAAI,CACV,8BAA8B,EAC9B,qBAAqB,EACrB,2BAA2B,MAAM,mDAAmD,KAAK,CAAC,uBAAuB,GAAG,CACrH,CAAC;QACF,OAAO;IACT,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { IndependenceProof, BaseCertificate } from "../types/index.js";
2
+ import type { CapacityEvidence } from "../types/capacity-evidence.js";
3
+ import type { CommitmentInclusionProof } from "../types/settlement-material.js";
4
+ import { ResultBuilder } from "../result/builder.js";
5
+ export declare function verifyLeafBinding(proof: IndependenceProof, baseCert: BaseCertificate, capacityEvidence: CapacityEvidence | null, commitmentInclusionProof: CommitmentInclusionProof | null, builder: ResultBuilder): void;
@@ -0,0 +1,135 @@
1
+ import { digestHexBytes } from "../crypto/digest.js";
2
+ import { jcsCanonicalizeBytes } from "../crypto/jcs.js";
3
+ import { canonicalJsonBytes } from "../crypto/canonical-json.js";
4
+ import { computeLeafHash, verifyInclusionProof } from "../crypto/merkle.js";
5
+ const COMMITMENT_LEAF_VERSION = "ccab1-commit";
6
+ function sha3_256_hex(bytes) {
7
+ return digestHexBytes(bytes);
8
+ }
9
+ /**
10
+ * Verify the emission binding between the base certificate and the `independence_proof`.
11
+ *
12
+ * Check: LEAF_BINDING_VALID
13
+ *
14
+ * Hybrid (leaf=subtree) binding: the cert carries no leaf-bound value to
15
+ * equate. The binding is two chained steps:
16
+ * 1. `SHA3-256(JCS(base_certificate)) === certificate_commitment_digest`,
17
+ * where the digest lives inside the zero-data capacity evidence's projected
18
+ * commitment. ("The cert I hold is the one this commitment backs.")
19
+ * 2. the per-commitment inclusion proof verifies `commitment_id →
20
+ * subtree_root`, where `subtree_root` is the value the proof anchors.
21
+ * ("That commitment was accepted into the leaf the proof anchors.")
22
+ */
23
+ const HEX64 = /^[0-9a-f]{64}$/;
24
+ const CANONICAL_UINT = /^(0|[1-9][0-9]*)$/;
25
+ const INCLUSION_MEMBERS = [
26
+ "commitment_id",
27
+ "commitment_leaf_hash",
28
+ "commitment_index",
29
+ "commitment_siblings",
30
+ "subtree_size",
31
+ ];
32
+ function commitmentInclusionProofShapeError(cip) {
33
+ if (typeof cip !== "object" || cip === null || Array.isArray(cip))
34
+ return "not a JSON object";
35
+ const o = cip;
36
+ const keys = Object.keys(o);
37
+ if (keys.length !== INCLUSION_MEMBERS.length || !INCLUSION_MEMBERS.every((k) => k in o)) {
38
+ return `must carry exactly {${INCLUSION_MEMBERS.join(", ")}}`;
39
+ }
40
+ if (typeof o.commitment_id !== "string" || !HEX64.test(o.commitment_id)) {
41
+ return "commitment_id is not 64 lowercase hex";
42
+ }
43
+ if (typeof o.commitment_leaf_hash !== "string" || !HEX64.test(o.commitment_leaf_hash)) {
44
+ return "commitment_leaf_hash is not 64 lowercase hex";
45
+ }
46
+ if (!Array.isArray(o.commitment_siblings) ||
47
+ !o.commitment_siblings.every((h) => typeof h === "string" && HEX64.test(h))) {
48
+ return "commitment_siblings is not an array of 64 lowercase hex";
49
+ }
50
+ if (typeof o.commitment_index !== "string" || !CANONICAL_UINT.test(o.commitment_index)) {
51
+ return "commitment_index is not a canonical unsigned integer string";
52
+ }
53
+ if (typeof o.subtree_size !== "string" ||
54
+ !CANONICAL_UINT.test(o.subtree_size) ||
55
+ o.subtree_size === "0") {
56
+ return "subtree_size is not a canonical positive integer string";
57
+ }
58
+ if (BigInt(o.commitment_index) >= BigInt(o.subtree_size)) {
59
+ return "commitment_index is not below subtree_size";
60
+ }
61
+ return null;
62
+ }
63
+ export function verifyLeafBinding(proof, baseCert, capacityEvidence, commitmentInclusionProof, builder) {
64
+ // Both artifacts are required for the hybrid binding — fail-closed if absent.
65
+ if (!capacityEvidence) {
66
+ builder.fail("LEAF_BINDING_VALID", "INCOMPLETE", "proof anchors a subtree_root but no capacity evidence was supplied to bind the certificate");
67
+ builder.addMissingArtifact("capacity_evidence");
68
+ return;
69
+ }
70
+ if (!commitmentInclusionProof) {
71
+ builder.fail("LEAF_BINDING_VALID", "INCOMPLETE", "proof anchors a subtree_root but no commitment inclusion proof was supplied");
72
+ builder.addMissingArtifact("commitment_inclusion_proof");
73
+ return;
74
+ }
75
+ // Step 1: the cert I hold is the one this commitment backs.
76
+ const certDigest = sha3_256_hex(jcsCanonicalizeBytes(baseCert));
77
+ const boundDigest = capacityEvidence.projected_commitment.certificate_commitment_digest;
78
+ if (certDigest !== boundDigest) {
79
+ builder.fail("LEAF_BINDING_VALID", "INDEPENDENT_INVALID", `certificate_commitment_digest mismatch: SHA3(cert)="${certDigest}" vs evidence="${boundDigest}"`);
80
+ return;
81
+ }
82
+ // Step 2: that commitment was accepted into the leaf the proof anchors.
83
+ const cip = commitmentInclusionProof;
84
+ // The inclusion proof is a closed object of five members
85
+ // (verification-package/1 §9.4.1): hashes as 64 lowercase hex, index and size
86
+ // as canonical unsigned integers with index < size. Anything else is a
87
+ // malformed artifact, refused before it is folded.
88
+ const shapeError = commitmentInclusionProofShapeError(cip);
89
+ if (shapeError) {
90
+ builder.fail("LEAF_BINDING_VALID", "REJECTED", `commitment_inclusion_proof: ${shapeError}`);
91
+ return;
92
+ }
93
+ // 2.0. Tie the supplied evidence to the commitment_id that includes into the
94
+ // tree. In the zero-data profile the commitment_id IS the canonical digest
95
+ // of the capacity evidence (capacity.evidence/1: commitment_id = the
96
+ // evidence digest). Without this the two
97
+ // binding paths only meet in the air: capacity-binding ties the evidence to
98
+ // the proof's digest, the inclusion path ties commitment_id to subtree_root,
99
+ // but nothing ties the supplied evidence to that commitment_id — a different
100
+ // (still self-consistent) evidence could be spliced in. RFC 8785 JCS, the
101
+ // same bytes the producer digests (capacity.evidence/1).
102
+ const evidenceDigest = sha3_256_hex(jcsCanonicalizeBytes(capacityEvidence));
103
+ if (evidenceDigest !== cip.commitment_id) {
104
+ builder.fail("LEAF_BINDING_VALID", "INDEPENDENT_INVALID", `capacity evidence does not recompute to the commitment_id it includes against: ` +
105
+ `SHA3(evidence)="${evidenceDigest}" vs commitment_id="${cip.commitment_id}"`);
106
+ return;
107
+ }
108
+ // 2a. The commitment leaf hash must be SHA3-256(0x00 || ordered_json({v, commitment_id})),
109
+ // so the verifier cannot be handed an arbitrary leaf hash.
110
+ const expectedLeafHash = computeLeafHash(canonicalJsonBytes([
111
+ ["v", COMMITMENT_LEAF_VERSION],
112
+ ["commitment_id", cip.commitment_id],
113
+ ]));
114
+ if (cip.commitment_leaf_hash !== expectedLeafHash) {
115
+ builder.fail("LEAF_BINDING_VALID", "INDEPENDENT_INVALID", `commitment leaf hash mismatch: computed="${expectedLeafHash}" vs declared="${cip.commitment_leaf_hash}"`);
116
+ return;
117
+ }
118
+ // 2b. The leaf hash must include against the subtree_root the proof anchors.
119
+ const commitmentIndex = parseInt(cip.commitment_index, 10);
120
+ const subtreeSize = parseInt(cip.subtree_size, 10);
121
+ if (isNaN(commitmentIndex) ||
122
+ isNaN(subtreeSize) ||
123
+ commitmentIndex < 0 ||
124
+ subtreeSize <= 0) {
125
+ builder.fail("LEAF_BINDING_VALID", "REJECTED", `invalid commitment_index=${cip.commitment_index} or subtree_size=${cip.subtree_size}`);
126
+ return;
127
+ }
128
+ const included = verifyInclusionProof(cip.commitment_leaf_hash, commitmentIndex, cip.commitment_siblings, proof.subtree_root, subtreeSize);
129
+ if (!included) {
130
+ builder.fail("LEAF_BINDING_VALID", "INDEPENDENT_INVALID", "commitment inclusion proof does not verify against proof.subtree_root");
131
+ return;
132
+ }
133
+ builder.pass("LEAF_BINDING_VALID");
134
+ }
135
+ //# sourceMappingURL=leaf-binding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"leaf-binding.js","sourceRoot":"","sources":["../../../core/independent/leaf-binding.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE5E,MAAM,uBAAuB,GAAG,cAAc,CAAC;AAE/C,SAAS,YAAY,CAAC,KAAiB;IACrC,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,KAAK,GA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,oBAAoB,GAAG,CAC1G,CAAC;QACF,OAAO;IACT,CAAC;IAED,6EAA6E;IAC7E,MAAM,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC3D,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACnD,IACE,KAAK,CAAC,eAAe,CAAC;QACtB,KAAK,CAAC,WAAW,CAAC;QAClB,eAAe,GAAG,CAAC;QACnB,WAAW,IAAI,CAAC,EAChB,CAAC;QACD,OAAO,CAAC,IAAI,CACV,oBAAoB,EACpB,UAAU,EACV,4BAA4B,GAAG,CAAC,gBAAgB,oBAAoB,GAAG,CAAC,YAAY,EAAE,CACvF,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,QAAQ,GAAG,oBAAoB,CACnC,GAAG,CAAC,oBAAoB,EACxB,eAAe,EACf,GAAG,CAAC,mBAAmB,EACvB,KAAK,CAAC,YAAa,EACnB,WAAW,CACZ,CAAC;IACF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,CAAC,IAAI,CACV,oBAAoB,EACpB,qBAAqB,EACrB,uEAAuE,CACxE,CAAC;QACF,OAAO;IACT,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Offline resolution of the `operator-recognition.registry/1` surface.
3
+ *
4
+ * Byte-for-byte parity with the reference resolution rule: the same event-replay
5
+ * semantics and the same canonical signing-byte / event_id recomputation
6
+ * (RFC 8785 JCS, two-pass id). The golden vectors in certcrypt-conformance pin
7
+ * both, so this implementation must reproduce them exactly — those vectors, not
8
+ * any single implementation, are what a reimplementation checks against.
9
+ *
10
+ * Non-retroactivity invariant: a revocatory or
11
+ * suspensive event only affects instants at or after its own `effective_from`,
12
+ * so a later revocation cannot reach back past it. Enforced by construction in
13
+ * `participationAt`.
14
+ */
15
+ import type { OperatorRecognitionEvent, OperatorRecognitionRegistry, ParticipationStatus } from "../types/operator-recognition.js";
16
+ /**
17
+ * Recompute the no-id, no-signature JCS view digest of an event. Absent
18
+ * optional fields are OMITTED (never null), matching the reference producer,
19
+ * which omits absent optional members, and the JCS canonicalizer (which drops
20
+ * `undefined`).
21
+ */
22
+ export declare function eventIdDigest(ev: OperatorRecognitionEvent): string;
23
+ /**
24
+ * Recompute the no-signature signing bytes (event_id present) an event's
25
+ * system-domain signature commits to.
26
+ */
27
+ export declare function eventSigningBytes(ev: OperatorRecognitionEvent): Uint8Array;
28
+ /**
29
+ * Resolve whether `operatorId` was a recognized participant at `instant`
30
+ * (RFC 3339). Replays the registry's events; latest-wins per kind. Mirrors the
31
+ * reference producer's semantics exactly, as pinned by the conformance vectors.
32
+ */
33
+ export declare function participationAt(registry: OperatorRecognitionRegistry, operatorId: string, instant: string): ParticipationStatus;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Offline resolution of the `operator-recognition.registry/1` surface.
3
+ *
4
+ * Byte-for-byte parity with the reference resolution rule: the same event-replay
5
+ * semantics and the same canonical signing-byte / event_id recomputation
6
+ * (RFC 8785 JCS, two-pass id). The golden vectors in certcrypt-conformance pin
7
+ * both, so this implementation must reproduce them exactly — those vectors, not
8
+ * any single implementation, are what a reimplementation checks against.
9
+ *
10
+ * Non-retroactivity invariant: a revocatory or
11
+ * suspensive event only affects instants at or after its own `effective_from`,
12
+ * so a later revocation cannot reach back past it. Enforced by construction in
13
+ * `participationAt`.
14
+ */
15
+ import { jcsCanonicalizeBytes } from "../crypto/jcs.js";
16
+ import { digestHexBytes } from "../crypto/digest.js";
17
+ /**
18
+ * Recompute the no-id, no-signature JCS view digest of an event. Absent
19
+ * optional fields are OMITTED (never null), matching the reference producer,
20
+ * which omits absent optional members, and the JCS canonicalizer (which drops
21
+ * `undefined`).
22
+ */
23
+ export function eventIdDigest(ev) {
24
+ const view = {
25
+ artifact_type: ev.artifact_type,
26
+ system_id: ev.system_id,
27
+ rules_version: ev.rules_version,
28
+ system_root_fingerprint: ev.system_root_fingerprint,
29
+ sequence: ev.sequence,
30
+ event_type: ev.event_type,
31
+ operator_id: ev.operator_id,
32
+ operator_public_key: ev.operator_public_key,
33
+ recorded_at: ev.recorded_at,
34
+ effective_from: ev.effective_from,
35
+ effective_until: ev.effective_until,
36
+ justification: ev.justification,
37
+ event_issuer: ev.event_issuer,
38
+ };
39
+ return digestHexBytes(jcsCanonicalizeBytes(view));
40
+ }
41
+ /**
42
+ * Recompute the no-signature signing bytes (event_id present) an event's
43
+ * system-domain signature commits to.
44
+ */
45
+ export function eventSigningBytes(ev) {
46
+ const view = {
47
+ artifact_type: ev.artifact_type,
48
+ system_id: ev.system_id,
49
+ rules_version: ev.rules_version,
50
+ system_root_fingerprint: ev.system_root_fingerprint,
51
+ event_id: ev.event_id,
52
+ sequence: ev.sequence,
53
+ event_type: ev.event_type,
54
+ operator_id: ev.operator_id,
55
+ operator_public_key: ev.operator_public_key,
56
+ recorded_at: ev.recorded_at,
57
+ effective_from: ev.effective_from,
58
+ effective_until: ev.effective_until,
59
+ justification: ev.justification,
60
+ event_issuer: ev.event_issuer,
61
+ };
62
+ return jcsCanonicalizeBytes(view);
63
+ }
64
+ const ms = (rfc3339) => Date.parse(rfc3339);
65
+ /**
66
+ * Resolve whether `operatorId` was a recognized participant at `instant`
67
+ * (RFC 3339). Replays the registry's events; latest-wins per kind. Mirrors the
68
+ * reference producer's semantics exactly, as pinned by the conformance vectors.
69
+ */
70
+ export function participationAt(registry, operatorId, instant) {
71
+ const t = ms(instant);
72
+ let recognized = false;
73
+ let currentKey;
74
+ let suspended = false;
75
+ let terminal;
76
+ for (const ev of registry.events) {
77
+ if (ev.operator_id !== operatorId)
78
+ continue;
79
+ const from = ms(ev.effective_from);
80
+ switch (ev.event_type) {
81
+ case "recognition":
82
+ if (from <= t) {
83
+ recognized = true;
84
+ if (ev.operator_public_key)
85
+ currentKey = ev.operator_public_key;
86
+ }
87
+ break;
88
+ case "key_rotation":
89
+ if (from <= t && ev.operator_public_key)
90
+ currentKey = ev.operator_public_key;
91
+ break;
92
+ case "suspension": {
93
+ const covers = from <= t && (ev.effective_until == null || t < ms(ev.effective_until));
94
+ if (covers)
95
+ suspended = true;
96
+ break;
97
+ }
98
+ case "revocation":
99
+ if (from <= t)
100
+ terminal = { status: "revoked" };
101
+ break;
102
+ case "expiration":
103
+ if (from <= t)
104
+ terminal = { status: "expired" };
105
+ break;
106
+ }
107
+ }
108
+ if (terminal)
109
+ return terminal;
110
+ if (suspended)
111
+ return { status: "suspended" };
112
+ if (recognized && currentKey)
113
+ return { status: "recognized", operator_public_key: currentKey };
114
+ return { status: "not_recognized" };
115
+ }
116
+ //# sourceMappingURL=operator-recognition-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator-recognition-registry.js","sourceRoot":"","sources":["../../../core/independent/operator-recognition-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAOrD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,EAA4B;IACxD,MAAM,IAAI,GAA4B;QACpC,aAAa,EAAE,EAAE,CAAC,aAAa;QAC/B,SAAS,EAAE,EAAE,CAAC,SAAS;QACvB,aAAa,EAAE,EAAE,CAAC,aAAa;QAC/B,uBAAuB,EAAE,EAAE,CAAC,uBAAuB;QACnD,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,UAAU,EAAE,EAAE,CAAC,UAAU;QACzB,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,mBAAmB,EAAE,EAAE,CAAC,mBAAmB;QAC3C,WAAW,EAAE,EAAE,CAAC,WAAW;QAC3B,cAAc,EAAE,EAAE,CAAC,cAAc;QACjC,eAAe,EAAE,EAAE,CAAC,eAAe;QACnC,aAAa,EAAE,EAAE,CAAC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EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { IndependenceProof } from "../types/index.js";
2
+ import { ResultBuilder } from "../result/builder.js";
3
+ /**
4
+ * Verify proof presence, version, and structural completeness.
5
+ *
6
+ * Checks: PROOF_PRESENT, PROOF_VERSION_SUPPORTED, PROOF_STRUCTURE_VALID
7
+ */
8
+ export declare function verifyProofStructure(proof: IndependenceProof | null, builder: ResultBuilder): proof is IndependenceProof;