@certcrypt/verifier-toolkit 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @certcrypt/verifier-toolkit might be problematic. Click here for more details.
- package/CHANGELOG.md +72 -0
- package/LICENSE +178 -0
- package/README.md +563 -2
- package/SECURITY.md +77 -0
- package/dist/cli/certcrypt-verify.d.ts +2 -0
- package/dist/cli/certcrypt-verify.js +174 -0
- package/dist/cli/certcrypt-verify.js.map +1 -0
- package/dist/core/config/certcrypt-foundation.d.ts +13 -0
- package/dist/core/config/certcrypt-foundation.js +123 -0
- package/dist/core/config/certcrypt-foundation.js.map +1 -0
- package/dist/core/config/default.d.ts +47 -0
- package/dist/core/config/default.js +93 -0
- package/dist/core/config/default.js.map +1 -0
- package/dist/core/config/test-keys.d.ts +40 -0
- package/dist/core/config/test-keys.js +41 -0
- package/dist/core/config/test-keys.js.map +1 -0
- package/dist/core/conformance/attestation.d.ts +4 -0
- package/dist/core/conformance/attestation.js +4 -0
- package/dist/core/conformance/attestation.js.map +1 -0
- package/dist/core/consistency/verify-consistency.d.ts +92 -0
- package/dist/core/consistency/verify-consistency.js +353 -0
- package/dist/core/consistency/verify-consistency.js.map +1 -0
- package/dist/core/crypto/canonical-json.d.ts +14 -0
- package/dist/core/crypto/canonical-json.js +13 -0
- package/dist/core/crypto/canonical-json.js.map +1 -0
- package/dist/core/crypto/canonical-subject.d.ts +76 -0
- package/dist/core/crypto/canonical-subject.js +248 -0
- package/dist/core/crypto/canonical-subject.js.map +1 -0
- package/dist/core/crypto/collection-merkle.d.ts +91 -0
- package/dist/core/crypto/collection-merkle.js +243 -0
- package/dist/core/crypto/collection-merkle.js.map +1 -0
- package/dist/core/crypto/composite.d.ts +73 -0
- package/dist/core/crypto/composite.js +206 -0
- package/dist/core/crypto/composite.js.map +1 -0
- package/dist/core/crypto/digest.d.ts +18 -0
- package/dist/core/crypto/digest.js +37 -0
- package/dist/core/crypto/digest.js.map +1 -0
- package/dist/core/crypto/ecdsa-p256.d.ts +12 -0
- package/dist/core/crypto/ecdsa-p256.js +70 -0
- package/dist/core/crypto/ecdsa-p256.js.map +1 -0
- package/dist/core/crypto/ed25519.d.ts +10 -0
- package/dist/core/crypto/ed25519.js +28 -0
- package/dist/core/crypto/ed25519.js.map +1 -0
- package/dist/core/crypto/holder-keyset.d.ts +23 -0
- package/dist/core/crypto/holder-keyset.js +64 -0
- package/dist/core/crypto/holder-keyset.js.map +1 -0
- package/dist/core/crypto/jcs.d.ts +9 -0
- package/dist/core/crypto/jcs.js +59 -0
- package/dist/core/crypto/jcs.js.map +1 -0
- package/dist/core/crypto/merkle.d.ts +34 -0
- package/dist/core/crypto/merkle.js +147 -0
- package/dist/core/crypto/merkle.js.map +1 -0
- package/dist/core/crypto/ml-dsa.d.ts +25 -0
- package/dist/core/crypto/ml-dsa.js +104 -0
- package/dist/core/crypto/ml-dsa.js.map +1 -0
- package/dist/core/crypto/provider/bytes.d.ts +31 -0
- package/dist/core/crypto/provider/bytes.js +106 -0
- package/dist/core/crypto/provider/bytes.js.map +1 -0
- package/dist/core/crypto/provider/index.d.ts +45 -0
- package/dist/core/crypto/provider/index.js +60 -0
- package/dist/core/crypto/provider/index.js.map +1 -0
- package/dist/core/crypto/provider/node.d.ts +2 -0
- package/dist/core/crypto/provider/node.js +96 -0
- package/dist/core/crypto/provider/node.js.map +1 -0
- package/dist/core/crypto/provider/register-node.d.ts +11 -0
- package/dist/core/crypto/provider/register-node.js +16 -0
- package/dist/core/crypto/provider/register-node.js.map +1 -0
- package/dist/core/crypto/provider/types.d.ts +77 -0
- package/dist/core/crypto/provider/types.js +16 -0
- package/dist/core/crypto/provider/types.js.map +1 -0
- package/dist/core/crypto/provider/web.d.ts +2 -0
- package/dist/core/crypto/provider/web.js +122 -0
- package/dist/core/crypto/provider/web.js.map +1 -0
- package/dist/core/crypto/pseudonym.d.ts +25 -0
- package/dist/core/crypto/pseudonym.js +37 -0
- package/dist/core/crypto/pseudonym.js.map +1 -0
- package/dist/core/crypto/subject-json-preconditions.d.ts +47 -0
- package/dist/core/crypto/subject-json-preconditions.js +373 -0
- package/dist/core/crypto/subject-json-preconditions.js.map +1 -0
- package/dist/core/domain/verify-domain.d.ts +13 -0
- package/dist/core/domain/verify-domain.js +39 -0
- package/dist/core/domain/verify-domain.js.map +1 -0
- package/dist/core/foundation/anti-equivocation.d.ts +87 -0
- package/dist/core/foundation/anti-equivocation.js +0 -0
- package/dist/core/foundation/anti-equivocation.js.map +1 -0
- package/dist/core/foundation/verify-foundation.d.ts +36 -0
- package/dist/core/foundation/verify-foundation.js +559 -0
- package/dist/core/foundation/verify-foundation.js.map +1 -0
- package/dist/core/independent/anti-replay.d.ts +15 -0
- package/dist/core/independent/anti-replay.js +27 -0
- package/dist/core/independent/anti-replay.js.map +1 -0
- package/dist/core/independent/anti-splicing.d.ts +16 -0
- package/dist/core/independent/anti-splicing.js +54 -0
- package/dist/core/independent/anti-splicing.js.map +1 -0
- package/dist/core/independent/capacity-binding.d.ts +26 -0
- package/dist/core/independent/capacity-binding.js +57 -0
- package/dist/core/independent/capacity-binding.js.map +1 -0
- package/dist/core/independent/capacity-evidence.d.ts +38 -0
- package/dist/core/independent/capacity-evidence.js +286 -0
- package/dist/core/independent/capacity-evidence.js.map +1 -0
- package/dist/core/independent/effective-units.d.ts +42 -0
- package/dist/core/independent/effective-units.js +147 -0
- package/dist/core/independent/effective-units.js.map +1 -0
- package/dist/core/independent/issuance-participation.d.ts +13 -0
- package/dist/core/independent/issuance-participation.js +24 -0
- package/dist/core/independent/issuance-participation.js.map +1 -0
- package/dist/core/independent/leaf-binding.d.ts +5 -0
- package/dist/core/independent/leaf-binding.js +135 -0
- package/dist/core/independent/leaf-binding.js.map +1 -0
- package/dist/core/independent/operator-recognition-registry.d.ts +33 -0
- package/dist/core/independent/operator-recognition-registry.js +116 -0
- package/dist/core/independent/operator-recognition-registry.js.map +1 -0
- package/dist/core/independent/proof-structure.d.ts +8 -0
- package/dist/core/independent/proof-structure.js +167 -0
- package/dist/core/independent/proof-structure.js.map +1 -0
- package/dist/core/independent/proof-views.d.ts +26 -0
- package/dist/core/independent/proof-views.js +58 -0
- package/dist/core/independent/proof-views.js.map +1 -0
- package/dist/core/independent/settlement.d.ts +18 -0
- package/dist/core/independent/settlement.js +548 -0
- package/dist/core/independent/settlement.js.map +1 -0
- package/dist/core/independent/verify-independent.d.ts +30 -0
- package/dist/core/independent/verify-independent.js +123 -0
- package/dist/core/independent/verify-independent.js.map +1 -0
- package/dist/core/independent/verify-operator-recognition.d.ts +26 -0
- package/dist/core/independent/verify-operator-recognition.js +60 -0
- package/dist/core/independent/verify-operator-recognition.js.map +1 -0
- package/dist/core/independent/verify-proof-signature.d.ts +20 -0
- package/dist/core/independent/verify-proof-signature.js +97 -0
- package/dist/core/independent/verify-proof-signature.js.map +1 -0
- package/dist/core/input/fs-bridge.d.ts +30 -0
- package/dist/core/input/fs-bridge.js +35 -0
- package/dist/core/input/fs-bridge.js.map +1 -0
- package/dist/core/input/load-artifacts.d.ts +2 -0
- package/dist/core/input/load-artifacts.js +80 -0
- package/dist/core/input/load-artifacts.js.map +1 -0
- package/dist/core/input/load-original-material.d.ts +11 -0
- package/dist/core/input/load-original-material.js +126 -0
- package/dist/core/input/load-original-material.js.map +1 -0
- package/dist/core/input/register-node-fs.d.ts +1 -0
- package/dist/core/input/register-node-fs.js +24 -0
- package/dist/core/input/register-node-fs.js.map +1 -0
- package/dist/core/input/resolve-target.d.ts +16 -0
- package/dist/core/input/resolve-target.js +43 -0
- package/dist/core/input/resolve-target.js.map +1 -0
- package/dist/core/input/strict-json.d.ts +25 -0
- package/dist/core/input/strict-json.js +167 -0
- package/dist/core/input/strict-json.js.map +1 -0
- package/dist/core/input/validate.d.ts +7 -0
- package/dist/core/input/validate.js +83 -0
- package/dist/core/input/validate.js.map +1 -0
- package/dist/core/issued/verify-collection-element.d.ts +66 -0
- package/dist/core/issued/verify-collection-element.js +137 -0
- package/dist/core/issued/verify-collection-element.js.map +1 -0
- package/dist/core/issued/verify-issued.d.ts +15 -0
- package/dist/core/issued/verify-issued.js +361 -0
- package/dist/core/issued/verify-issued.js.map +1 -0
- package/dist/core/issued/verify-original-material.d.ts +35 -0
- package/dist/core/issued/verify-original-material.js +418 -0
- package/dist/core/issued/verify-original-material.js.map +1 -0
- package/dist/core/package/verify-package.d.ts +34 -0
- package/dist/core/package/verify-package.js +109 -0
- package/dist/core/package/verify-package.js.map +1 -0
- package/dist/core/public-api.d.ts +178 -0
- package/dist/core/public-api.js +182 -0
- package/dist/core/public-api.js.map +1 -0
- package/dist/core/result/builder.d.ts +92 -0
- package/dist/core/result/builder.js +408 -0
- package/dist/core/result/builder.js.map +1 -0
- package/dist/core/rules/verify-corpus.d.ts +88 -0
- package/dist/core/rules/verify-corpus.js +165 -0
- package/dist/core/rules/verify-corpus.js.map +1 -0
- package/dist/core/rules/verify-rules.d.ts +14 -0
- package/dist/core/rules/verify-rules.js +62 -0
- package/dist/core/rules/verify-rules.js.map +1 -0
- package/dist/core/testing/validate-against-schema.d.ts +31 -0
- package/dist/core/testing/validate-against-schema.js +93 -0
- package/dist/core/testing/validate-against-schema.js.map +1 -0
- package/dist/core/types/artifacts.d.ts +224 -0
- package/dist/core/types/artifacts.js +2 -0
- package/dist/core/types/artifacts.js.map +1 -0
- package/dist/core/types/capacity-evidence.d.ts +85 -0
- package/dist/core/types/capacity-evidence.js +51 -0
- package/dist/core/types/capacity-evidence.js.map +1 -0
- package/dist/core/types/check.d.ts +61 -0
- package/dist/core/types/check.js +2 -0
- package/dist/core/types/check.js.map +1 -0
- package/dist/core/types/config.d.ts +97 -0
- package/dist/core/types/config.js +2 -0
- package/dist/core/types/config.js.map +1 -0
- package/dist/core/types/foundation.d.ts +121 -0
- package/dist/core/types/foundation.js +25 -0
- package/dist/core/types/foundation.js.map +1 -0
- package/dist/core/types/index.d.ts +9 -0
- package/dist/core/types/index.js +2 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/types/operator-recognition.d.ts +71 -0
- package/dist/core/types/operator-recognition.js +24 -0
- package/dist/core/types/operator-recognition.js.map +1 -0
- package/dist/core/types/proof.d.ts +94 -0
- package/dist/core/types/proof.js +2 -0
- package/dist/core/types/proof.js.map +1 -0
- package/dist/core/types/request.d.ts +59 -0
- package/dist/core/types/request.js +2 -0
- package/dist/core/types/request.js.map +1 -0
- package/dist/core/types/result.d.ts +164 -0
- package/dist/core/types/result.js +2 -0
- package/dist/core/types/result.js.map +1 -0
- package/dist/core/types/settlement-material.d.ts +130 -0
- package/dist/core/types/settlement-material.js +2 -0
- package/dist/core/types/settlement-material.js.map +1 -0
- package/dist/core/verify-node.d.ts +14 -0
- package/dist/core/verify-node.js +17 -0
- package/dist/core/verify-node.js.map +1 -0
- package/dist/core/verify-web.d.ts +1 -0
- package/dist/core/verify-web.js +25 -0
- package/dist/core/verify-web.js.map +1 -0
- package/dist/core/verify.d.ts +18 -0
- package/dist/core/verify.js +183 -0
- package/dist/core/verify.js.map +1 -0
- package/package.json +71 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { verifyProofStructure } from "./proof-structure.js";
|
|
2
|
+
import { verifySystemDomain } from "../domain/verify-domain.js";
|
|
3
|
+
import { verifyRulesDomain } from "../rules/verify-rules.js";
|
|
4
|
+
import { verifyLeafBinding } from "./leaf-binding.js";
|
|
5
|
+
import { verifySettlement } from "./settlement.js";
|
|
6
|
+
import { verifyIssuanceParticipation } from "./issuance-participation.js";
|
|
7
|
+
import { verifyProofSignature } from "./verify-proof-signature.js";
|
|
8
|
+
import { verifyAntiReplay } from "./anti-replay.js";
|
|
9
|
+
import { verifyAntiSplicing } from "./anti-splicing.js";
|
|
10
|
+
import { verifyCapacityBinding } from "./capacity-binding.js";
|
|
11
|
+
import { verifyEffectiveUnitsBinding } from "./effective-units.js";
|
|
12
|
+
import { capacityEvidenceShapeError } from "./capacity-evidence.js";
|
|
13
|
+
/**
|
|
14
|
+
* Verify the Independent path.
|
|
15
|
+
*
|
|
16
|
+
* Per verifier-toolkit/1 section 11.2:
|
|
17
|
+
* This runs AFTER verifyIssued has already been called (step 3).
|
|
18
|
+
*
|
|
19
|
+
* Validation sequence (verifier-toolkit/1 §11.2; independence.proof/1 §12):
|
|
20
|
+
* 1. Proof structure
|
|
21
|
+
* 2. System domain attribution
|
|
22
|
+
* 3. Rules domain selection
|
|
23
|
+
* 4. Leaf binding
|
|
24
|
+
* 5. Capacity-evidence binding — before settlement, as independence.proof/1
|
|
25
|
+
* §9 and §12.5 require: the settlement fixes a consumption whose
|
|
26
|
+
* authorization must first be shown legitimate
|
|
27
|
+
* 6. Settlement (ref, finality, capacity, inclusion, aggregated interpretation)
|
|
28
|
+
* 7. Issuance-time participation
|
|
29
|
+
* 8. Proof signature (mandatory; authenticates the signed view, node
|
|
30
|
+
* attestation included)
|
|
31
|
+
* 9. Anti-replay
|
|
32
|
+
* 10. Anti-splicing
|
|
33
|
+
* 11. Effective-units binding
|
|
34
|
+
*
|
|
35
|
+
* Short-circuit only on Independent-specific failures (via checkpoint),
|
|
36
|
+
* NOT on prior Issued failures like UNSUPPORTED for signature verification.
|
|
37
|
+
* This ensures the full Independent baseline runs and populates diagnostics
|
|
38
|
+
* even when Issued checks have a non-blocking failure.
|
|
39
|
+
*/
|
|
40
|
+
export function verifyIndependent(artifacts, config, builder) {
|
|
41
|
+
const baseCert = artifacts.baseCertificate;
|
|
42
|
+
// Create checkpoint after Issued phase so we only short-circuit
|
|
43
|
+
// on failures from Independent checks, not from Issued UNSUPPORTED
|
|
44
|
+
const cp = builder.checkpoint();
|
|
45
|
+
// 1. Proof structure
|
|
46
|
+
const proof = artifacts.independenceProof;
|
|
47
|
+
if (!verifyProofStructure(proof, builder)) {
|
|
48
|
+
builder.markEarlyExit();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// Populate structural lineage from proof (visible in result regardless of outcome)
|
|
52
|
+
builder.setLineage({
|
|
53
|
+
settlement_profile_id: proof.settlement?.profile_id,
|
|
54
|
+
subtree_root: proof.subtree_root,
|
|
55
|
+
settlement_ref: proof.settlement_ref,
|
|
56
|
+
batch_root: proof.batch?.root,
|
|
57
|
+
batch_index: proof.batch?.index,
|
|
58
|
+
batch_size: proof.batch?.size,
|
|
59
|
+
});
|
|
60
|
+
// 2. System domain
|
|
61
|
+
verifySystemDomain(proof, config, builder);
|
|
62
|
+
if (builder.hasFailureSince(cp))
|
|
63
|
+
return;
|
|
64
|
+
// 3. Rules domain
|
|
65
|
+
verifyRulesDomain(proof, baseCert, config, builder);
|
|
66
|
+
if (builder.hasFailureSince(cp))
|
|
67
|
+
return;
|
|
68
|
+
// capacity.evidence/1 is a closed runtime artifact, not merely a TypeScript
|
|
69
|
+
// interface. Validate it before any binding check dereferences its members.
|
|
70
|
+
if (artifacts.capacityEvidence) {
|
|
71
|
+
const shapeError = capacityEvidenceShapeError(artifacts.capacityEvidence);
|
|
72
|
+
if (shapeError) {
|
|
73
|
+
builder.fail("CAPACITY_EVIDENCE_VALID", "INDEPENDENT_INVALID", `capacity evidence does not verify: ${shapeError}`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// 4. Leaf binding (hybrid leaf=subtree binding: the certificate digest in the
|
|
78
|
+
// capacity evidence, then commitment inclusion into subtree_root)
|
|
79
|
+
verifyLeafBinding(proof, baseCert, artifacts.capacityEvidence, artifacts.commitmentInclusionProof, builder);
|
|
80
|
+
if (builder.hasFailureSince(cp))
|
|
81
|
+
return;
|
|
82
|
+
// 5. Capacity-evidence binding: verifies the zero-data capacity evidence and
|
|
83
|
+
// requires it to recompute to the evaluated certificate's commitment_id.
|
|
84
|
+
// Runs before settlement (independence.proof/1 §9, §12.5).
|
|
85
|
+
verifyCapacityBinding(proof, artifacts.capacityEvidence, artifacts.commitmentInclusionProof, artifacts.systemFoundation, builder, config.signature_profile);
|
|
86
|
+
if (builder.hasFailureSince(cp))
|
|
87
|
+
return;
|
|
88
|
+
// 6. Settlement
|
|
89
|
+
verifySettlement(proof, artifacts.settlementMaterial, artifacts.capacityEvidence, config, builder);
|
|
90
|
+
if (builder.hasFailureSince(cp))
|
|
91
|
+
return;
|
|
92
|
+
// 7. Issuance-time participation
|
|
93
|
+
verifyIssuanceParticipation(proof, baseCert, config, builder);
|
|
94
|
+
if (builder.hasFailureSince(cp))
|
|
95
|
+
return;
|
|
96
|
+
// 8. Proof signature: the system domain's composite signature over the
|
|
97
|
+
// signed view, against the Level-1 capacity key from the foundation.
|
|
98
|
+
// Mandatory; fails closed when absent, unresolvable or invalid. Once it
|
|
99
|
+
// verifies, the node attestation it covers is authentic and is recorded
|
|
100
|
+
// for the result (reported only on INDEPENDENT_VALID).
|
|
101
|
+
verifyProofSignature(proof, artifacts.systemFoundation, builder, config.signature_profile);
|
|
102
|
+
if (builder.hasFailureSince(cp))
|
|
103
|
+
return;
|
|
104
|
+
builder.setAttestedNode(proof.node_attestation ?? null);
|
|
105
|
+
// 9. Anti-replay
|
|
106
|
+
verifyAntiReplay(proof, builder);
|
|
107
|
+
if (builder.hasFailureSince(cp))
|
|
108
|
+
return;
|
|
109
|
+
// 10. Anti-splicing
|
|
110
|
+
verifyAntiSplicing(proof, baseCert, artifacts.settlementMaterial, artifacts.commitmentInclusionProof, builder);
|
|
111
|
+
if (builder.hasFailureSince(cp))
|
|
112
|
+
return;
|
|
113
|
+
// 11. Effective-units binding: binds declared effective units to the
|
|
114
|
+
// certified subjects; under-declaration is rejected. Binds
|
|
115
|
+
// declared_effective_units to the subjects actually certified in the
|
|
116
|
+
// base-certificate anchor: capacity.commitment/1 requires it to
|
|
117
|
+
// EQUAL Σ per-subject units (collection → declared_cardinality, any other
|
|
118
|
+
// subject → 1). The only actor holding both the subjects and the declared
|
|
119
|
+
// units is this offline verifier. Fail-closed (INDEPENDENT_INVALID) on an
|
|
120
|
+
// under-declaration.
|
|
121
|
+
verifyEffectiveUnitsBinding(baseCert, artifacts.capacityEvidence, artifacts.originalMaterial, builder);
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=verify-independent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-independent.js","sourceRoot":"","sources":["../../../core/independent/verify-independent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAA0B,EAC1B,MAA0B,EAC1B,OAAsB;IAEtB,MAAM,QAAQ,GAAG,SAAS,CAAC,eAAgB,CAAC;IAE5C,gEAAgE;IAChE,mEAAmE;IACnE,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAEhC,qBAAqB;IACrB,MAAM,KAAK,GAAG,SAAS,CAAC,iBAAiB,CAAC;IAC1C,IAAI,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC;QAC1C,OAAO,CAAC,aAAa,EAAE,CAAC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8E;IAC9E,8EAA8E;IAC9E,yBAAyB;IACzB,2BAA2B,CACzB,QAAQ,EACR,SAAS,CAAC,gBAAgB,EAC1B,SAAS,CAAC,gBAAgB,EAC1B,OAAO,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IndependenceProof, BaseCertificate, LoadedArtifacts } from "../types/index.js";
|
|
2
|
+
import { ResultBuilder } from "../result/builder.js";
|
|
3
|
+
/**
|
|
4
|
+
* Verify OPT-IN operator recognition at issuance time.
|
|
5
|
+
*
|
|
6
|
+
* Check: OPERATOR_RECOGNITION_VALID
|
|
7
|
+
*
|
|
8
|
+
* This is OPT-IN, not a baseline requirement: it runs ONLY when the artifact
|
|
9
|
+
* declares an `operator_id` (the actor chose to be recognizable).
|
|
10
|
+
* It is therefore NOT in INDEPENDENT_REQUIRED_CHECKS; a proof without an
|
|
11
|
+
* operator_id is complete without it.
|
|
12
|
+
*
|
|
13
|
+
* When an `operator_id` IS declared:
|
|
14
|
+
* - If no operator-recognition registry was supplied, the verifier cannot
|
|
15
|
+
* resolve participation offline → records a diagnostic note (the registry
|
|
16
|
+
* history is part of the optional offline material); it does NOT fail (absence of material is not
|
|
17
|
+
* a forgery).
|
|
18
|
+
* - If a registry is supplied, resolve participation at the issuance instant.
|
|
19
|
+
* Recognized → pass. Suspended/revoked/expired/not-recognized at that
|
|
20
|
+
* instant → fail INDEPENDENT_INVALID (INVALID_ISSUANCE_PARTICIPATION).
|
|
21
|
+
*
|
|
22
|
+
* Non-retroactivity is enforced inside `participationAt`: a later
|
|
23
|
+
* revocatory event only covers instants at or after its own `effective_from`,
|
|
24
|
+
* so an artifact emitted before that instant stays recognized.
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyOperatorRecognition(proof: IndependenceProof, baseCert: BaseCertificate, artifacts: LoadedArtifacts, builder: ResultBuilder): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { participationAt } from "./operator-recognition-registry.js";
|
|
2
|
+
/**
|
|
3
|
+
* Verify OPT-IN operator recognition at issuance time.
|
|
4
|
+
*
|
|
5
|
+
* Check: OPERATOR_RECOGNITION_VALID
|
|
6
|
+
*
|
|
7
|
+
* This is OPT-IN, not a baseline requirement: it runs ONLY when the artifact
|
|
8
|
+
* declares an `operator_id` (the actor chose to be recognizable).
|
|
9
|
+
* It is therefore NOT in INDEPENDENT_REQUIRED_CHECKS; a proof without an
|
|
10
|
+
* operator_id is complete without it.
|
|
11
|
+
*
|
|
12
|
+
* When an `operator_id` IS declared:
|
|
13
|
+
* - If no operator-recognition registry was supplied, the verifier cannot
|
|
14
|
+
* resolve participation offline → records a diagnostic note (the registry
|
|
15
|
+
* history is part of the optional offline material); it does NOT fail (absence of material is not
|
|
16
|
+
* a forgery).
|
|
17
|
+
* - If a registry is supplied, resolve participation at the issuance instant.
|
|
18
|
+
* Recognized → pass. Suspended/revoked/expired/not-recognized at that
|
|
19
|
+
* instant → fail INDEPENDENT_INVALID (INVALID_ISSUANCE_PARTICIPATION).
|
|
20
|
+
*
|
|
21
|
+
* Non-retroactivity is enforced inside `participationAt`: a later
|
|
22
|
+
* revocatory event only covers instants at or after its own `effective_from`,
|
|
23
|
+
* so an artifact emitted before that instant stays recognized.
|
|
24
|
+
*/
|
|
25
|
+
export function verifyOperatorRecognition(proof, baseCert, artifacts, builder) {
|
|
26
|
+
const operatorId = proof.operator_id;
|
|
27
|
+
if (!operatorId) {
|
|
28
|
+
// Opt-in: no declared operator identity → nothing to resolve.
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const registry = artifacts.operatorRecognitionRegistry;
|
|
32
|
+
if (!registry) {
|
|
33
|
+
builder.addDiagnostic("warning", `proof declares operator_id="${operatorId}" but no operator-recognition ` +
|
|
34
|
+
"registry was supplied; issuance-time participation cannot be resolved offline", "OPERATOR_RECOGNITION_VALID");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// The registry must be tied to the same system root as the proof.
|
|
38
|
+
if (registry.system_root_fingerprint !== proof.system_root_fingerprint) {
|
|
39
|
+
builder.fail("OPERATOR_RECOGNITION_VALID", "INDEPENDENT_INVALID", `operator-recognition registry system_root_fingerprint=` +
|
|
40
|
+
`"${registry.system_root_fingerprint}" does not match the proof's ` +
|
|
41
|
+
`"${proof.system_root_fingerprint}"`);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Issuance instant: prefer the proof's created_at, fall back to the
|
|
45
|
+
// certificate anchor's issued_at.
|
|
46
|
+
const instant = proof.created_at ?? baseCert.payload?.anchor?.issued_at;
|
|
47
|
+
if (!instant) {
|
|
48
|
+
builder.fail("OPERATOR_RECOGNITION_VALID", "INDEPENDENT_INVALID", "cannot determine the issuance instant (no proof.created_at and no " +
|
|
49
|
+
"base_certificate anchor.issued_at) to resolve operator recognition");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const status = participationAt(registry, operatorId, instant);
|
|
53
|
+
if (status.status === "recognized") {
|
|
54
|
+
builder.pass("OPERATOR_RECOGNITION_VALID");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
builder.fail("OPERATOR_RECOGNITION_VALID", "INDEPENDENT_INVALID", `operator_id="${operatorId}" was not a recognized participant at issuance ` +
|
|
58
|
+
`instant ${instant} (resolved status: ${status.status})`);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=verify-operator-recognition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-operator-recognition.js","sourceRoot":"","sources":["../../../core/independent/verify-operator-recognition.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAwB,EACxB,QAAyB,EACzB,SAA0B,EAC1B,OAAsB;IAEtB,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC;IACrC,IAAI,CAAC,UAAU,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ify the IndependenceProof signature against the CERTCRYPT system domain.
|
|
3
|
+
*
|
|
4
|
+
* Check: PROOF_SIGNATURE_VALID.
|
|
5
|
+
*
|
|
6
|
+
* The signature is MANDATORY under every rules domain (independence.proof/1
|
|
7
|
+
* §10.13): a composite under the rules domain's signature profile (ECDSA P-256
|
|
8
|
+
* + ML-DSA-65, classical first) by the system-domain Level-1 capacity key the
|
|
9
|
+
* system foundation publishes, over the JCS of the signed view (§10.13.1). An
|
|
10
|
+
* absent signature, an unresolvable signer key or an unavailable ML-DSA-65
|
|
11
|
+
* runtime fail closed; none of them is reported as "not performed".
|
|
12
|
+
*
|
|
13
|
+
* The signed view carries `anti_replay` and, when present, `node_attestation`,
|
|
14
|
+
* so a passing signature also authenticates the node attestation.
|
|
15
|
+
*/
|
|
16
|
+
import type { IndependenceProof, SystemFoundation } from "../types/index.js";
|
|
17
|
+
import { ResultBuilder } from "../result/builder.js";
|
|
18
|
+
export declare function verifyProofSignature(proof: IndependenceProof, foundation: SystemFoundation | null, builder: ResultBuilder,
|
|
19
|
+
/** The composite profile the rules domain fixes for the proof signature. */
|
|
20
|
+
signatureProfile: string): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify the IndependenceProof signature against the CERTCRYPT system domain.
|
|
3
|
+
*
|
|
4
|
+
* Check: PROOF_SIGNATURE_VALID.
|
|
5
|
+
*
|
|
6
|
+
* The signature is MANDATORY under every rules domain (independence.proof/1
|
|
7
|
+
* §10.13): a composite under the rules domain's signature profile (ECDSA P-256
|
|
8
|
+
* + ML-DSA-65, classical first) by the system-domain Level-1 capacity key the
|
|
9
|
+
* system foundation publishes, over the JCS of the signed view (§10.13.1). An
|
|
10
|
+
* absent signature, an unresolvable signer key or an unavailable ML-DSA-65
|
|
11
|
+
* runtime fail closed; none of them is reported as "not performed".
|
|
12
|
+
*
|
|
13
|
+
* The signed view carries `anti_replay` and, when present, `node_attestation`,
|
|
14
|
+
* so a passing signature also authenticates the node attestation.
|
|
15
|
+
*/
|
|
16
|
+
import { jcsCanonicalizeBytes } from "../crypto/jcs.js";
|
|
17
|
+
import { digestHexBytes } from "../crypto/digest.js";
|
|
18
|
+
import { verifyComposite } from "../crypto/composite.js";
|
|
19
|
+
import { proofSignedView } from "./proof-views.js";
|
|
20
|
+
/** The proof signature's closed member set (independence.proof/1 §10.13). */
|
|
21
|
+
const PROOF_SIGNATURE_MEMBERS = ["signing_kid", "alg", "mode", "signatures"];
|
|
22
|
+
function isProofSignatureObject(s) {
|
|
23
|
+
if (typeof s !== "object" || s === null || Array.isArray(s))
|
|
24
|
+
return false;
|
|
25
|
+
const keys = Object.keys(s);
|
|
26
|
+
return (keys.length === PROOF_SIGNATURE_MEMBERS.length &&
|
|
27
|
+
PROOF_SIGNATURE_MEMBERS.every((m) => Object.hasOwn(s, m)) &&
|
|
28
|
+
typeof s.signing_kid === "string" &&
|
|
29
|
+
s.signing_kid.length > 0 &&
|
|
30
|
+
typeof s.alg === "string" &&
|
|
31
|
+
Array.isArray(s.signatures));
|
|
32
|
+
}
|
|
33
|
+
export function verifyProofSignature(proof, foundation, builder,
|
|
34
|
+
/** The composite profile the rules domain fixes for the proof signature. */
|
|
35
|
+
signatureProfile) {
|
|
36
|
+
const sig = proof.signature;
|
|
37
|
+
// Absent → the signed fields carry no authenticity: incomplete. Present but not
|
|
38
|
+
// a composite signature object → malformed: rejected.
|
|
39
|
+
if (sig === undefined || sig === null) {
|
|
40
|
+
builder.fail("PROOF_SIGNATURE_VALID", "INCOMPLETE", "independence_proof carries no signature; it is mandatory");
|
|
41
|
+
builder.addMissingArtifact("proof_signature");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!isProofSignatureObject(sig)) {
|
|
45
|
+
builder.fail("PROOF_SIGNATURE_VALID", "REJECTED", "independence_proof signature is not a composite signature object with exactly " +
|
|
46
|
+
PROOF_SIGNATURE_MEMBERS.join(", "));
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// The expected profile is the rules domain's, never the one the signature
|
|
50
|
+
// declares: a proof signed under another profile fails even if it verifies.
|
|
51
|
+
if (sig.alg !== signatureProfile) {
|
|
52
|
+
builder.fail("PROOF_SIGNATURE_VALID", "REJECTED", `proof signature profile "${sig.alg}" is not the rules domain's "${signatureProfile}"`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// The proof is signed by the system-domain Level-1 COMPOSITE key — the DISTINCT
|
|
56
|
+
// capacity key (NOT the bootstrap root, which signs the foundation statement).
|
|
57
|
+
// Both component public keys are published in the foundation. Without them the
|
|
58
|
+
// verifier cannot resolve the signer key offline: incomplete.
|
|
59
|
+
const mldsaPub = foundation?.system_domain_capacity_key_mldsa_b64;
|
|
60
|
+
const classicalPub = foundation?.system_domain_capacity_key_p256_b64;
|
|
61
|
+
if (!foundation || !mldsaPub || !classicalPub) {
|
|
62
|
+
builder.fail("PROOF_SIGNATURE_VALID", "INCOMPLETE", "no complete system-domain composite capacity key is available from system_foundation to verify the proof signature");
|
|
63
|
+
builder.addMissingArtifact("system_foundation");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// Defense in depth: the proof must be bound to the same root the foundation
|
|
67
|
+
// attests, so a proof from a cloned domain cannot be verified with this domain's key.
|
|
68
|
+
if (proof.system_root_fingerprint &&
|
|
69
|
+
foundation.system_root_fingerprint &&
|
|
70
|
+
proof.system_root_fingerprint !== foundation.system_root_fingerprint) {
|
|
71
|
+
builder.fail("PROOF_SIGNATURE_VALID", "INDEPENDENT_INVALID", "proof system_root_fingerprint does not match the system_foundation root");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Composite signs M' = composite_m_prime(SHA3-256(JCS(signed view))).
|
|
75
|
+
const signingBytes = jcsCanonicalizeBytes(proofSignedView(proof));
|
|
76
|
+
const signingDigestHex = digestHexBytes(signingBytes);
|
|
77
|
+
const result = verifyComposite(signatureProfile, signingDigestHex, { alg: sig.alg, mode: sig.mode, signatures: sig.signatures }, { classicalPubB64: classicalPub, mldsaPubB64: mldsaPub });
|
|
78
|
+
// Malformed material — layout, members, fixed values, key encoding — is a
|
|
79
|
+
// structural defect, not a signature that fails to verify.
|
|
80
|
+
if (result.malformed) {
|
|
81
|
+
builder.fail("PROOF_SIGNATURE_VALID", "REJECTED", `proof composite signature is malformed: ${result.malformed}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (result.mldsa.performed === false && (result.mldsa.reason ?? "").startsWith("unsupported_runtime")) {
|
|
85
|
+
builder.fail("PROOF_SIGNATURE_VALID", "UNSUPPORTED", `ML-DSA-65 verification is unavailable, so the mandatory proof signature cannot be verified: ${result.mldsa.reason}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (!result.valid) {
|
|
89
|
+
const why = result.mldsa.passed !== true
|
|
90
|
+
? `ML-DSA-65 component (${result.mldsa.reason})`
|
|
91
|
+
: `${result.classical.alg ?? "classical"} component (${result.classical.reason})`;
|
|
92
|
+
builder.fail("PROOF_SIGNATURE_VALID", "INDEPENDENT_INVALID", `proof composite signature does not verify against the system-domain key: ${why}`);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
builder.pass("PROOF_SIGNATURE_VALID");
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=verify-proof-signature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-proof-signature.js","sourceRoot":"","sources":["../../../core/independent/verify-proof-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,6EAA6E;AAC7E,MAAM,uBAAuB,GAAG,CAAC,aAAa,EAAE,KA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Ae,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,CACzD,CAAC;IAEF,0EAA0E;IAC1E,2DAA2D;IAC3D,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CACV,uBAAuB,EACvB,UAAU,EACV,2CAA2C,MAAM,CAAC,SAAS,EAAE,CAC9D,CAAC;QACF,OAAO;IACT,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,qBAAqB,CAAC,EAAE,CAAC;QACtG,OAAO,CAAC,IAAI,CACV,uBAAuB,EACvB,aAAa,EACb,+FAA+F,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CACrH,CAAC;QACF,OAAO;IACT,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,IAAI;YACtC,CAAC,CAAC,wBAAwB,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG;YAChD,CAAC,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,WAAW,eAAe,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC;QACpF,OAAO,CAAC,IAAI,CACV,uBAAuB,EACvB,qBAAqB,EACrB,4EAA4E,GAAG,EAAE,CAClF,CAAC;QACF,OAAO;IACT,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-reading bridge.
|
|
3
|
+
*
|
|
4
|
+
* `VerifierRequest` accepts artifacts either in memory or by path. Paths are a
|
|
5
|
+
* Node convenience (the CLI reads files); a browser always supplies artifacts in
|
|
6
|
+
* memory, because the material it verifies is already in the page.
|
|
7
|
+
*
|
|
8
|
+
* Keeping `node:fs`/`node:path` behind this bridge is what lets a browser bundle
|
|
9
|
+
* exclude them: nothing a browser imports reaches the Node implementation, so
|
|
10
|
+
* the built-ins never enter the module graph. If a path IS supplied without a
|
|
11
|
+
* bridge registered, the read fails with a clear error rather than a bundler's
|
|
12
|
+
* cryptic "module not found".
|
|
13
|
+
*/
|
|
14
|
+
export interface FileSystemBridge {
|
|
15
|
+
readTextFile(path: string): string;
|
|
16
|
+
readBinaryFile(path: string): Uint8Array;
|
|
17
|
+
/** Resolve `p` against `baseDir` unless it is already absolute. */
|
|
18
|
+
resolvePath(baseDir: string, p: string): string;
|
|
19
|
+
/** The directory portion of a path. */
|
|
20
|
+
directoryOf(path: string): string;
|
|
21
|
+
}
|
|
22
|
+
/** Install the Node implementation. Called by `register-node-fs.ts`. */
|
|
23
|
+
export declare function registerFileSystemBridge(bridge: FileSystemBridge): void;
|
|
24
|
+
export declare function hasFileSystemBridge(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The active bridge. Throws when a path-based artifact is requested in a runtime
|
|
27
|
+
* that has no filesystem — which is a caller error (supply the artifact in
|
|
28
|
+
* memory), and is reported as one.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getFileSystemBridge(): FileSystemBridge;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-reading bridge.
|
|
3
|
+
*
|
|
4
|
+
* `VerifierRequest` accepts artifacts either in memory or by path. Paths are a
|
|
5
|
+
* Node convenience (the CLI reads files); a browser always supplies artifacts in
|
|
6
|
+
* memory, because the material it verifies is already in the page.
|
|
7
|
+
*
|
|
8
|
+
* Keeping `node:fs`/`node:path` behind this bridge is what lets a browser bundle
|
|
9
|
+
* exclude them: nothing a browser imports reaches the Node implementation, so
|
|
10
|
+
* the built-ins never enter the module graph. If a path IS supplied without a
|
|
11
|
+
* bridge registered, the read fails with a clear error rather than a bundler's
|
|
12
|
+
* cryptic "module not found".
|
|
13
|
+
*/
|
|
14
|
+
let _bridge = null;
|
|
15
|
+
/** Install the Node implementation. Called by `register-node-fs.ts`. */
|
|
16
|
+
export function registerFileSystemBridge(bridge) {
|
|
17
|
+
_bridge = bridge;
|
|
18
|
+
}
|
|
19
|
+
export function hasFileSystemBridge() {
|
|
20
|
+
return _bridge !== null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The active bridge. Throws when a path-based artifact is requested in a runtime
|
|
24
|
+
* that has no filesystem — which is a caller error (supply the artifact in
|
|
25
|
+
* memory), and is reported as one.
|
|
26
|
+
*/
|
|
27
|
+
export function getFileSystemBridge() {
|
|
28
|
+
if (!_bridge) {
|
|
29
|
+
throw new Error("no filesystem available in this runtime: supply artifacts in memory " +
|
|
30
|
+
"(base_certificate, independence_proof, original_material, …) rather " +
|
|
31
|
+
"than by *_path");
|
|
32
|
+
}
|
|
33
|
+
return _bridge;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=fs-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-bridge.js","sourceRoot":"","sources":["../../../core/input/fs-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,IAAI,OAAO,GAA4B,IAAI,CAAC;AAE5C,wEAAwE;AACxE,MAAM,UAAU,wBAAwB,CAAC,MAAwB;IAC/D,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,KAAK,IAAI,CAAC;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,sEAAsE;YACpE,sEAAsE;YACtE,gBAAgB,CACnB,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getFileSystemBridge } from "./fs-bridge.js";
|
|
2
|
+
import { strictJsonParse } from "./strict-json.js";
|
|
3
|
+
import { loadOriginalMaterial } from "./load-original-material.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve one artifact: the in-memory value wins, else the file is read and
|
|
6
|
+
* strict-parsed, else null.
|
|
7
|
+
*
|
|
8
|
+
* The precedence is deliberate and one-directional — an in-memory artifact is
|
|
9
|
+
* something the caller already holds, so re-reading a path it also passed would
|
|
10
|
+
* silently ignore what it handed us. Neither form is deprecated: the CLI reads
|
|
11
|
+
* files, a service passes objects.
|
|
12
|
+
*/
|
|
13
|
+
function resolve(inMemory, path) {
|
|
14
|
+
if (inMemory !== undefined)
|
|
15
|
+
return inMemory;
|
|
16
|
+
if (!path)
|
|
17
|
+
return null;
|
|
18
|
+
return strictJsonParse(getFileSystemBridge().readTextFile(path));
|
|
19
|
+
}
|
|
20
|
+
export function loadArtifacts(request) {
|
|
21
|
+
const result = {
|
|
22
|
+
baseCertificate: null,
|
|
23
|
+
independenceProof: null,
|
|
24
|
+
settlementMaterial: null,
|
|
25
|
+
capacityEvidence: null,
|
|
26
|
+
commitmentInclusionProof: null,
|
|
27
|
+
verificationPackage: null,
|
|
28
|
+
originalMaterialPath: request.original_material_path ?? null,
|
|
29
|
+
// The subject-material map is loaded from originalMaterialPath by
|
|
30
|
+
// loadOriginalMaterial below (delivery container). Null means no
|
|
31
|
+
// material was supplied → the complete-verification plane is not performed;
|
|
32
|
+
// the structural Independent/Issued result still stands.
|
|
33
|
+
originalMaterial: null,
|
|
34
|
+
systemFoundation: null,
|
|
35
|
+
};
|
|
36
|
+
const pkgIn = resolve(request.verification_package, request.verification_package_path);
|
|
37
|
+
if (request.input_mode === "package" && pkgIn !== null) {
|
|
38
|
+
// Kept as delivered: PACKAGE_STRUCTURE_VALID decides whether it is a package
|
|
39
|
+
// at all before any member below is used.
|
|
40
|
+
result.verificationPackage = pkgIn;
|
|
41
|
+
const pkg = pkgIn;
|
|
42
|
+
if (typeof pkg === "object" && !Array.isArray(pkg)) {
|
|
43
|
+
result.baseCertificate = pkg.base_certificate ?? null;
|
|
44
|
+
result.independenceProof = pkg.independence_proof ?? null;
|
|
45
|
+
result.settlementMaterial = pkg.settlement_material ?? null;
|
|
46
|
+
result.capacityEvidence = pkg.capacity_evidence ?? null;
|
|
47
|
+
result.commitmentInclusionProof =
|
|
48
|
+
pkg.commitment_inclusion_proof ?? null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (request.input_mode === "artifact_set") {
|
|
52
|
+
result.baseCertificate = resolve(request.base_certificate, request.base_certificate_path);
|
|
53
|
+
result.independenceProof = resolve(request.independence_proof, request.independence_proof_path);
|
|
54
|
+
result.settlementMaterial = resolve(request.settlement_material, request.settlement_material_path);
|
|
55
|
+
result.capacityEvidence = resolve(request.capacity_evidence, request.capacity_evidence_path);
|
|
56
|
+
result.commitmentInclusionProof = resolve(request.commitment_inclusion_proof, request.commitment_inclusion_proof_path);
|
|
57
|
+
}
|
|
58
|
+
// The system foundation is never a package member: it is public rules
|
|
59
|
+
// material the verifier obtains itself, pinned by the
|
|
60
|
+
// foundation_statement_id and root fingerprint of its configuration
|
|
61
|
+
// (verifier-toolkit/1 §8.2), in either mode.
|
|
62
|
+
result.systemFoundation = resolve(request.system_foundation, request.system_foundation_path);
|
|
63
|
+
// Verifier-local original material (optional, both modes). The path points at
|
|
64
|
+
// a subject-material manifest (delivery container); loaded into the
|
|
65
|
+
// index → bytes map the complete-verification plane consumes.
|
|
66
|
+
// In-memory wins, as everywhere above. A bare Uint8Array is accepted as
|
|
67
|
+
// shorthand for the single-subject case (index 0) — the common shape by far,
|
|
68
|
+
// and spelling out `new Map([[0, bytes]])` for it is noise.
|
|
69
|
+
if (request.original_material !== undefined) {
|
|
70
|
+
result.originalMaterial =
|
|
71
|
+
request.original_material instanceof Uint8Array
|
|
72
|
+
? new Map([[0, request.original_material]])
|
|
73
|
+
: request.original_material;
|
|
74
|
+
}
|
|
75
|
+
else if (request.original_material_path) {
|
|
76
|
+
result.originalMaterial = loadOriginalMaterial(request.original_material_path);
|
|
77
|
+
}
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=load-artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-artifacts.js","sourceRoot":"","sources":["../../../core/input/load-artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAYrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE;;;;;;;;GAQG;AACH,SAAS,OAAO,CAAI,QAAuB,EAAE,IAAwB;IACnE,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,QAAQ,CAAC;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,eAAe,CAAC,mBAAmB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAM,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,MAAM,MAAM,GAAoB;QAC9B,eAAe,EAAE,IAAI;QACrB,iBAAiB,EAAE,IAAI;QACvB,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,IAAI;QACtB,wBAAwB,EAAE,IAAI;QAC9B,mBAAmB,EAAE,IAAI;QACzB,oBAAoB,EAAE,OAAO,CAAC,sBAAsB,IAAI,IAAI;QAC5D,kEAAkE;QAClE,iEAAiE;QACjE,4EAA4E;QAC5E,yDAAyD;QACzD,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,IAAI;KACvB,CAAC;IAEF,MAAM,KAAK,GAAG,OAAO,CACnB,OAAO,CAAC,oBAAoB,EAC5B,OAAO,CAAC,yBAAyB,CAClC,CAAC;IACF,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACvD,6EAA6E;QAC7E,0C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BAAgB,GAAG,OAAO,CAC/B,OAAO,CAAC,iBAAiB,EACzB,OAAO,CAAC,sBAAsB,CAC/B,CAAC;IAEF,8EAA8E;IAC9E,oEAAoE;IACpE,8DAA8D;IAC9D,wEAAwE;IACxE,6EAA6E;IAC7E,4DAA4D;IAC5D,IAAI,OAAO,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,CAAC,gBAAgB;YACrB,OAAO,CAAC,iBAAiB,YAAY,UAAU;gBAC7C,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBAC3C,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;IAClC,CAAC;SAAM,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QAC1C,MAAM,CAAC,gBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACjF,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SubjectMaterialMap } from "../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read the subject-material manifest at `manifestPath` and build the
|
|
4
|
+
* SubjectMaterialMap keyed by zero-based subject index.
|
|
5
|
+
*
|
|
6
|
+
* Throws on a manifest that is not a JSON array or whose entries are malformed;
|
|
7
|
+
* the CLI surfaces that as a usage error. Per-subject *verification* outcomes
|
|
8
|
+
* (missing subject, cardinality mismatch, unsupported profile, commitment
|
|
9
|
+
* mismatch) are decided later by verifyOriginalMaterial against the certificate.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadOriginalMaterial(manifestPath: string): SubjectMaterialMap;
|