@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,92 @@
1
+ /**
2
+ * CCVP/1 — issuance consistency against certified historical context.
3
+ *
4
+ * The problem this answers: a certificate signed three years ago by a key that
5
+ * has since been retired. A CRL or OCSP responder answers it by being alive
6
+ * today, which is exactly the dependency that fails over long horizons. CCVP
7
+ * answers it from signed history instead — context snapshots declaring who was
8
+ * eligible to issue, from when, and until when — so the question stays
9
+ * answerable offline with no live authority.
10
+ *
11
+ * Four properties shape everything here:
12
+ *
13
+ * OPTIONAL, AND NEVER A VERDICT. CCVP grants no authority (CCVP/1 §0.2) and its
14
+ * outcome never feeds `Issued` or `Independent` (verifier-toolkit/1 §11.3). A
15
+ * certificate whose consistency is unknown is not thereby invalid: "Absence of
16
+ * context snapshots MUST NOT invalidate cryptographic validity" (§10).
17
+ *
18
+ * CERTIFICATES IN, NOT VALUES. Both the target and every snapshot are signed
19
+ * certificates, and each is verified here under the Issued route before it
20
+ * counts. A snapshot's issuer is the key that signed it — `signer.id` plus the
21
+ * composite key fingerprint — never a field it carries. The target names that
22
+ * key in its signed `payload.context`, so a snapshot signed by anyone else is
23
+ * outside the namespace whatever label it borrows (§5.2, §9 step 2).
24
+ *
25
+ * FORWARD ONLY. Context is selected by the certificate's issuance time, never
26
+ * by now. Retiring a key today cannot retroactively unmake what it signed.
27
+ *
28
+ * INSTANTS, NOT STRINGS. Every timestamp is read as nanoseconds since the
29
+ * epoch (§6.3). Comparing RFC 3339 strings orders `…00Z` after `…00.000Z`,
30
+ * which name the same instant, and two verifiers would select differently.
31
+ *
32
+ * Three outcomes, and the third is not a failure:
33
+ * consistency-match an applicable entry covers this issuance
34
+ * consistency-mismatch a snapshot governs and no entry covers it
35
+ * consistency-unknown no verification unit, no governing snapshot, or a
36
+ * context that is equivocal or unreadable
37
+ */
38
+ import type { SystemDomainConfig } from "../types/index.js";
39
+ export type ConsistencyOutcome = "consistency-match" | "consistency-mismatch" | "consistency-unknown";
40
+ /**
41
+ * The declared context namespace of a target certificate (CCVP/1 §5.2): the
42
+ * snapshot issuer by label and composite key fingerprint, and the context set.
43
+ */
44
+ export interface ConsistencyNamespace {
45
+ snapshot_issuer_id: string;
46
+ snapshot_issuer_fingerprint_digest_hex: string;
47
+ context_set_id: string;
48
+ }
49
+ /** The snapshot that governed the outcome. */
50
+ export interface SelectedSnapshot {
51
+ snapshot_id: string;
52
+ /** `S.payload.snapshot.issued_at` — the snapshot's effective context time. */
53
+ issued_at: string;
54
+ }
55
+ export interface ConsistencyResult {
56
+ outcome: ConsistencyOutcome;
57
+ /** Why, in terms a caller can act on. */
58
+ reason: string;
59
+ /**
60
+ * Whether the target verified under the Issued route. When false the outcome
61
+ * is `consistency-unknown`: there is no issuer signature to bind (§5.3).
62
+ */
63
+ target_issued_valid: boolean;
64
+ /** The namespace the target declares, when it declares a complete one. */
65
+ namespace: ConsistencyNamespace | null;
66
+ /** The governing snapshot, when one governed. */
67
+ selected_snapshot: SelectedSnapshot | null;
68
+ /** Index in the selected snapshot's `entries` of the entry that matched. */
69
+ matched_entry_index: number | null;
70
+ /** Candidates that were not Issued-valid and took no part (§9 step 1). */
71
+ discarded_candidates: number;
72
+ }
73
+ /**
74
+ * CCVP/1 §6.3: the instant a timestamp names, in nanoseconds since the epoch,
75
+ * or null when the value is not a timestamp in the CCSP/1 `issued_at` form
76
+ * naming a real instant.
77
+ */
78
+ export declare function ccvpInstant(value: unknown): bigint | null;
79
+ /**
80
+ * Evaluate the CCVP/1 consistency of one certificate under the namespace it
81
+ * declares, against the candidate context snapshot certificates on hand.
82
+ *
83
+ * `certificate` and every element of `snapshots` are CCSP/1 certificates as
84
+ * parsed JSON; parse them with `strictJsonParse` so a repeated member name
85
+ * fails instead of being silently resolved. Each one is verified here under the
86
+ * Issued route with `config` (the published production profile when omitted),
87
+ * so ML-DSA-65 must be initialised (`initMlDsa65`) first.
88
+ *
89
+ * The result is reported beside, never instead of, the verdict of `verify()`:
90
+ * no outcome here changes whether a certificate is Issued or Independent.
91
+ */
92
+ export declare function verifyConsistency(certificate: unknown, snapshots: readonly unknown[], config?: SystemDomainConfig): ConsistencyResult;
@@ -0,0 +1,353 @@
1
+ /**
2
+ * CCVP/1 — issuance consistency against certified historical context.
3
+ *
4
+ * The problem this answers: a certificate signed three years ago by a key that
5
+ * has since been retired. A CRL or OCSP responder answers it by being alive
6
+ * today, which is exactly the dependency that fails over long horizons. CCVP
7
+ * answers it from signed history instead — context snapshots declaring who was
8
+ * eligible to issue, from when, and until when — so the question stays
9
+ * answerable offline with no live authority.
10
+ *
11
+ * Four properties shape everything here:
12
+ *
13
+ * OPTIONAL, AND NEVER A VERDICT. CCVP grants no authority (CCVP/1 §0.2) and its
14
+ * outcome never feeds `Issued` or `Independent` (verifier-toolkit/1 §11.3). A
15
+ * certificate whose consistency is unknown is not thereby invalid: "Absence of
16
+ * context snapshots MUST NOT invalidate cryptographic validity" (§10).
17
+ *
18
+ * CERTIFICATES IN, NOT VALUES. Both the target and every snapshot are signed
19
+ * certificates, and each is verified here under the Issued route before it
20
+ * counts. A snapshot's issuer is the key that signed it — `signer.id` plus the
21
+ * composite key fingerprint — never a field it carries. The target names that
22
+ * key in its signed `payload.context`, so a snapshot signed by anyone else is
23
+ * outside the namespace whatever label it borrows (§5.2, §9 step 2).
24
+ *
25
+ * FORWARD ONLY. Context is selected by the certificate's issuance time, never
26
+ * by now. Retiring a key today cannot retroactively unmake what it signed.
27
+ *
28
+ * INSTANTS, NOT STRINGS. Every timestamp is read as nanoseconds since the
29
+ * epoch (§6.3). Comparing RFC 3339 strings orders `…00Z` after `…00.000Z`,
30
+ * which name the same instant, and two verifiers would select differently.
31
+ *
32
+ * Three outcomes, and the third is not a failure:
33
+ * consistency-match an applicable entry covers this issuance
34
+ * consistency-mismatch a snapshot governs and no entry covers it
35
+ * consistency-unknown no verification unit, no governing snapshot, or a
36
+ * context that is equivocal or unreadable
37
+ */
38
+ import { verify } from "../verify.js";
39
+ import { jcsCanonicalizeBytes } from "../crypto/jcs.js";
40
+ import { digestHexBytes, digestHexText } from "../crypto/digest.js";
41
+ import { canonicalBytesForSubject, SUBJECT_CONTEXT_SNAPSHOT } from "../crypto/canonical-subject.js";
42
+ import { toHex } from "../crypto/provider/bytes.js";
43
+ const HEX64_RE = /^[0-9a-f]{64}$/;
44
+ /** CCSP/1 §7.3.1 form, which CCVP/1 §6.3 adopts for every timestamp. */
45
+ const TIMESTAMP_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?Z$/;
46
+ const ASCII_TOKEN_RE = /^[\x21-\x7e]+$/;
47
+ function isObject(v) {
48
+ return typeof v === "object" && v !== null && !Array.isArray(v);
49
+ }
50
+ /** Days from 1970-01-01 to a proleptic Gregorian date (no Date: it remaps years 0–99). */
51
+ function daysFromCivil(y, m, d) {
52
+ const yy = m <= 2 ? y - 1 : y;
53
+ const era = Math.floor(yy / 400);
54
+ const yoe = yy - era * 400;
55
+ const doy = Math.floor((153 * (m + (m > 2 ? -3 : 9)) + 2) / 5) + d - 1;
56
+ const doe = yoe * 365 + Math.floor(yoe / 4) - Math.floor(yoe / 100) + doy;
57
+ return era * 146097 + doe - 719468;
58
+ }
59
+ function daysInMonth(y, m) {
60
+ if (m === 2)
61
+ return (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0 ? 29 : 28;
62
+ return [4, 6, 9, 11].includes(m) ? 30 : 31;
63
+ }
64
+ /**
65
+ * CCVP/1 §6.3: the instant a timestamp names, in nanoseconds since the epoch,
66
+ * or null when the value is not a timestamp in the CCSP/1 `issued_at` form
67
+ * naming a real instant.
68
+ */
69
+ export function ccvpInstant(value) {
70
+ if (typeof value !== "string")
71
+ return null;
72
+ const m = TIMESTAMP_RE.exec(value);
73
+ if (!m)
74
+ return null;
75
+ const [y, mo, d, h, mi, se] = m.slice(1, 7).map(Number);
76
+ if (mo < 1 || mo > 12 || d < 1 || d > daysInMonth(y, mo) || h > 23 || mi > 59 || se > 59) {
77
+ return null;
78
+ }
79
+ const seconds = BigInt(daysFromCivil(y, mo, d)) * 86400n + BigInt(h * 3600 + mi * 60 + se);
80
+ return seconds * 1000000000n + BigInt((m[7] ?? "").padEnd(9, "0"));
81
+ }
82
+ /** RFC 4648 base64 (standard alphabet, padded), or null. */
83
+ function decodeBase64(v) {
84
+ if (typeof v !== "string" || v.length === 0 || v.length % 4 !== 0)
85
+ return null;
86
+ if (!/^[A-Za-z0-9+/]+={0,2}$/.test(v))
87
+ return null;
88
+ const bin = atob(v);
89
+ const out = new Uint8Array(bin.length);
90
+ for (let i = 0; i < bin.length; i++)
91
+ out[i] = bin.charCodeAt(i);
92
+ return out;
93
+ }
94
+ /**
95
+ * CCVP/1 §8.1: SHA3-256(pub_p256_bytes || pub_mldsa_bytes) over the decoded
96
+ * keys of an issuer signature's signer — the construction of
97
+ * composite-signature/1 §10. Only called on certificates that already verified,
98
+ * so the keys decode.
99
+ */
100
+ function compositeKeyFingerprint(signer) {
101
+ const p256 = decodeBase64(signer.pub_p256_b64) ?? new Uint8Array();
102
+ const mldsa = decodeBase64(signer.pub_mldsa_b64) ?? new Uint8Array();
103
+ const both = new Uint8Array(p256.length + mldsa.length);
104
+ both.set(p256, 0);
105
+ both.set(mldsa, p256.length);
106
+ return digestHexBytes(both);
107
+ }
108
+ function verifyIssuedCertificate(candidate, config) {
109
+ if (!isObject(candidate))
110
+ return null;
111
+ const result = verify({
112
+ verification_target_requested: "issued",
113
+ input_mode: "artifact_set",
114
+ base_certificate: candidate,
115
+ }, config);
116
+ if (result.result_code !== "ISSUED_VALID")
117
+ return null;
118
+ const payload = candidate.payload;
119
+ const signature = candidate.signatures[0];
120
+ const signer = signature.signer;
121
+ return {
122
+ payload,
123
+ signature,
124
+ signer,
125
+ signerId: signer.id,
126
+ fingerprint: compositeKeyFingerprint(signer),
127
+ };
128
+ }
129
+ /** CCVP/1 §5.2: the namespace triple, or null when incomplete or malformed. */
130
+ function readNamespace(payload) {
131
+ const ctx = payload.context;
132
+ if (!isObject(ctx))
133
+ return null;
134
+ const { snapshot_issuer_id, snapshot_issuer_fingerprint_digest_hex, context_set_id } = ctx;
135
+ if (typeof snapshot_issuer_id !== "string")
136
+ return null;
137
+ if (typeof snapshot_issuer_fingerprint_digest_hex !== "string")
138
+ return null;
139
+ if (!HEX64_RE.test(snapshot_issuer_fingerprint_digest_hex))
140
+ return null;
141
+ if (typeof context_set_id !== "string" || context_set_id.length === 0)
142
+ return null;
143
+ return { snapshot_issuer_id, snapshot_issuer_fingerprint_digest_hex, context_set_id };
144
+ }
145
+ function isStringArray(v) {
146
+ return Array.isArray(v) && v.every((x) => typeof x === "string");
147
+ }
148
+ function isOptionalTimestamp(e, key) {
149
+ return !(key in e) || e[key] === null || ccvpInstant(e[key]) !== null;
150
+ }
151
+ /** CCVP/1 §7.1: one entry in the form the specification defines. */
152
+ function isConformantEntry(e) {
153
+ if (!isObject(e))
154
+ return false;
155
+ if (typeof e.issuer_id !== "string" || e.issuer_id.length === 0)
156
+ return false;
157
+ if (typeof e.pub_fingerprint_digest_hex !== "string" || !HEX64_RE.test(e.pub_fingerprint_digest_hex)) {
158
+ return false;
159
+ }
160
+ if (typeof e.status !== "string")
161
+ return false;
162
+ if (ccvpInstant(e.valid_from) === null)
163
+ return false;
164
+ if (!isOptionalTimestamp(e, "valid_to") || !isOptionalTimestamp(e, "revoked_at"))
165
+ return false;
166
+ if ("revocation_reason" in e && e.revocation_reason !== null && typeof e.revocation_reason !== "string") {
167
+ return false;
168
+ }
169
+ if ("kid" in e) {
170
+ const kid = e.kid;
171
+ if (typeof kid !== "string" || !ASCII_TOKEN_RE.test(kid) || kid.length > 128)
172
+ return false;
173
+ }
174
+ if ("roles" in e && !isStringArray(e.roles))
175
+ return false;
176
+ if ("scope" in e) {
177
+ if (!isObject(e.scope))
178
+ return false;
179
+ if ("subject_profiles" in e.scope && !isStringArray(e.scope.subject_profiles))
180
+ return false;
181
+ }
182
+ return true;
183
+ }
184
+ /**
185
+ * CCVP/1 §5.1 requirements 2–3 with §6, §6.3 and §7.1: the snapshot object is
186
+ * well formed and is the one the issuer committed to in its
187
+ * `subject.context-snapshot/1` subject.
188
+ */
189
+ function isConformantSnapshot(cert) {
190
+ const snapshot = cert.payload.snapshot;
191
+ if (!isObject(snapshot))
192
+ return false;
193
+ const anchor = cert.payload.anchor;
194
+ const markers = anchor.subjects.filter((s) => s.profile === SUBJECT_CONTEXT_SNAPSHOT);
195
+ if (markers.length !== 1)
196
+ return false;
197
+ let canonical;
198
+ try {
199
+ // The profile's own preconditions: no JSON number at any depth. The value
200
+ // reached here was parsed already, so repeated member names are the
201
+ // caller's parser's to refuse (see strictJsonParse).
202
+ canonical = canonicalBytesForSubject(SUBJECT_CONTEXT_SNAPSHOT, new TextEncoder().encode(JSON.stringify(snapshot)));
203
+ }
204
+ catch {
205
+ return false;
206
+ }
207
+ const commitment = digestHexText(anchor.nonce_hex + digestHexBytes(canonical));
208
+ if (markers[0].commitment_digest_hex !== commitment)
209
+ return false;
210
+ if (typeof snapshot.context_set_id !== "string" || snapshot.context_set_id.length === 0)
211
+ return false;
212
+ if (typeof snapshot.snapshot_id !== "string" || snapshot.snapshot_id.length === 0)
213
+ return false;
214
+ if (ccvpInstant(snapshot.issued_at) === null)
215
+ return false;
216
+ if (!Array.isArray(snapshot.entries) || !snapshot.entries.every(isConformantEntry))
217
+ return false;
218
+ return true;
219
+ }
220
+ /** CCVP/1 §8: is this entry applicable to the target? Every clause is a conjunct. */
221
+ function entryApplies(entry, target, issuedAt) {
222
+ if (entry.issuer_id !== target.signerId)
223
+ return false;
224
+ if (entry.pub_fingerprint_digest_hex !== target.fingerprint)
225
+ return false;
226
+ // A kid narrows; it never admits. Without one in the entry, the signature's
227
+ // kid plays no part.
228
+ if ("kid" in entry && target.signature.kid !== entry.kid)
229
+ return false;
230
+ if (entry.status !== "active")
231
+ return false;
232
+ if (ccvpInstant(entry.valid_from) > issuedAt)
233
+ return false;
234
+ if (entry.valid_to !== undefined && entry.valid_to !== null) {
235
+ if (!(issuedAt < ccvpInstant(entry.valid_to)))
236
+ return false;
237
+ }
238
+ // CCSP/1 certificates carry one signature, under the issuer role.
239
+ if (entry.roles !== undefined && !entry.roles.includes("issuer"))
240
+ return false;
241
+ const scope = entry.scope;
242
+ if (scope?.subject_profiles !== undefined) {
243
+ const allowed = scope.subject_profiles;
244
+ const profiles = target.payload.anchor.subjects.map((s) => s.profile);
245
+ if (!profiles.some((p) => typeof p === "string" && allowed.includes(p)))
246
+ return false;
247
+ }
248
+ return true;
249
+ }
250
+ /**
251
+ * Evaluate the CCVP/1 consistency of one certificate under the namespace it
252
+ * declares, against the candidate context snapshot certificates on hand.
253
+ *
254
+ * `certificate` and every element of `snapshots` are CCSP/1 certificates as
255
+ * parsed JSON; parse them with `strictJsonParse` so a repeated member name
256
+ * fails instead of being silently resolved. Each one is verified here under the
257
+ * Issued route with `config` (the published production profile when omitted),
258
+ * so ML-DSA-65 must be initialised (`initMlDsa65`) first.
259
+ *
260
+ * The result is reported beside, never instead of, the verdict of `verify()`:
261
+ * no outcome here changes whether a certificate is Issued or Independent.
262
+ */
263
+ export function verifyConsistency(certificate, snapshots, config) {
264
+ const result = (outcome, reason, extra = {}) => ({
265
+ outcome,
266
+ reason,
267
+ target_issued_valid: true,
268
+ namespace: null,
269
+ selected_snapshot: null,
270
+ matched_entry_index: null,
271
+ discarded_candidates: 0,
272
+ ...extra,
273
+ });
274
+ const target = verifyIssuedCertificate(certificate, config);
275
+ if (!target) {
276
+ return result("consistency-unknown", "the target certificate is not Issued-valid, so it has no issuer signature to bind " +
277
+ "(CCVP/1 §5.3)", { target_issued_valid: false });
278
+ }
279
+ const namespace = readNamespace(target.payload);
280
+ if (!namespace) {
281
+ return result("consistency-unknown", "the certificate declares no complete context namespace in payload.context " +
282
+ "(snapshot_issuer_id, snapshot_issuer_fingerprint_digest_hex, context_set_id)");
283
+ }
284
+ const issuedAt = ccvpInstant(target.payload.anchor.issued_at);
285
+ // §9 steps 1–2: verify every candidate, then keep the snapshots signed by the
286
+ // key the namespace names, for its context set.
287
+ let discarded = 0;
288
+ const conformant = [];
289
+ const nonConformant = [];
290
+ for (const candidate of snapshots) {
291
+ const cert = verifyIssuedCertificate(candidate, config);
292
+ if (!cert) {
293
+ discarded++;
294
+ continue;
295
+ }
296
+ const subjects = cert.payload.anchor.subjects;
297
+ const isSnapshot = "snapshot" in cert.payload || subjects.some((s) => s.profile === SUBJECT_CONTEXT_SNAPSHOT);
298
+ if (!isSnapshot)
299
+ continue;
300
+ if (cert.signerId !== namespace.snapshot_issuer_id)
301
+ continue;
302
+ if (cert.fingerprint !== namespace.snapshot_issuer_fingerprint_digest_hex)
303
+ continue;
304
+ const snapshot = cert.payload.snapshot;
305
+ if (!isObject(snapshot) || snapshot.context_set_id !== namespace.context_set_id)
306
+ continue;
307
+ (isConformantSnapshot(cert) ? conformant : nonConformant).push(snapshot);
308
+ }
309
+ const base = { namespace, discarded_candidates: discarded };
310
+ // §9 step 4: the maximal effective instant at or before issuance.
311
+ const eligible = conformant.filter((s) => ccvpInstant(s.issued_at) <= issuedAt);
312
+ let maximal = null;
313
+ for (const s of eligible) {
314
+ const at = ccvpInstant(s.issued_at);
315
+ if (maximal === null || at > maximal)
316
+ maximal = at;
317
+ }
318
+ // §9.1: a non-conformant snapshot from the namespace key is set aside only
319
+ // when its effective time is readable and shows it cannot govern. It is never
320
+ // skipped to reach an older snapshot it may have been meant to supersede.
321
+ for (const s of nonConformant) {
322
+ const at = ccvpInstant(s.issued_at);
323
+ if (at !== null && (at > issuedAt || (maximal !== null && at < maximal)))
324
+ continue;
325
+ return result("consistency-unknown", "a context snapshot signed by the namespace key does not conform to CCVP/1 and may " +
326
+ "govern this issuance; it cannot be read and it cannot be skipped (CCVP/1 §9.1)", base);
327
+ }
328
+ if (maximal === null) {
329
+ return result("consistency-unknown", "no context snapshot in this namespace takes effect at or before the certificate's " +
330
+ "issuance time", base);
331
+ }
332
+ // §9: a tie is one snapshot only if the canonical bytes agree; otherwise the
333
+ // holder of the namespace key equivocated.
334
+ const tied = eligible.filter((s) => ccvpInstant(s.issued_at) === maximal);
335
+ const identities = new Set(tied.map((s) => toHex(jcsCanonicalizeBytes(s))));
336
+ if (identities.size > 1) {
337
+ return result("consistency-unknown", `context equivocation: ${identities.size} distinct snapshots share the maximal ` +
338
+ "effective time in this namespace", base);
339
+ }
340
+ const selected = tied[0];
341
+ const selectedSnapshot = {
342
+ snapshot_id: selected.snapshot_id,
343
+ issued_at: selected.issued_at,
344
+ };
345
+ const entries = selected.entries;
346
+ const index = entries.findIndex((e) => entryApplies(e, target, issuedAt));
347
+ return index >= 0
348
+ ? result("consistency-match", `entry ${index} of snapshot ${selectedSnapshot.snapshot_id} (effective ` +
349
+ `${selectedSnapshot.issued_at}) covers this issuance`, { ...base, selected_snapshot: selectedSnapshot, matched_entry_index: index })
350
+ : result("consistency-mismatch", `snapshot ${selectedSnapshot.snapshot_id} (effective ${selectedSnapshot.issued_at}) ` +
351
+ "governs this issuance and no entry covers the key that signed it", { ...base, selected_snapshot: selectedSnapshot });
352
+ }
353
+ //# sourceMappingURL=verify-consistency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-consistency.js","sourceRoot":"","sources":["../../../core/consistency/verify-consistency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACpG,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AA2CpD,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAClC,wEAAwE;AACxE,MAAM,YAAY,GAAG,oEAAoE,CAAC;AAC1F,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAIxC,SAAS,QAAQ,CAAC,CAA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E,CAC7E;QACH,CAAC,CAAC,MAAM,CACJ,sBAAsB,EACtB,YAAY,gBAAgB,CAAC,WAAW,eAAe,gBAAgB,CAAC,SAAS,IAAI;YACnF,kEAAkE,EACpE,EAAE,GAAG,IAAI,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CACjD,CAAC;AACR,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Build canonical JSON bytes from an ordered list of key-value pairs.
3
+ *
4
+ * Per settlement.binding/1 sections 5-6 and system-foundation/1:
5
+ * - UTF-8 encoding
6
+ * - Exact member order as prescribed (NOT sorted)
7
+ * - No additional members
8
+ * - Values may be strings, numbers, booleans, null, or arrays thereof
9
+ *
10
+ * We build the JSON string by explicit concatenation to guarantee
11
+ * exact field order regardless of JS engine object key ordering.
12
+ */
13
+ export type CanonicalJsonValue = string | number | boolean | null | string[] | number[] | boolean[];
14
+ export declare function canonicalJsonBytes(orderedFields: [string, CanonicalJsonValue][]): Uint8Array;
@@ -0,0 +1,13 @@
1
+ export function canonicalJsonBytes(orderedFields) {
2
+ const parts = ["{"];
3
+ for (let i = 0; i < orderedFields.length; i++) {
4
+ if (i > 0)
5
+ parts.push(",");
6
+ const [key, value] = orderedFields[i];
7
+ parts.push(JSON.stringify(key) + ":" + JSON.stringify(value));
8
+ }
9
+ parts.push("}");
10
+ const json = parts.join("");
11
+ return new TextEncoder().encode(json);
12
+ }
13
+ //# sourceMappingURL=canonical-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-json.js","sourceRoot":"","sources":["../../../core/crypto/canonical-json.ts"],"names":[],"mappings":"AAqBA,MAAM,UAAU,kBAAkB,CAChC,aAA6C;IAE7C,MAAM,KAAK,GAAa,CAAC,GAAG,CAAC,CAAC;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,IAAI,CAAC,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC5B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * `canonical_bytes(subject)` dispatch by subject profile (CCCP/1;
3
+ * verifier-toolkit/1). The verifier recomputes these bytes from the
4
+ * original material, hashes them to `subject_local_digest_hex`, and rebuilds the
5
+ * certificate commitment to confirm the material matches.
6
+ *
7
+ * Supported profiles: `subject.binary/1`, `subject.text/1`, `subject.email/1`,
8
+ * `subject.collection/1`, `subject.ai-decision/1`, and `subject.context-snapshot/1`.
9
+ * An unsupported profile
10
+ * MUST fail closed as UNSUPPORTED — the caller maps a thrown
11
+ * `UnsupportedProfileError` to that outcome rather than falling back to another
12
+ * profile.
13
+ *
14
+ * The subject canonicalization context is opaque bytes at the CCCP layer
15
+ * (CCCP/1); CCCP/1 UTF-8/BOM rules govern CCCP-defined contexts, not
16
+ * subject input. `subject.text/1` and `subject.email/1` therefore operate on the
17
+ * RAW bytes and never decode/re-encode through a platform string (which could
18
+ * alter bytes via U+FFFD substitution, normalization, or NUL truncation).
19
+ */
20
+ export declare const SUBJECT_BINARY = "subject.binary/1";
21
+ export declare const SUBJECT_TEXT = "subject.text/1";
22
+ export declare const SUBJECT_EMAIL = "subject.email/1";
23
+ export declare const SUBJECT_COLLECTION = "subject.collection/1";
24
+ export declare const SUBJECT_AI_DECISION = "subject.ai-decision/1";
25
+ export declare const SUBJECT_CONTEXT_SNAPSHOT = "subject.context-snapshot/1";
26
+ /** Profiles the toolkit supports for `canonical_bytes` recomputation. */
27
+ export declare const SUPPORTED_SUBJECT_PROFILES: string[];
28
+ /**
29
+ * Profiles whose canonical_bytes ARE the input bytes, unchanged.
30
+ *
31
+ * This is the precondition for hashing material INCREMENTALLY: a digest assembled from
32
+ * chunks equals a digest of the whole buffer only when nothing is rewritten in between.
33
+ * Every other profile fails it — `text/1` normalizes line endings and appends a terminator,
34
+ * `email/1` unfolds headers across the whole message, and the JSON-object profiles
35
+ * re-serialize the PARSED value under JCS, which is not even a byte transformation.
36
+ *
37
+ * It is a LIST, not a string comparison against `SUBJECT_BINARY`, because the property
38
+ * belongs to the profile family and its versions: a future `subject.binary/2` that still
39
+ * defines canonical_bytes as the exact input bytes belongs here, and one that does not must
40
+ * NOT be added — the whole point of naming this separately from `SUPPORTED_SUBJECT_PROFILES`
41
+ * is that supporting a profile and being streamable are different questions, decided here,
42
+ * next to the switch that implements them.
43
+ */
44
+ export declare const OPAQUE_BYTE_PROFILES: readonly string[];
45
+ /**
46
+ * Whether `profile`'s canonical_bytes are its input bytes, so material under it may be
47
+ * hashed in chunks instead of held whole in memory.
48
+ */
49
+ export declare function isOpaqueByteProfile(profile: string): boolean;
50
+ /** Thrown when a subject declares a profile the toolkit does not support. */
51
+ export declare class UnsupportedProfileError extends Error {
52
+ readonly profile: string;
53
+ constructor(profile: string);
54
+ }
55
+ /**
56
+ * Compute `canonical_bytes(subject)` for a subject under its declared profile.
57
+ *
58
+ * - `subject.binary/1`: the exact input bytes, opaque, no transformation
59
+ * (subject.binary/1). `material` MUST already be the raw bytes.
60
+ * - `subject.text/1`: line-ending normalization + single trailing CRLF, byte
61
+ * preserved otherwise (subject.text/1). Operates on raw bytes.
62
+ * - `subject.email/1`: global CRLF normalization, header/body split, RFC 5322
63
+ * header unfolding (WSP preserved), body trailing-terminator normalization,
64
+ * deterministic assembly (subject.email/1). Raw bytes.
65
+ * - `subject.collection/1`: UTF-8 bytes of the RFC 8785 JCS serialization of the
66
+ * parsed JSON object (subject.collection/1). `material` is the JSON source
67
+ * bytes; it is parsed and re-canonicalized (canonicalize the value, not the
68
+ * source bytes).
69
+ * - `subject.ai-decision/1`: the same JCS rule over the parsed decision record,
70
+ * after its field-set and string-only preconditions (subject.ai-decision/1).
71
+ * - `subject.context-snapshot/1`: the same JCS rule over the parsed snapshot,
72
+ * which must carry no JSON number at any depth (subject.context-snapshot/1).
73
+ *
74
+ * Throws `UnsupportedProfileError` for any other declared profile.
75
+ */
76
+ export declare function canonicalBytesForSubject(profile: string, material: Uint8Array): Uint8Array;