xoonya 3.1.17 → 3.2.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.
Files changed (240) hide show
  1. package/README.md +97 -74
  2. package/RELEASE_NOTES.md +1 -1
  3. package/START_HERE.md +38 -134
  4. package/bin/xoonya-first-run.js +22 -10
  5. package/bin/xoonya.js +61 -29
  6. package/lib/native_verify.js +1918 -0
  7. package/package.json +19 -42
  8. package/scripts/verify_release_candidate.js +243 -116
  9. package/scripts/verify_vectors.js +351 -104
  10. package/verify.js +95 -0
  11. package/.env.example +0 -10
  12. package/CARRIED_HANDOFF_DEMO.md +0 -60
  13. package/COMPATIBILITY_NOTE.md +0 -27
  14. package/CROSS_RUNTIME_POSTURE.md +0 -77
  15. package/EXAMPLE_PATHS.md +0 -53
  16. package/FINAL_CONTRACT.md +0 -445
  17. package/PARTNER_READY_PATH.md +0 -67
  18. package/PUBLIC_DEMO_SCRIPT.md +0 -79
  19. package/SERVICE_CONTRACT.md +0 -207
  20. package/TERMINOLOGY.md +0 -55
  21. package/WHY_XYTARA_XOONYA.md +0 -43
  22. package/XNYA_CONFORMANCE_MARK.md +0 -78
  23. package/XNYA_REFERENCE_IMPLEMENTATIONS.md +0 -157
  24. package/XOONYA_DEFAULT_PATH_MODEL.md +0 -63
  25. package/XOONYA_FOLLOWTHROUGH_TRUTH_MODEL.md +0 -63
  26. package/XOONYA_NATIVE_ATOM_SPEC.md +0 -184
  27. package/XOONYA_NATIVE_PROOF_FORMAT.md +0 -570
  28. package/XOONYA_NATIVE_STANDARD_GOVERNANCE.md +0 -119
  29. package/XOONYA_PROOF_TRUTH_MODEL.md +0 -58
  30. package/bin/xoonya-release.js +0 -1367
  31. package/bin/xoonya-review.js +0 -70
  32. package/examples/integration_boundary_walkthrough.js +0 -37
  33. package/examples/package_quickstart.js +0 -1007
  34. package/examples/partner_proof_walkthrough.js +0 -68
  35. package/examples/proof_review_walkthrough.js +0 -66
  36. package/examples/review_carried_handoff.js +0 -72
  37. package/index.js +0 -31
  38. package/integrations/PROOF_INTEGRATION_PROCESS.md +0 -45
  39. package/integrations/examples/example-third-party-verifier-registration.record.json +0 -22
  40. package/integrations/registration-record.schema.json +0 -99
  41. package/integrations/registry-snapshot.schema.json +0 -36
  42. package/integrations/registry.js +0 -636
  43. package/integrations/views.js +0 -36
  44. package/lib/adapter_certification_contract.js +0 -90
  45. package/lib/announcement_pack.js +0 -61
  46. package/lib/artifact_distribution_lane_contract.js +0 -54
  47. package/lib/asyncapi_contract.js +0 -135
  48. package/lib/auth_interop_contract.js +0 -69
  49. package/lib/authority_binding_lifecycle_contract.js +0 -182
  50. package/lib/bridge_intelligence.js +0 -102
  51. package/lib/cloudevents_contract.js +0 -79
  52. package/lib/crypto_agility_matrix.js +0 -131
  53. package/lib/default_path_contract.js +0 -380
  54. package/lib/ecosystem_entry.js +0 -64
  55. package/lib/erc8004_proof_lane_contract.js +0 -64
  56. package/lib/event_system_lane_contract.js +0 -76
  57. package/lib/external_proof_import_lane_contract.js +0 -87
  58. package/lib/feature_control_lane_contract.js +0 -54
  59. package/lib/followthrough_truth_contract.js +0 -214
  60. package/lib/framework_lane_contract.js +0 -76
  61. package/lib/governance_disputes_summary.js +0 -36
  62. package/lib/governance_intelligence.js +0 -108
  63. package/lib/identity_interop_contract.js +0 -83
  64. package/lib/integration_matrix_contract.js +0 -81
  65. package/lib/launch_narrative.js +0 -53
  66. package/lib/machine_identity_registry_contract.js +0 -199
  67. package/lib/major_rails_proof_lane_contract.js +0 -87
  68. package/lib/offline_verifiability_recovery_contract.js +0 -155
  69. package/lib/openapi_contract.js +0 -227
  70. package/lib/operational_receipt_contract.js +0 -165
  71. package/lib/outreach_proof.js +0 -71
  72. package/lib/phase_10_closeout_pack.js +0 -45
  73. package/lib/phase_10_completion_pack.js +0 -76
  74. package/lib/phase_10_decision_record_pack.js +0 -54
  75. package/lib/phase_10_decision_resolution_pack.js +0 -53
  76. package/lib/phase_10_demand_signal_adapters_proof_pack.js +0 -74
  77. package/lib/phase_10_ecosystem_backlog_triage_proof_pack.js +0 -74
  78. package/lib/phase_10_freeze_baseline_pack.js +0 -67
  79. package/lib/phase_10_freeze_review_pack.js +0 -64
  80. package/lib/phase_10_gate_pack.js +0 -57
  81. package/lib/phase_10_long_tail_continuity_pack.js +0 -80
  82. package/lib/phase_10_long_tail_ecosystem_pack.js +0 -68
  83. package/lib/phase_10_niche_extension_registry_proof_pack.js +0 -74
  84. package/lib/phase_1_claude_mcp_pack.js +0 -60
  85. package/lib/phase_1_claude_mcp_proof_pack.js +0 -57
  86. package/lib/phase_1_ecosystem_pack.js +0 -51
  87. package/lib/phase_1_openai_codex_pack.js +0 -60
  88. package/lib/phase_1_openai_codex_proof_pack.js +0 -57
  89. package/lib/phase_2_base_proof_pack.js +0 -71
  90. package/lib/phase_2_base_usdc_proof_pack.js +0 -72
  91. package/lib/phase_2_closeout_pack.js +0 -65
  92. package/lib/phase_2_completion_pack.js +0 -113
  93. package/lib/phase_2_decision_record_pack.js +0 -66
  94. package/lib/phase_2_decision_resolution_pack.js +0 -69
  95. package/lib/phase_2_eth_proof_pack.js +0 -70
  96. package/lib/phase_2_evm_base_proof_pack.js +0 -73
  97. package/lib/phase_2_evm_proof_pack.js +0 -71
  98. package/lib/phase_2_flip_preview_pack.js +0 -60
  99. package/lib/phase_2_freeze_review_pack.js +0 -99
  100. package/lib/phase_2_gate_pack.js +0 -77
  101. package/lib/phase_2_payment_rails_pack.js +0 -71
  102. package/lib/phase_2_usdc_proof_pack.js +0 -71
  103. package/lib/phase_3_brc_proof_pack.js +0 -81
  104. package/lib/phase_3_bsv_teranode_proof_pack.js +0 -81
  105. package/lib/phase_3_closeout_pack.js +0 -62
  106. package/lib/phase_3_completion_pack.js +0 -92
  107. package/lib/phase_3_decision_record_pack.js +0 -64
  108. package/lib/phase_3_decision_resolution_pack.js +0 -69
  109. package/lib/phase_3_freeze_baseline_pack.js +0 -67
  110. package/lib/phase_3_freeze_review_pack.js +0 -80
  111. package/lib/phase_3_gate_pack.js +0 -76
  112. package/lib/phase_3_metanet_proof_pack.js +0 -81
  113. package/lib/phase_3_native_bsv_pack.js +0 -89
  114. package/lib/phase_3_native_continuity_pack.js +0 -82
  115. package/lib/phase_4_attestation_proof_pack.js +0 -75
  116. package/lib/phase_4_closeout_pack.js +0 -45
  117. package/lib/phase_4_completion_pack.js +0 -82
  118. package/lib/phase_4_decision_record_pack.js +0 -54
  119. package/lib/phase_4_decision_resolution_pack.js +0 -45
  120. package/lib/phase_4_erc8004_proof_pack.js +0 -76
  121. package/lib/phase_4_freeze_baseline_pack.js +0 -67
  122. package/lib/phase_4_freeze_review_pack.js +0 -68
  123. package/lib/phase_4_gate_pack.js +0 -58
  124. package/lib/phase_4_identity_registry_proof_pack.js +0 -75
  125. package/lib/phase_4_identity_trust_pack.js +0 -73
  126. package/lib/phase_4_trust_continuity_pack.js +0 -86
  127. package/lib/phase_5_antelope_proof_pack.js +0 -76
  128. package/lib/phase_5_closeout_pack.js +0 -44
  129. package/lib/phase_5_completion_pack.js +0 -82
  130. package/lib/phase_5_decision_record_pack.js +0 -54
  131. package/lib/phase_5_decision_resolution_pack.js +0 -45
  132. package/lib/phase_5_freeze_baseline_pack.js +0 -67
  133. package/lib/phase_5_freeze_review_pack.js +0 -68
  134. package/lib/phase_5_gate_pack.js +0 -58
  135. package/lib/phase_5_major_rails_continuity_pack.js +0 -86
  136. package/lib/phase_5_major_rails_pack.js +0 -74
  137. package/lib/phase_5_proton_xpr_proof_pack.js +0 -76
  138. package/lib/phase_5_solana_proof_pack.js +0 -76
  139. package/lib/phase_6_autogen_proof_pack.js +0 -74
  140. package/lib/phase_6_closeout_pack.js +0 -46
  141. package/lib/phase_6_completion_pack.js +0 -77
  142. package/lib/phase_6_decision_record_pack.js +0 -54
  143. package/lib/phase_6_decision_resolution_pack.js +0 -53
  144. package/lib/phase_6_framework_continuity_pack.js +0 -81
  145. package/lib/phase_6_framework_runtime_pack.js +0 -68
  146. package/lib/phase_6_freeze_baseline_pack.js +0 -68
  147. package/lib/phase_6_freeze_review_pack.js +0 -65
  148. package/lib/phase_6_gate_pack.js +0 -59
  149. package/lib/phase_6_langchain_proof_pack.js +0 -74
  150. package/lib/phase_6_langgraph_proof_pack.js +0 -74
  151. package/lib/phase_6_semantic_kernel_proof_pack.js +0 -74
  152. package/lib/phase_7_closeout_pack.js +0 -45
  153. package/lib/phase_7_completion_pack.js +0 -85
  154. package/lib/phase_7_decision_record_pack.js +0 -53
  155. package/lib/phase_7_decision_resolution_pack.js +0 -53
  156. package/lib/phase_7_event_system_continuity_pack.js +0 -89
  157. package/lib/phase_7_event_system_pack.js +0 -76
  158. package/lib/phase_7_freeze_baseline_pack.js +0 -74
  159. package/lib/phase_7_freeze_review_pack.js +0 -65
  160. package/lib/phase_7_gate_pack.js +0 -58
  161. package/lib/phase_7_kafka_proof_pack.js +0 -76
  162. package/lib/phase_7_mqtt_proof_pack.js +0 -76
  163. package/lib/phase_7_nats_proof_pack.js +0 -76
  164. package/lib/phase_7_webhook_event_bus_proof_pack.js +0 -76
  165. package/lib/phase_8_closeout_pack.js +0 -46
  166. package/lib/phase_8_completion_pack.js +0 -82
  167. package/lib/phase_8_decision_record_pack.js +0 -54
  168. package/lib/phase_8_decision_resolution_pack.js +0 -53
  169. package/lib/phase_8_external_receipt_import_proof_pack.js +0 -74
  170. package/lib/phase_8_external_result_import_proof_pack.js +0 -74
  171. package/lib/phase_8_freeze_baseline_pack.js +0 -71
  172. package/lib/phase_8_freeze_review_pack.js +0 -64
  173. package/lib/phase_8_gate_pack.js +0 -58
  174. package/lib/phase_8_proof_bridge_continuity_pack.js +0 -86
  175. package/lib/phase_8_proof_bridges_pack.js +0 -72
  176. package/lib/phase_8_proof_bundle_normalization_proof_pack.js +0 -74
  177. package/lib/phase_9_closeout_pack.js +0 -46
  178. package/lib/phase_9_completion_pack.js +0 -82
  179. package/lib/phase_9_custody_refs_proof_pack.js +0 -74
  180. package/lib/phase_9_decision_record_pack.js +0 -54
  181. package/lib/phase_9_decision_resolution_pack.js +0 -53
  182. package/lib/phase_9_freeze_baseline_pack.js +0 -71
  183. package/lib/phase_9_freeze_review_pack.js +0 -64
  184. package/lib/phase_9_gate_pack.js +0 -58
  185. package/lib/phase_9_operator_accounting_bridges_proof_pack.js +0 -74
  186. package/lib/phase_9_treasury_connectivity_pack.js +0 -72
  187. package/lib/phase_9_treasury_continuity_pack.js +0 -86
  188. package/lib/phase_9_treasury_destinations_proof_pack.js +0 -74
  189. package/lib/phase_program_pack.js +0 -47
  190. package/lib/proof_bridge_lane_contract.js +0 -82
  191. package/lib/proof_truth_contract.js +0 -224
  192. package/lib/provenance_lane_contract.js +0 -54
  193. package/lib/provider_lane_contract.js +0 -67
  194. package/lib/public_surface_policy_contract.js +0 -111
  195. package/lib/publish_plan.js +0 -51
  196. package/lib/release_candidate.js +0 -50
  197. package/lib/release_center.js +0 -1037
  198. package/lib/release_history.js +0 -206
  199. package/lib/release_manifest.js +0 -114
  200. package/lib/release_pack.js +0 -391
  201. package/lib/result_package_trust_lane_contract.js +0 -74
  202. package/lib/review_intelligence.js +0 -100
  203. package/lib/role_freeze.js +0 -436
  204. package/lib/shared_signals_lane_contract.js +0 -54
  205. package/lib/signed_audit_provenance_contract.js +0 -93
  206. package/lib/telemetry_lane_contract.js +0 -54
  207. package/lib/treasury_proof_lane_contract.js +0 -83
  208. package/lib/trust_intelligence.js +0 -106
  209. package/lib/trust_portability_boundary_contract.js +0 -66
  210. package/lib/trust_portability_pack.js +0 -224
  211. package/lib/verification_service_pack.js +0 -149
  212. package/proof_sdk.js +0 -6692
  213. package/reference/python/README.md +0 -35
  214. package/reference/python/requirements-optional.txt +0 -1
  215. package/reference/python/verify_vectors.py +0 -223
  216. package/reference/python/xnya_reference.py +0 -810
  217. package/reference/rust/Cargo.toml +0 -11
  218. package/reference/rust/README.md +0 -28
  219. package/reference/rust/src/lib.rs +0 -87
  220. package/scripts/registry_cli.js +0 -157
  221. package/scripts/verify_all.js +0 -603
  222. package/scripts/verify_control_plane_contracts.js +0 -34
  223. package/scripts/verify_control_plane_routes.js +0 -70
  224. package/scripts/verify_examples.js +0 -19
  225. package/scripts/verify_external_proof_import_gate.js +0 -84
  226. package/scripts/verify_external_proof_signature.js +0 -142
  227. package/scripts/verify_forgery_resistance.js +0 -281
  228. package/scripts/verify_integrations.js +0 -170
  229. package/scripts/verify_native_hybrid_design_gate.js +0 -114
  230. package/scripts/verify_paid_execute.js +0 -133
  231. package/scripts/verify_paywall_flag.js +0 -86
  232. package/scripts/verify_reference_promotion_gate.js +0 -74
  233. package/scripts/verify_reference_python.js +0 -49
  234. package/scripts/verify_reference_python_crypto.js +0 -87
  235. package/scripts/verify_reference_rust_scaffold.js +0 -50
  236. package/scripts/verify_service.js +0 -3038
  237. package/scripts/verify_tooling.js +0 -1251
  238. package/scripts/verify_trust_portability.js +0 -56
  239. package/scripts/verify_verification_services.js +0 -56
  240. package/server.js +0 -4430
@@ -1,70 +0,0 @@
1
- "use strict";
2
-
3
- const assert = require("assert");
4
- const { createServer } = require("../server.js");
5
-
6
- async function getJson(baseUrl, route) {
7
- const response = await fetch(`${baseUrl}${route}`);
8
- return {
9
- status: response.status,
10
- json: await response.json()
11
- };
12
- }
13
-
14
- async function main() {
15
- const server = createServer();
16
- await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
17
- const address = server.address();
18
- const baseUrl = `http://127.0.0.1:${address.port}`;
19
-
20
- try {
21
- const adapterCertification = await getJson(baseUrl, "/v1/adapter-certification");
22
- assert.strictEqual(adapterCertification.status, 200, "adapter certification route failed");
23
- assert.strictEqual(adapterCertification.json.category, "naxytra-adapter-certification-contract", "adapter certification category mismatch");
24
- assert.strictEqual(adapterCertification.json.certification_fronts.length >= 8, true, "adapter certification front count mismatch");
25
-
26
- const adapterCertificationSummary = await getJson(baseUrl, "/v1/adapter-certification/summary");
27
- assert.strictEqual(adapterCertificationSummary.status, 200, "adapter certification summary route failed");
28
- assert.strictEqual(adapterCertificationSummary.json.certification_state_count >= 5, true, "adapter certification summary count mismatch");
29
-
30
- const adapterCertificationDetail = await getJson(baseUrl, "/v1/adapter-certification/protocol_front");
31
- assert.strictEqual(adapterCertificationDetail.status, 200, "adapter certification detail route failed");
32
- assert.strictEqual(adapterCertificationDetail.json.front.front_id, "protocol_front", "adapter certification detail mismatch");
33
-
34
- const trustBoundary = await getJson(baseUrl, "/v1/trust-portability-boundary");
35
- assert.strictEqual(trustBoundary.status, 200, "trust portability boundary route failed");
36
- assert.strictEqual(trustBoundary.json.category, "naxytra-trust-portability-boundary-contract", "trust portability boundary category mismatch");
37
- assert.strictEqual(trustBoundary.json.portable_axes.length >= 4, true, "trust portability boundary axis count mismatch");
38
-
39
- const trustBoundarySummary = await getJson(baseUrl, "/v1/trust-portability-boundary/summary");
40
- assert.strictEqual(trustBoundarySummary.status, 200, "trust portability boundary summary route failed");
41
- assert.strictEqual(trustBoundarySummary.json.portable_axis_count >= 4, true, "trust portability boundary summary count mismatch");
42
-
43
- const trustBoundaryDetail = await getJson(baseUrl, "/v1/trust-portability-boundary/agent_identity_portability");
44
- assert.strictEqual(trustBoundaryDetail.status, 200, "trust portability boundary detail route failed");
45
- assert.strictEqual(trustBoundaryDetail.json.axis.axis_id, "agent_identity_portability", "trust portability boundary detail mismatch");
46
-
47
- const signedAudit = await getJson(baseUrl, "/v1/signed-audit-provenance");
48
- assert.strictEqual(signedAudit.status, 200, "signed audit provenance route failed");
49
- assert.strictEqual(signedAudit.json.category, "naxytra-signed-audit-provenance-contract", "signed audit provenance category mismatch");
50
- assert.strictEqual(signedAudit.json.evidence_surfaces.length >= 6, true, "signed audit provenance evidence surface count mismatch");
51
-
52
- const signedAuditSummary = await getJson(baseUrl, "/v1/signed-audit-provenance/summary");
53
- assert.strictEqual(signedAuditSummary.status, 200, "signed audit provenance summary route failed");
54
- assert.strictEqual(signedAuditSummary.json.evidence_surface_count >= 6, true, "signed audit provenance summary count mismatch");
55
-
56
- const signedAuditDetail = await getJson(baseUrl, "/v1/signed-audit-provenance/release_provenance");
57
- assert.strictEqual(signedAuditDetail.status, 200, "signed audit provenance detail route failed");
58
- assert.strictEqual(signedAuditDetail.json.surface.surface_id, "release_provenance", "signed audit provenance detail mismatch");
59
- } finally {
60
- await new Promise((resolve) => server.close(resolve));
61
- }
62
-
63
- console.log("xoonya verify:control-plane-routes passed");
64
- }
65
-
66
- main().catch((error) => {
67
- console.error(error);
68
- process.exit(1);
69
- });
70
-
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- const { spawnSync } = require("child_process");
4
- const path = require("path");
5
-
6
- function runExample(scriptPath) {
7
- const result = spawnSync(process.execPath, [scriptPath], {
8
- stdio: "inherit"
9
- });
10
- if (result.status !== 0) {
11
- process.exit(result.status || 1);
12
- }
13
- }
14
-
15
- runExample(path.join(__dirname, "..", "examples", "package_quickstart.js"));
16
- runExample(path.join(__dirname, "..", "examples", "review_carried_handoff.js"));
17
- runExample(path.join(__dirname, "..", "examples", "partner_proof_walkthrough.js"));
18
- runExample(path.join(__dirname, "..", "examples", "proof_review_walkthrough.js"));
19
- runExample(path.join(__dirname, "..", "examples", "integration_boundary_walkthrough.js"));
@@ -1,84 +0,0 @@
1
- "use strict";
2
-
3
- const assert = require("assert");
4
- const {
5
- buildExternalProofImportAdapterPack,
6
- validateExternalProofImportEvidence
7
- } = require("../proof_sdk");
8
-
9
- function validImport() {
10
- return {
11
- method: "jwt-assertion-v1",
12
- import_ref: "external-import-gate-demo",
13
- issuer_ref: "did:example:issuer",
14
- subject_ref: "txn:xytara:demo",
15
- external_proof: "eyJhbGciOiJFZERTQSJ9.eyJzdWIiOiJ0eG4teHl0YXJhLWRlbW8ifQ.signature",
16
- evidence_refs: ["memory://external/import-gate-demo"]
17
- };
18
- }
19
-
20
- function assertRejected(input, expectedCode) {
21
- const validation = validateExternalProofImportEvidence(input);
22
- assert.strictEqual(validation.import_allowed, false, `expected ${expectedCode} to block external proof import`);
23
- assert.strictEqual(
24
- validation.rejection_codes.includes(expectedCode),
25
- true,
26
- `missing deterministic rejection code ${expectedCode}`
27
- );
28
- return validation;
29
- }
30
-
31
- function main() {
32
- const pack = buildExternalProofImportAdapterPack();
33
- const validValidation = validateExternalProofImportEvidence(validImport());
34
-
35
- assert.strictEqual(pack.category, "xoonya-external-proof-import-adapter", "external import adapter category mismatch");
36
- assert.strictEqual(pack.deterministic_rejection_codes.length >= 11, true, "external import rejection code count missing");
37
- assert.strictEqual(validValidation.import_allowed, true, "valid structural external import should pass");
38
- assert.deepStrictEqual(validValidation.rejection_codes, [], "valid structural external import should not carry rejection codes");
39
-
40
- assertRejected({ ...validImport(), method: "" }, "verification_method_required");
41
- assertRejected({ ...validImport(), method: "unknown-method-v1" }, "verification_method_unsupported");
42
- assertRejected({ ...validImport(), method: "xoonya-native-sha256-v1" }, "verification_method_not_external_importable");
43
- assertRejected({ method: "jwt-assertion-v1" }, "external_proof_material_required");
44
- assertRejected({ ...validImport(), external_proof: " " }, "external_proof_material_empty");
45
- assertRejected({ ...validImport(), declared_hash_sha256: "00".repeat(32) }, "external_proof_hash_mismatch");
46
- assertRejected({ ...validImport(), claim_external_issuer_truth: true }, "external_issuer_truth_claim_requires_external_verifier");
47
- assertRejected({ ...validImport(), claim_external_signature_truth: true }, "external_signature_truth_claim_requires_external_verifier");
48
- assertRejected({ ...validImport(), claim_external_revocation_status: true }, "external_revocation_status_claim_requires_external_verifier");
49
- assertRejected({ ...validImport(), method: "did-vc-v1", claim_did_resolution_truth: true }, "did_resolution_truth_claim_requires_external_verifier");
50
- assertRejected({ ...validImport(), external_verifier_api_key: "sk_live_accidental_secret" }, "secret_material_forbidden");
51
-
52
- const externallyVerified = validateExternalProofImportEvidence({
53
- ...validImport(),
54
- method: "did-vc-v1",
55
- external_proof: {
56
- "@context": ["https://www.w3.org/ns/credentials/v2"],
57
- type: ["VerifiableCredential"],
58
- issuer: "did:example:issuer",
59
- credentialSubject: { id: "did:example:agent" }
60
- },
61
- claim_external_issuer_truth: true,
62
- claim_external_signature_truth: true,
63
- claim_external_revocation_status: true,
64
- claim_did_resolution_truth: true,
65
- external_issuer_verifier_ref: "external.verifier.issuer.did-vc.2026-04-22",
66
- external_signature_verifier_ref: "external.verifier.signature.did-vc.2026-04-22",
67
- external_revocation_verifier_ref: "external.verifier.revocation.did-vc.2026-04-22",
68
- did_resolution_verifier_ref: "external.verifier.did_resolution.did-vc.2026-04-22"
69
- });
70
- assert.strictEqual(externallyVerified.import_allowed, true, "external verifier-backed truth claims should pass structural validation");
71
-
72
- const output = {
73
- ok: true,
74
- product: "xoonya",
75
- category: "xoonya-external-proof-import-gate-verification",
76
- status: "external_import_binds_evidence_without_claiming_external_truth_unless_external_verifier_refs_exist",
77
- deterministic_rejection_code_count: pack.deterministic_rejection_codes.length,
78
- adversarial_case_count: 11,
79
- boundary: "xoonya_imports_external_evidence_but_external_issuer_signature_revocation_and_did_truth_stay_with_external_verifiers"
80
- };
81
- process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
82
- }
83
-
84
- main();
@@ -1,142 +0,0 @@
1
- "use strict";
2
-
3
- // Verifies xoonya's external-proof signature verification (lib/external_proof_verify.js
4
- // + proof_sdk integration) under the HONEST trust model: it reports signature_valid
5
- // (a fact) + signing_key_ref, and only reports trust_anchored when the caller declared
6
- // an expected_key_ref that matches the signer. Covers JWS (EdDSA/ES256/RS256), the
7
- // alg<->key binding, alg:none/crit/malformed rejection, private-key refusal, detached
8
- // signatures, import-run promotion, and byte-for-byte backward compatibility.
9
-
10
- const crypto = require("crypto");
11
- const assert = require("assert");
12
- const { verifyJws, verifyDetachedSignature } = require("../lib/external_proof_verify");
13
-
14
- const b64url = (buf) => Buffer.from(buf).toString("base64url");
15
-
16
- function makeJws(alg, payloadObj, signFn, extraHeader) {
17
- const header = { alg, ...(extraHeader || {}) };
18
- const protectedB64 = b64url(Buffer.from(JSON.stringify(header), "utf8"));
19
- const payloadB64 = b64url(Buffer.from(JSON.stringify(payloadObj), "utf8"));
20
- const signingInput = `${protectedB64}.${payloadB64}`;
21
- return `${signingInput}.${b64url(signFn(Buffer.from(signingInput, "utf8")))}`;
22
- }
23
-
24
- function main() {
25
- const ed = crypto.generateKeyPairSync("ed25519");
26
- const edPubPem = ed.publicKey.export({ type: "spki", format: "pem" });
27
- const edJws = makeJws("EdDSA", { sub: "agent-1" }, (d) => crypto.sign(null, d, ed.privateKey));
28
-
29
- // 1. EdDSA JWS: signature_valid is a fact; trust requires a declared key ref.
30
- let r = verifyJws(edJws, { trusted_public_key: edPubPem });
31
- assert.strictEqual(r.ok, true);
32
- assert.strictEqual(r.signature_valid, true, "EdDSA signature valid");
33
- assert.ok(r.signing_key_ref && r.signing_key_ref.startsWith("ed25519-"));
34
- assert.strictEqual(r.trust_anchored, false, "no expected_key_ref -> not trust-anchored");
35
- const edRef = r.signing_key_ref;
36
- assert.strictEqual(verifyJws(edJws, { trusted_public_key: edPubPem, expected_key_ref: edRef }).trust_anchored, true, "matching expected_key_ref -> anchored");
37
- assert.strictEqual(verifyJws(edJws, { trusted_public_key: edPubPem, expected_key_ref: "ed25519-spki-sha256:deadbeef" }).trust_anchored, false, "wrong expected_key_ref -> not anchored");
38
-
39
- // wrong key / tamper -> signature invalid
40
- const ed2 = crypto.generateKeyPairSync("ed25519");
41
- assert.strictEqual(verifyJws(edJws, { trusted_public_key: ed2.publicKey.export({ type: "spki", format: "pem" }) }).signature_valid, false);
42
-
43
- // 2. Embedded self-asserted key: signature internally valid but NOT caller-supplied.
44
- const edJwk = ed.publicKey.export({ format: "jwk" });
45
- const edJwsEmbedded = makeJws("EdDSA", { sub: "agent-1" }, (d) => crypto.sign(null, d, ed.privateKey), { jwk: edJwk });
46
- r = verifyJws(edJwsEmbedded);
47
- assert.strictEqual(r.signature_valid, true, "embedded-key signature internally valid");
48
- assert.strictEqual(r.key_source, "embedded_self_asserted");
49
- assert.strictEqual(r.trust_anchored, false, "self-asserted key is never trust-anchored");
50
-
51
- // 3. ES256 works; alg<->key binding rejects an ES256K header over a P-256 key.
52
- const ec = crypto.generateKeyPairSync("ec", { namedCurve: "P-256" });
53
- const ecPubPem = ec.publicKey.export({ type: "spki", format: "pem" });
54
- const es256Jws = makeJws("ES256", { sub: "a" }, (d) => crypto.sign("sha256", d, { key: ec.privateKey, dsaEncoding: "ieee-p1363" }));
55
- assert.strictEqual(verifyJws(es256Jws, { trusted_public_key: ecPubPem }).signature_valid, true, "ES256 valid");
56
- const es256kMisdeclared = makeJws("ES256K", { sub: "a" }, (d) => crypto.sign("sha256", d, { key: ec.privateKey, dsaEncoding: "ieee-p1363" }));
57
- assert.strictEqual(verifyJws(es256kMisdeclared, { trusted_public_key: ecPubPem }).signature_valid, false, "alg<->key mismatch (ES256K over P-256) rejected");
58
-
59
- // 4. RS256
60
- const rsa = crypto.generateKeyPairSync("rsa", { modulusLength: 2048 });
61
- const rsaJws = makeJws("RS256", { sub: "a" }, (d) => crypto.sign("sha256", d, rsa.privateKey));
62
- assert.strictEqual(verifyJws(rsaJws, { trusted_public_key: rsa.publicKey.export({ type: "spki", format: "pem" }) }).signature_valid, true, "RS256 valid");
63
-
64
- // 5. none / crit / malformed / private-key refusal.
65
- assert.strictEqual(verifyJws(makeJws("none", { x: 1 }, () => Buffer.alloc(0)), { trusted_public_key: edPubPem }).reason, "jws_alg_none_rejected");
66
- const critJws = makeJws("EdDSA", { sub: "a" }, (d) => crypto.sign(null, d, ed.privateKey), { crit: ["exp"] });
67
- assert.strictEqual(verifyJws(critJws, { trusted_public_key: edPubPem }).reason, "jws_crit_unsupported");
68
- assert.strictEqual(verifyJws("only.two").reason, "jws_malformed");
69
- assert.strictEqual(verifyJws(edJws, { trusted_public_key: ed.privateKey.export({ type: "pkcs8", format: "pem" }) }).reason, "no_public_key", "PEM private key refused as trust key");
70
- assert.strictEqual(verifyJws(edJws, { trusted_public_key: ed.privateKey.export({ format: "jwk" }) }).reason, "no_public_key", "private JWK refused");
71
-
72
- // 6. Detached signature.
73
- const material = "x402-receipt:0xabc";
74
- const detSig = crypto.sign(null, Buffer.from(material), ed.privateKey).toString("base64");
75
- r = verifyDetachedSignature({ material, signature: detSig, signature_encoding: "base64", public_key: edPubPem, algorithm: "EdDSA", expected_key_ref: edRef });
76
- assert.strictEqual(r.signature_valid, true);
77
- assert.strictEqual(r.trust_anchored, true, "detached with matching expected_key_ref -> anchored");
78
- assert.strictEqual(verifyDetachedSignature({ material: "tampered", signature: detSig, signature_encoding: "base64", public_key: edPubPem, algorithm: "EdDSA" }).signature_valid, false);
79
-
80
- // 7. proof_sdk integration.
81
- const proofSdk = require("../proof_sdk");
82
- // no verification input -> structural, NO external_signature_* fields (byte-for-byte).
83
- const run0 = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss" });
84
- assert.strictEqual(run0.external_signature_valid, undefined, "no verification -> no top-level field");
85
- assert.strictEqual(run0.proof_bundle.attestations[0].external_signature_valid, undefined, "no verification -> no attestation field");
86
- assert.ok(String(run0.proof_bundle.attestations[0].verification_boundary).includes("external_truth_out_of_scope"));
87
- const run0Keys = Object.keys(run0.proof_bundle.attestations[0]).length;
88
-
89
- // A stray TOP-LEVEL signature/key field must NOT activate verification (namespace only).
90
- const run0b = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss", signature: "ZZZZ", public_key: edPubPem });
91
- assert.strictEqual(run0b.external_signature_valid, undefined, "top-level fields do not activate verification");
92
- assert.strictEqual(Object.keys(run0b.proof_bundle.attestations[0]).length, run0Keys, "attestation shape unchanged by stray top-level fields");
93
-
94
- // trusted key but no expected_key_ref -> signature_valid, NOT anchored; result echo is whitelisted.
95
- const run1 = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss", signature_verification: { trusted_public_key: edPubPem } });
96
- assert.strictEqual(run1.external_signature_valid, true, "imported JWS signature verified");
97
- assert.strictEqual(run1.external_signature_trust_anchored, false);
98
- assert.ok(String(run1.proof_bundle.attestations[0].verification_boundary).includes("consumer_decision"));
99
- assert.strictEqual(run1.signature_verification.header, undefined, "result echo does not leak JWS header");
100
- assert.strictEqual(run1.signature_verification.payload_b64url, undefined, "result echo does not leak payload");
101
-
102
- // declared expected_key_ref matching the signer -> trust-anchored.
103
- const run2 = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss", signature_verification: { trusted_public_key: edPubPem, expected_key_ref: edRef } });
104
- assert.strictEqual(run2.external_signature_trust_anchored, true, "declared+matching key -> anchored");
105
- assert.ok(String(run2.proof_bundle.attestations[0].verification_boundary).includes("cryptographically_verified_against_declared_key_ref"));
106
-
107
- // Requested-but-INVALID signature hard-fails the import (ok:false).
108
- const run3 = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss", signature_verification: { trusted_public_key: ed2.publicKey.export({ type: "spki", format: "pem" }) } });
109
- assert.strictEqual(run3.ok, false, "invalid requested signature hard-fails");
110
- assert.strictEqual(run3.reason, "external_signature_invalid");
111
- // ...unless the caller opts out.
112
- const run3b = proofSdk.runExternalProofImport({ method: "jwt-assertion-v1", token: edJws, issuer_ref: "iss", signature_verification: { trusted_public_key: ed2.publicKey.export({ type: "spki", format: "pem" }), require_valid_signature: false } });
113
- assert.strictEqual(run3b.ok, true, "opt-out records the import despite invalid signature");
114
- assert.strictEqual(run3b.external_signature_valid, false);
115
-
116
- // Object material + detached signature request -> unsupported (does not mislead), hard-fails by default.
117
- const run4 = proofSdk.runExternalProofImport({ method: "signed-envelope-v1", proof_envelope: { claim: "x" }, issuer_ref: "iss", signature_verification: { trusted_public_key: edPubPem, signature: "AA", algorithm: "EdDSA" } });
118
- assert.strictEqual(run4.ok, false);
119
- assert.strictEqual(run4.reason, "unsupported_import_signature_verification");
120
-
121
- // standalone function
122
- assert.strictEqual(proofSdk.verifyExternalProofSignature({ jws: edJws, trusted_public_key: edPubPem }).signature_valid, true);
123
- assert.strictEqual(proofSdk.verifyExternalProofSignature({}).reason, "no_signature_verification_input");
124
-
125
- // Detached ML-DSA-65 (FIPS-204): valid verifies + anchors to the declared key ref; tampered
126
- // material fails; the declared alg is bound to the key type (no cross-alg confusion).
127
- const mldsa = crypto.generateKeyPairSync("ml-dsa-65");
128
- const mlSpki = mldsa.publicKey.export({ type: "spki", format: "der" }).toString("base64");
129
- const mlRef = "ml-dsa-65-spki-sha256:" + crypto.createHash("sha256").update(mldsa.publicKey.export({ type: "spki", format: "der" })).digest("hex");
130
- const mlMaterial = '{"receipt":"x","v":1}';
131
- const mlSig = crypto.sign(null, Buffer.from(mlMaterial, "utf8"), mldsa.privateKey).toString("base64");
132
- const mlOk = proofSdk.verifyExternalProofSignature({ material: mlMaterial, signature: mlSig, algorithm: "ML-DSA-65", public_key: mlSpki, expected_key_ref: mlRef });
133
- assert.strictEqual(mlOk.signature_valid, true, "ML-DSA-65 detached signature verifies");
134
- assert.strictEqual(mlOk.trust_anchored, true, "ML-DSA-65 anchors to the declared key ref");
135
- assert.strictEqual(proofSdk.verifyExternalProofSignature({ material: mlMaterial + " ", signature: mlSig, algorithm: "ML-DSA-65", public_key: mlSpki }).signature_valid, false, "ML-DSA-65 tampered material fails");
136
- assert.strictEqual(proofSdk.verifyExternalProofSignature({ material: mlMaterial, signature: mlSig, algorithm: "ML-DSA-44", public_key: mlSpki }).signature_valid, false, "ML-DSA alg bound to the key's parameter set");
137
- assert.strictEqual(proofSdk.verifyExternalProofSignature({ material: mlMaterial, signature: mlSig, algorithm: "EdDSA", public_key: mlSpki }).signature_valid, false, "EdDSA cannot verify with an ML-DSA key");
138
-
139
- console.log("verify_external_proof_signature: all checks passed");
140
- }
141
-
142
- main();
@@ -1,281 +0,0 @@
1
- "use strict";
2
-
3
- // Forgery-resistance checks for the xoonya proof engine.
4
- //
5
- // This script talks to proof_sdk.js directly (no HTTP server) and pins down:
6
- // (a) key substitution: a proof signed by key B that claims key A's identity
7
- // self-verifies WITHOUT a trust root (known limitation, documented here)
8
- // and is rejected WITH a trust root pinned to key A;
9
- // (b) external methods are structural-only and fail under strict mode;
10
- // (c) the default digest method is digest-only and fails under strict mode;
11
- // (d) hybrid ed25519+ml-dsa-65: tampered PQ signature is rejected, and a
12
- // wrong pinned PQ ref yields native_hybrid_public_key_not_trusted;
13
- // (e) results are deterministic across repeated runs for the same inputs.
14
-
15
- const assert = require("assert");
16
- const crypto = require("crypto");
17
- const sdk = require("../proof_sdk.js");
18
-
19
- function canonicalize(value) {
20
- if (Array.isArray(value)) {
21
- return `[${value.map((item) => canonicalize(item)).join(",")}]`;
22
- }
23
- if (value && typeof value === "object") {
24
- const keys = Object.keys(value).sort();
25
- return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalize(value[key])}`).join(",")}}`;
26
- }
27
- return JSON.stringify(value);
28
- }
29
-
30
- function pem(key, type) {
31
- return key.export({ type, format: "pem" });
32
- }
33
-
34
- function tamperBase64url(value) {
35
- const last = value.slice(-1);
36
- return `${value.slice(0, -1)}${last === "A" ? "B" : "A"}`;
37
- }
38
-
39
- const event = {
40
- version: "canonical-event-bundle/v1",
41
- domain_id: "forgery.resistance",
42
- sequence: "1",
43
- actor_id: "alice",
44
- adapter_source: "verify_forgery_resistance",
45
- event_type: "proof.forgery.probe",
46
- event_hash: "cd".repeat(32)
47
- };
48
- const ALICE_IDENTITY_REF = "did:xoonya:alice";
49
-
50
- function signedReceiptFor(keyPair) {
51
- return sdk.emitReceipt(event, {
52
- agent_identity: "alice",
53
- algorithm: "xoonya-native-signed-v1",
54
- identity_ref: ALICE_IDENTITY_REF,
55
- signature_suite: "ed25519",
56
- private_key_pem: pem(keyPair.privateKey, "pkcs8"),
57
- public_key_pem: pem(keyPair.publicKey, "spki")
58
- });
59
- }
60
-
61
- function bundleFor(receipt) {
62
- return sdk.buildProofBundle({ ceb: event, receipt });
63
- }
64
-
65
- function checkKeySubstitution() {
66
- const keyA = crypto.generateKeyPairSync("ed25519");
67
- const keyB = crypto.generateKeyPairSync("ed25519");
68
- const receiptA = signedReceiptFor(keyA);
69
- const receiptB = signedReceiptFor(keyB);
70
- const refA = receiptA.native_proof.public_key_ref;
71
- const refB = receiptB.native_proof.public_key_ref;
72
- assert.notStrictEqual(refA, refB, "distinct keys must produce distinct public_key_ref values");
73
- assert.strictEqual(receiptB.native_proof.identity_ref, ALICE_IDENTITY_REF, "key B proof claims alice's identity_ref");
74
-
75
- // Known limitation: without a verifier-supplied trust root, public_key_ref is only
76
- // self-bound to the carried key material, so key B can claim alice's identity.
77
- const substitutionWithoutRoot = sdk.verifyProofBundle(bundleFor(receiptB));
78
- assert.strictEqual(substitutionWithoutRoot.valid, true, "key substitution self-verifies without a trust root (documented limitation)");
79
- assert.strictEqual(substitutionWithoutRoot.verification_class, "cryptographic", "native signed class must be cryptographic");
80
- assert.strictEqual(substitutionWithoutRoot.cryptographically_verified, true, "native signed proof must report cryptographic verification");
81
- assert.strictEqual(substitutionWithoutRoot.trust_root_applied, false, "trust_root_applied must be false without a trust root");
82
- assert.strictEqual(substitutionWithoutRoot.public_key_ref, refB, "verify result must surface the signing key ref so callers can pin it");
83
-
84
- const trustRoot = { trusted_public_key_refs: { [ALICE_IDENTITY_REF]: refA } };
85
- const substitutionWithRoot = sdk.verifyProofBundle(bundleFor(receiptB), trustRoot);
86
- assert.strictEqual(substitutionWithRoot.valid, false, "key substitution must be rejected with a pinned trust root");
87
- assert.strictEqual(substitutionWithRoot.reason, "native_public_key_not_trusted", "key substitution rejection reason mismatch");
88
- assert.strictEqual(substitutionWithRoot.trust_root_applied, true, "trust_root_applied must be true with a trust root");
89
- assert.strictEqual(substitutionWithRoot.cryptographically_verified, false, "rejected result must not claim cryptographic verification");
90
-
91
- const genuineWithRoot = sdk.verifyProofBundle(bundleFor(receiptA), trustRoot);
92
- assert.strictEqual(genuineWithRoot.valid, true, "genuine key A proof must verify with trust root pinned to key A");
93
- assert.strictEqual(genuineWithRoot.trust_root_applied, true, "genuine trust_root_applied mismatch");
94
-
95
- const genuineArrayRoot = sdk.verifyProofBundle(bundleFor(receiptA), { trusted_public_key_refs: { [ALICE_IDENTITY_REF]: [refB, refA] } });
96
- assert.strictEqual(genuineArrayRoot.valid, true, "array-valued trust root must accept any listed ref");
97
-
98
- const expectedRefRoot = sdk.verifyProofBundle(bundleFor(receiptB), { expected_public_key_ref: refA });
99
- assert.strictEqual(expectedRefRoot.reason, "native_public_key_not_trusted", "expected_public_key_ref must reject key B");
100
- assert.strictEqual(sdk.verifyProofBundle(bundleFor(receiptA), { expected_public_key_ref: refA }).valid, true, "expected_public_key_ref must accept key A");
101
-
102
- const unknownIdentityRoot = sdk.verifyProofBundle(bundleFor(receiptA), { trusted_public_key_refs: { "did:xoonya:bob": refA } });
103
- assert.strictEqual(unknownIdentityRoot.reason, "native_public_key_not_trusted", "identity absent from trust root must fail closed");
104
-
105
- const hybridOnlyRoot = sdk.verifyProofBundle(bundleFor(receiptA), { expected_pq_public_key_ref: "ml-dsa-65-spki-sha256:" + "00".repeat(32) });
106
- assert.strictEqual(hybridOnlyRoot.reason, "native_public_key_not_trusted", "a PQ-only pin against a classical-only proof must fail closed");
107
-
108
- const strictGenuine = sdk.verifyProofBundle(bundleFor(receiptA), { ...trustRoot, strict: true });
109
- assert.strictEqual(strictGenuine.valid, true, "cryptographic class must pass strict mode");
110
- return { refA, refB };
111
- }
112
-
113
- function checkExternalStructural() {
114
- const methods = ["jwt-assertion-v1", "did-vc-v1", "sd-jwt-vc-v1", "signed-envelope-v1", "partner-proof-envelope-v1", "detached-assertion-v1"];
115
- for (const methodId of methods) {
116
- const receipt = sdk.emitReceipt(event, {
117
- agent_identity: "alice",
118
- algorithm: methodId,
119
- signature: `garbage-signature-${crypto.randomBytes(8).toString("hex")}`
120
- });
121
- const relaxed = sdk.verifyProofBundle(bundleFor(receipt));
122
- assert.strictEqual(relaxed.valid, true, `${methodId} garbage signature is accepted structurally by default`);
123
- assert.strictEqual(relaxed.verification_class, "structural", `${methodId} class must be structural`);
124
- assert.strictEqual(relaxed.cryptographically_verified, false, `${methodId} must not claim cryptographic verification`);
125
- const strict = sdk.verifyProofBundle(bundleFor(receipt), { strict: true });
126
- assert.strictEqual(strict.valid, false, `${methodId} must fail under strict verification`);
127
- assert.strictEqual(strict.reason, "external_verification_required", `${methodId} strict rejection reason mismatch`);
128
- assert.strictEqual(strict.verification_class, "structural", `${methodId} strict class mismatch`);
129
- }
130
- }
131
-
132
- function checkDigestDefault() {
133
- const receipt = sdk.emitReceipt(event, { agent_identity: "alice" });
134
- assert.strictEqual(receipt.algorithm, "xoonya-native-sha256-v1", "default receipt method mismatch");
135
- const relaxed = sdk.verifyProofBundle(bundleFor(receipt));
136
- assert.strictEqual(relaxed.valid, true, "digest bundle verifies by default");
137
- assert.strictEqual(relaxed.verification_class, "digest", "digest class mismatch");
138
- assert.strictEqual(relaxed.cryptographically_verified, false, "digest must not claim cryptographic verification");
139
-
140
- // Anyone can forge a digest receipt for any identity: there is no key involved.
141
- const forged = sdk.emitReceipt(event, { agent_identity: "alice" });
142
- assert.strictEqual(forged.signature, receipt.signature, "digest receipts are reproducible by anyone who knows the event");
143
-
144
- const strict = sdk.verifyProofBundle(bundleFor(receipt), { strict: true });
145
- assert.strictEqual(strict.valid, false, "digest bundle must fail under strict verification");
146
- assert.strictEqual(strict.reason, "digest_only_not_cryptographically_verified", "strict digest reason mismatch");
147
-
148
- const previous = process.env.XOONYA_STRICT_VERIFY;
149
- process.env.XOONYA_STRICT_VERIFY = "1";
150
- try {
151
- const envStrict = sdk.verifyProofBundle(bundleFor(receipt));
152
- assert.strictEqual(envStrict.valid, false, "XOONYA_STRICT_VERIFY=1 must enable strict mode globally");
153
- assert.strictEqual(envStrict.strict, true, "env strict flag must echo in the result");
154
- } finally {
155
- if (previous === undefined) delete process.env.XOONYA_STRICT_VERIFY;
156
- else process.env.XOONYA_STRICT_VERIFY = previous;
157
- }
158
- }
159
-
160
- function checkHybrid() {
161
- const classical = crypto.generateKeyPairSync("ed25519");
162
- const pq = crypto.generateKeyPairSync("ml-dsa-65");
163
- const receipt = sdk.emitReceipt(event, {
164
- agent_identity: "alice",
165
- algorithm: "xoonya-native-hybrid-v1",
166
- identity_ref: ALICE_IDENTITY_REF,
167
- classical_signature_suite: "ed25519",
168
- pq_signature_suite: "ml-dsa-65",
169
- classical_public_key_pem: pem(classical.publicKey, "spki"),
170
- classical_private_key_pem: pem(classical.privateKey, "pkcs8"),
171
- pq_public_key_pem: pem(pq.publicKey, "spki"),
172
- pq_private_key_pem: pem(pq.privateKey, "pkcs8")
173
- });
174
- const bundle = bundleFor(receipt);
175
- const genuine = sdk.verifyProofBundle(bundle);
176
- assert.strictEqual(genuine.valid, true, "hybrid bundle must verify");
177
- assert.strictEqual(genuine.verification_class, "cryptographic", "hybrid class must be cryptographic");
178
- assert.strictEqual(genuine.cryptographically_verified, true, "hybrid must report cryptographic verification");
179
- assert.strictEqual(genuine.classical_public_key_ref, receipt.native_proof.classical_public_key_ref, "hybrid classical ref surfaced");
180
- assert.strictEqual(genuine.pq_public_key_ref, receipt.native_proof.pq_public_key_ref, "hybrid pq ref surfaced");
181
-
182
- const tamperedPqSignature = tamperBase64url(receipt.native_proof.proof_material.pq_signature);
183
- const tamperedReceipt = {
184
- ...receipt,
185
- native_proof: {
186
- ...receipt.native_proof,
187
- proof_material: { ...receipt.native_proof.proof_material, pq_signature: tamperedPqSignature }
188
- },
189
- signature: `xoonya-native-hybrid-v1:${receipt.native_proof.hybrid_suite}:${receipt.native_proof.proof_material.classical_signature}.${tamperedPqSignature}`
190
- };
191
- const tampered = sdk.verifyProofBundle(bundleFor(tamperedReceipt));
192
- assert.strictEqual(tampered.valid, false, "tampered PQ signature must be rejected");
193
- assert.strictEqual(tampered.reason, "native_hybrid_pq_signature_invalid", "tampered PQ signature reason mismatch");
194
- assert.strictEqual(tampered.cryptographically_verified, false, "tampered hybrid must not claim cryptographic verification");
195
-
196
- const wrongPqRef = `ml-dsa-65-spki-sha256:${"11".repeat(32)}`;
197
- const wrongPqPinned = sdk.verifyProofBundle(bundle, {
198
- trusted_public_key_refs: { [ALICE_IDENTITY_REF]: { classical: genuine.classical_public_key_ref, pq: wrongPqRef } }
199
- });
200
- assert.strictEqual(wrongPqPinned.valid, false, "wrong pinned PQ ref must be rejected");
201
- assert.strictEqual(wrongPqPinned.reason, "native_hybrid_public_key_not_trusted", "wrong PQ pin reason mismatch");
202
- assert.strictEqual(wrongPqPinned.trust_root_applied, true, "hybrid trust_root_applied mismatch");
203
-
204
- const wrongExpectedPq = sdk.verifyProofBundle(bundle, { expected_pq_public_key_ref: wrongPqRef });
205
- assert.strictEqual(wrongExpectedPq.reason, "native_hybrid_public_key_not_trusted", "expected_pq_public_key_ref mismatch must be rejected");
206
-
207
- const rightPinned = sdk.verifyProofBundle(bundle, {
208
- trusted_public_key_refs: { [ALICE_IDENTITY_REF]: { classical: genuine.classical_public_key_ref, pq: genuine.pq_public_key_ref } },
209
- strict: true
210
- });
211
- assert.strictEqual(rightPinned.valid, true, "correctly pinned hybrid must verify under strict mode");
212
-
213
- const classicalOnlyPin = sdk.verifyProofBundle(bundle, { trusted_public_key_refs: { [ALICE_IDENTITY_REF]: genuine.classical_public_key_ref } });
214
- assert.strictEqual(classicalOnlyPin.valid, true, "string-valued trust root pins the classical lane of a hybrid proof");
215
-
216
- const otherClassical = crypto.generateKeyPairSync("ed25519");
217
- const otherClassicalRef = sdk.emitReceipt(event, {
218
- agent_identity: "alice",
219
- algorithm: "xoonya-native-signed-v1",
220
- identity_ref: ALICE_IDENTITY_REF,
221
- signature_suite: "ed25519",
222
- private_key_pem: pem(otherClassical.privateKey, "pkcs8"),
223
- public_key_pem: pem(otherClassical.publicKey, "spki")
224
- }).native_proof.public_key_ref;
225
- const wrongClassicalPin = sdk.verifyProofBundle(bundle, { trusted_public_key_refs: { [ALICE_IDENTITY_REF]: otherClassicalRef } });
226
- assert.strictEqual(wrongClassicalPin.reason, "native_hybrid_public_key_not_trusted", "wrong classical pin on hybrid must be rejected");
227
- return bundle;
228
- }
229
-
230
- function checkDeterminism(hybridBundle, refs) {
231
- const keyA = crypto.generateKeyPairSync("ed25519");
232
- const signedBundle = bundleFor(signedReceiptFor(keyA));
233
- const digestBundle = bundleFor(sdk.emitReceipt(event, { agent_identity: "alice" }));
234
- const externalBundle = bundleFor(sdk.emitReceipt(event, { agent_identity: "alice", algorithm: "jwt-assertion-v1", signature: "garbage" }));
235
- const cases = [
236
- [signedBundle, {}],
237
- [signedBundle, { strict: true }],
238
- [signedBundle, { trusted_public_key_refs: { [ALICE_IDENTITY_REF]: refs.refA } }],
239
- [digestBundle, {}],
240
- [digestBundle, { strict: true }],
241
- [externalBundle, { strict: true }],
242
- [hybridBundle, {}],
243
- [hybridBundle, { expected_pq_public_key_ref: "nope" }]
244
- ];
245
- for (const [bundle, options] of cases) {
246
- const first = canonicalize(sdk.verifyProofBundle(bundle, options));
247
- const second = canonicalize(sdk.verifyProofBundle(bundle, options));
248
- assert.strictEqual(first, second, `verification result must be deterministic for options ${JSON.stringify(options)}`);
249
- }
250
- }
251
-
252
- function main() {
253
- const classes = sdk.listProofVerificationClasses().map((entry) => entry.id).sort();
254
- assert.deepStrictEqual(classes, ["anchored_binding", "cryptographic", "digest", "structural"], "verification class registry mismatch");
255
- assert.deepStrictEqual(
256
- sdk.PROOF_VERIFICATION_STRICT_REJECTION_CODES.slice(),
257
- ["digest_only_not_cryptographically_verified", "external_verification_required"],
258
- "strict rejection code registry mismatch"
259
- );
260
- assert.deepStrictEqual(
261
- sdk.PROOF_VERIFICATION_TRUST_ROOT_REJECTION_CODES.slice(),
262
- ["native_public_key_not_trusted", "native_hybrid_public_key_not_trusted"],
263
- "trust root rejection code registry mismatch"
264
- );
265
-
266
- const refs = checkKeySubstitution();
267
- checkExternalStructural();
268
- checkDigestDefault();
269
- const hybridBundle = checkHybrid();
270
- checkDeterminism(hybridBundle, refs);
271
-
272
- console.log("xoonya verify:forgery-resistance passed");
273
- console.log("key substitution without trust root: accepted (documented limitation; pin with trusted_public_key_refs)");
274
- console.log("key substitution with trust root: native_public_key_not_trusted");
275
- console.log("external methods under strict: external_verification_required");
276
- console.log("digest method under strict: digest_only_not_cryptographically_verified");
277
- console.log("hybrid tampered pq signature: native_hybrid_pq_signature_invalid");
278
- console.log("hybrid wrong pq pin: native_hybrid_public_key_not_trusted");
279
- }
280
-
281
- main();