ariadne-verify 0.1.0__tar.gz

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.
@@ -0,0 +1,8 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.pyc
4
+ .pytest_cache/
5
+ .hypothesis/
6
+ *.egg-info/
7
+ dist/
8
+ build/
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.5
2
+ Name: ariadne-verify
3
+ Version: 0.1.0
4
+ Summary: Air-gapped Ed25519 & SHA-256 Merkle compliance verifier for Ariadne Nexus ZK_PROV_V1 provenance certificates.
5
+ Project-URL: Homepage, https://ariadnenexus.com
6
+ Project-URL: Specification, https://ariadnenexus.com/rfc/zk-prov-v1
7
+ Project-URL: Repository, https://github.com/dotlink-ops/nexus-core
8
+ Author-email: Ariadne Nexus Engineering <security@ariadnenexus.com>
9
+ License: Apache-2.0
10
+ Keywords: ed25519,mcp,merkle,provenance,title-insurance,zero-knowledge
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Topic :: Security :: Cryptography
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: cryptography>=43.0.3
18
+ Description-Content-Type: text/markdown
19
+
20
+ # `ariadne-verify` — Air-Gapped `ZK_PROV_V1` Certificate Verifier
21
+
22
+ Standalone, zero-network cryptographic compliance CLI and Python library for auditing **Ariadne Nexus Zero-PII Collateral Provenance Certificates** (`ANX-RFC-001` / `ZK_PROV_V1`).
23
+
24
+ Designed for specialty legal-title insurers, specie underwriters, reinsurance auditors, and art/RWA credit desks requiring **10+ year offline non-repudiation** with zero runtime dependency on Ariadne Nexus infrastructure.
25
+
26
+ - **Specification:** [`https://ariadnenexus.com/rfc/zk-prov-v1`](https://ariadnenexus.com/rfc/zk-prov-v1)
27
+ - **Repository:** [`https://github.com/dotlink-ops/nexus-core`](https://github.com/dotlink-ops/nexus-core)
28
+ - **Runtime Dependencies:** Python `>= 3.10` + `cryptography >= 43.0.3` (zero HTTP/network libraries)
29
+ - **License:** Apache-2.0
30
+
31
+ ---
32
+
33
+ ## 1. Supply-Chain & Artifact Integrity Verification (Optional Pre-Audit Step)
34
+
35
+ Every release wheel and standalone script published on GitHub Releases includes a Sigstore-signed SLSA build provenance attestation. Before transferring the wheel into an air-gapped compliance environment, verify its cryptographic build provenance:
36
+
37
+ ```bash
38
+ gh attestation verify ariadne_verify-0.1.0-py3-none-any.whl \
39
+ --repo dotlink-ops/nexus-core
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 2. Zero-Install Execution (`uvx` or Air-Gapped Wheel)
45
+
46
+ ### Online Workstation (Zero Global Install via `uvx`)
47
+ ```bash
48
+ uvx ariadne-verify --input archived_binder_proof.json \
49
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>"
50
+ ```
51
+
52
+ ### Air-Gapped Vault / Compliance Server
53
+ ```bash
54
+ pip install --no-index --find-links ./offline-wheelhouse ariadne-verify
55
+ ariadne-verify --input archived_binder_proof.json \
56
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>"
57
+ ```
58
+
59
+ ---
60
+
61
+ ## 3. Full Chain-of-Custody Merkle Root Recomputation
62
+
63
+ During a title claim or underwriting audit where the custodian presents the ordered 32-byte SHA-256 transfer digests (`L_0, L_1, ..., L_{n-1}`), pass `--custody-hashes` to independently recompute the domain-separated (`0x01` internal node prefix) binary Merkle root and cross-verify it against the Ed25519-signed statement:
64
+
65
+ ```bash
66
+ ariadne-verify \
67
+ --input archived_binder_proof.json \
68
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>" \
69
+ --custody-hashes "0x4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a,0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
70
+ ```
71
+
72
+ ### Verification Checks & Exit Codes
73
+ 1. Confirms `scheme == "ariadne-zk-ed25519-v1"` and `seller_pii_exposed is False`.
74
+ 2. Enforces exact issuer match when `--pinned-pubkey-b64` is supplied.
75
+ 3. Validates base64 encoding, 32-byte Ed25519 public key length, 64-byte signature length, and RFC 8032 PureEdDSA signature over `public_statement`.
76
+ 4. Parses `ZK_PROV_V1` claims from `public_statement` and rejects outer-JSON field mismatches (`asset_id`, `policy_ref`, `optical_forensic_score_bps`, `title_lien_clearance_merkle_root`).
77
+ 5. Recomputes the `0x01`-domain-separated SHA-256 binary Merkle root when `--custody-hashes` is provided.
78
+
79
+ - **Exit `0`:** All cryptographic, claim-binding, Zero-PII, and Merkle custody checks pass. Prints structured audit JSON to `stdout`.
80
+ - **Exit `1`:** Any cryptographic mismatch, outer-envelope spoofing attempt, key-pinning violation, or corrupted Merkle leaf. Prints structured error JSON to `stderr`.
@@ -0,0 +1,61 @@
1
+ # `ariadne-verify` — Air-Gapped `ZK_PROV_V1` Certificate Verifier
2
+
3
+ Standalone, zero-network cryptographic compliance CLI and Python library for auditing **Ariadne Nexus Zero-PII Collateral Provenance Certificates** (`ANX-RFC-001` / `ZK_PROV_V1`).
4
+
5
+ Designed for specialty legal-title insurers, specie underwriters, reinsurance auditors, and art/RWA credit desks requiring **10+ year offline non-repudiation** with zero runtime dependency on Ariadne Nexus infrastructure.
6
+
7
+ - **Specification:** [`https://ariadnenexus.com/rfc/zk-prov-v1`](https://ariadnenexus.com/rfc/zk-prov-v1)
8
+ - **Repository:** [`https://github.com/dotlink-ops/nexus-core`](https://github.com/dotlink-ops/nexus-core)
9
+ - **Runtime Dependencies:** Python `>= 3.10` + `cryptography >= 43.0.3` (zero HTTP/network libraries)
10
+ - **License:** Apache-2.0
11
+
12
+ ---
13
+
14
+ ## 1. Supply-Chain & Artifact Integrity Verification (Optional Pre-Audit Step)
15
+
16
+ Every release wheel and standalone script published on GitHub Releases includes a Sigstore-signed SLSA build provenance attestation. Before transferring the wheel into an air-gapped compliance environment, verify its cryptographic build provenance:
17
+
18
+ ```bash
19
+ gh attestation verify ariadne_verify-0.1.0-py3-none-any.whl \
20
+ --repo dotlink-ops/nexus-core
21
+ ```
22
+
23
+ ---
24
+
25
+ ## 2. Zero-Install Execution (`uvx` or Air-Gapped Wheel)
26
+
27
+ ### Online Workstation (Zero Global Install via `uvx`)
28
+ ```bash
29
+ uvx ariadne-verify --input archived_binder_proof.json \
30
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>"
31
+ ```
32
+
33
+ ### Air-Gapped Vault / Compliance Server
34
+ ```bash
35
+ pip install --no-index --find-links ./offline-wheelhouse ariadne-verify
36
+ ariadne-verify --input archived_binder_proof.json \
37
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>"
38
+ ```
39
+
40
+ ---
41
+
42
+ ## 3. Full Chain-of-Custody Merkle Root Recomputation
43
+
44
+ During a title claim or underwriting audit where the custodian presents the ordered 32-byte SHA-256 transfer digests (`L_0, L_1, ..., L_{n-1}`), pass `--custody-hashes` to independently recompute the domain-separated (`0x01` internal node prefix) binary Merkle root and cross-verify it against the Ed25519-signed statement:
45
+
46
+ ```bash
47
+ ariadne-verify \
48
+ --input archived_binder_proof.json \
49
+ --pinned-pubkey-b64 "<OFFICIAL_ARIADNE_ORACLE_ED25519_PUBKEY_B64>" \
50
+ --custody-hashes "0x4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a,0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
51
+ ```
52
+
53
+ ### Verification Checks & Exit Codes
54
+ 1. Confirms `scheme == "ariadne-zk-ed25519-v1"` and `seller_pii_exposed is False`.
55
+ 2. Enforces exact issuer match when `--pinned-pubkey-b64` is supplied.
56
+ 3. Validates base64 encoding, 32-byte Ed25519 public key length, 64-byte signature length, and RFC 8032 PureEdDSA signature over `public_statement`.
57
+ 4. Parses `ZK_PROV_V1` claims from `public_statement` and rejects outer-JSON field mismatches (`asset_id`, `policy_ref`, `optical_forensic_score_bps`, `title_lien_clearance_merkle_root`).
58
+ 5. Recomputes the `0x01`-domain-separated SHA-256 binary Merkle root when `--custody-hashes` is provided.
59
+
60
+ - **Exit `0`:** All cryptographic, claim-binding, Zero-PII, and Merkle custody checks pass. Prints structured audit JSON to `stdout`.
61
+ - **Exit `1`:** Any cryptographic mismatch, outer-envelope spoofing attempt, key-pinning violation, or corrupted Merkle leaf. Prints structured error JSON to `stderr`.
@@ -0,0 +1,19 @@
1
+ """Air-gapped Ed25519 and SHA-256 Merkle verifier for Ariadne ZK_PROV_V1 certificates."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from ariadne_verify.cli import (
6
+ compute_custody_merkle_root,
7
+ extract_structured_payload,
8
+ main,
9
+ parse_public_statement,
10
+ verify_certificate_bundle,
11
+ )
12
+
13
+ __all__ = [
14
+ "compute_custody_merkle_root",
15
+ "extract_structured_payload",
16
+ "main",
17
+ "parse_public_statement",
18
+ "verify_certificate_bundle",
19
+ ]
@@ -0,0 +1,198 @@
1
+ #!/usr/bin/env python3
2
+ """Standalone offline Ed25519 and SHA-256 Merkle compliance verifier for Ariadne ZK_PROV_V1 certificates."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import base64
8
+ import binascii
9
+ import hashlib
10
+ import json
11
+ import sys
12
+ from pathlib import Path
13
+ from typing import Any
14
+
15
+ from cryptography.exceptions import InvalidSignature
16
+ from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
17
+
18
+
19
+ def _norm_hex64(val: str) -> str:
20
+ cleaned = val.strip().lower()
21
+ if cleaned.startswith("0x"):
22
+ cleaned = cleaned[2:]
23
+ if len(cleaned) != 64 or any(c not in "0123456789abcdef" for c in cleaned):
24
+ raise ValueError(f"Invalid 32-byte SHA-256 hex digest: '{val}'")
25
+ return cleaned
26
+
27
+
28
+ def compute_custody_merkle_root(leaves_hex: list[str]) -> str:
29
+ if not leaves_hex:
30
+ return hashlib.sha256(b"GENESIS_EMPTY_CUSTODY_TREE").hexdigest()
31
+ layer = [bytes.fromhex(_norm_hex64(h)) for h in leaves_hex]
32
+ while len(layer) > 1:
33
+ if len(layer) % 2 == 1:
34
+ layer.append(layer[-1])
35
+ next_layer: list[bytes] = []
36
+ for idx in range(0, len(layer), 2):
37
+ combined = hashlib.sha256(b"\x01" + layer[idx] + layer[idx + 1]).digest()
38
+ next_layer.append(combined)
39
+ layer = next_layer
40
+ return layer[0].hex()
41
+
42
+
43
+ def parse_public_statement(statement: str) -> dict[str, str]:
44
+ parts = statement.split("|")
45
+ if not parts or parts[0] != "ZK_PROV_V1":
46
+ raise ValueError("Unsupported or malformed ZK statement header (expected 'ZK_PROV_V1').")
47
+ parsed: dict[str, str] = {"version": parts[0]}
48
+ for token in parts[1:]:
49
+ if "=" not in token:
50
+ raise ValueError(f"Malformed key=value claim '{token}' in public_statement.")
51
+ k, v = token.split("=", 1)
52
+ parsed[k] = v
53
+ return parsed
54
+
55
+
56
+ def extract_structured_payload(doc: dict[str, Any]) -> dict[str, Any]:
57
+ """Accept full JSON-RPC response, `result` envelope, or raw `structuredContent` dict."""
58
+ if "result" in doc and isinstance(doc["result"], dict):
59
+ doc = doc["result"]
60
+ if "structuredContent" in doc and isinstance(doc["structuredContent"], dict):
61
+ return doc["structuredContent"]
62
+ return doc
63
+
64
+
65
+ def verify_certificate_bundle(
66
+ payload: dict[str, Any],
67
+ *,
68
+ pinned_pubkey_b64: str | None = None,
69
+ custody_hashes_csv: str | None = None,
70
+ ) -> dict[str, Any]:
71
+ cert = payload.get("zk_attestation_certificate")
72
+ if not isinstance(cert, dict):
73
+ raise ValueError("Payload does not contain a 'zk_attestation_certificate' object.")
74
+
75
+ if cert.get("scheme") != "ariadne-zk-ed25519-v1":
76
+ raise ValueError(f"Unsupported certificate scheme: {cert.get('scheme')!r}")
77
+
78
+ if cert.get("seller_pii_exposed") is not False:
79
+ raise ValueError("Zero-PII invariant failed: seller_pii_exposed is not strictly False.")
80
+
81
+ pubkey_b64 = str(cert.get("oracle_pubkey_ed25519_b64", "")).strip()
82
+ if pinned_pubkey_b64 is not None and pubkey_b64 != pinned_pubkey_b64.strip():
83
+ raise ValueError(
84
+ f"Oracle public key mismatch! Expected pinned key '{pinned_pubkey_b64.strip()}', "
85
+ f"got '{pubkey_b64}'."
86
+ )
87
+
88
+ try:
89
+ pub_bytes = base64.b64decode(pubkey_b64, validate=True)
90
+ sig_bytes = base64.b64decode(str(cert.get("signature_b64", "")).strip(), validate=True)
91
+ except binascii.Error as exc:
92
+ raise ValueError("Malformed base64 in oracle_pubkey_ed25519_b64 or signature_b64.") from exc
93
+
94
+ if len(pub_bytes) != 32 or len(sig_bytes) != 64:
95
+ raise ValueError("Invalid Ed25519 key (expected 32B) or signature (expected 64B) length.")
96
+
97
+ statement = str(cert.get("public_statement", ""))
98
+ pubkey = Ed25519PublicKey.from_public_bytes(pub_bytes)
99
+ try:
100
+ pubkey.verify(sig_bytes, statement.encode("utf-8"))
101
+ except InvalidSignature as exc:
102
+ raise ValueError("CRITICAL: Ed25519 cryptographic signature verification FAILED.") from exc
103
+
104
+ claims = parse_public_statement(statement)
105
+
106
+ # Cross-check outer JSON fields against signed inner statement claims (blocks outer-JSON spoofing)
107
+ if "asset_id" in payload and str(payload["asset_id"]) != claims.get("asset"):
108
+ raise ValueError("Outer JSON 'asset_id' does not match signed statement 'asset' claim.")
109
+ if "policy_ref" in payload and str(payload["policy_ref"]) != claims.get("policy"):
110
+ raise ValueError("Outer JSON 'policy_ref' does not match signed statement 'policy' claim.")
111
+ if (
112
+ "optical_forensic_score_bps" in payload
113
+ and str(payload["optical_forensic_score_bps"]) != claims.get("optical_bps")
114
+ ):
115
+ raise ValueError("Outer JSON 'optical_forensic_score_bps' does not match signed 'optical_bps' claim.")
116
+ if "title_lien_clearance_merkle_root" in payload:
117
+ outer_root = _norm_hex64(str(payload["title_lien_clearance_merkle_root"]))
118
+ if outer_root != claims.get("merkle_root"):
119
+ raise ValueError("Outer JSON Merkle root does not match signed statement 'merkle_root'.")
120
+
121
+ # Optional independent Merkle root recomputation from raw custodial transfer hashes
122
+ merkle_recomputed = False
123
+ if custody_hashes_csv is not None and custody_hashes_csv.strip():
124
+ leaves = [h.strip() for h in custody_hashes_csv.split(",") if h.strip()]
125
+ expected_root = compute_custody_merkle_root(leaves)
126
+ if expected_root != claims.get("merkle_root"):
127
+ raise ValueError(
128
+ f"Custody Merkle root mismatch: recomputed 0x{expected_root}, "
129
+ f"signed certificate has 0x{claims.get('merkle_root')}."
130
+ )
131
+ merkle_recomputed = True
132
+
133
+ return {
134
+ "verified": True,
135
+ "scheme": "ariadne-zk-ed25519-v1",
136
+ "oracle_pubkey_ed25519_b64": pubkey_b64,
137
+ "pinned_key_enforced": pinned_pubkey_b64 is not None,
138
+ "merkle_chain_independently_recomputed": merkle_recomputed,
139
+ "signed_claims": claims,
140
+ }
141
+
142
+
143
+ def main() -> None:
144
+ parser = argparse.ArgumentParser(
145
+ description="Offline Ed25519 & Merkle compliance verifier for Ariadne ZK Provenance Certificates."
146
+ )
147
+ parser.add_argument(
148
+ "--input",
149
+ required=True,
150
+ help="Path to JSON file containing MCP response or '-' for stdin",
151
+ )
152
+ parser.add_argument(
153
+ "--pinned-pubkey-b64",
154
+ default=None,
155
+ help="Optional pinned Ariadne Oracle Ed25519 public key (base64) for strict issuer pinning",
156
+ )
157
+ parser.add_argument(
158
+ "--custody-hashes",
159
+ default=None,
160
+ help="Optional comma-separated SHA-256 custody transfer hashes to recompute Merkle root offline",
161
+ )
162
+ args = parser.parse_args()
163
+
164
+ try:
165
+ raw_text = (
166
+ sys.stdin.read()
167
+ if args.input == "-"
168
+ else Path(args.input).read_text(encoding="utf-8")
169
+ )
170
+ doc = json.loads(raw_text)
171
+ if not isinstance(doc, dict):
172
+ raise ValueError("Input JSON root must be an object.")
173
+ structured = extract_structured_payload(doc)
174
+ audit_report = verify_certificate_bundle(
175
+ structured,
176
+ pinned_pubkey_b64=args.pinned_pubkey_b64,
177
+ custody_hashes_csv=args.custody_hashes,
178
+ )
179
+ except Exception as exc:
180
+ error_out = {"verified": False, "error": str(exc)}
181
+ print(json.dumps(error_out, indent=2), file=sys.stderr)
182
+ sys.exit(1)
183
+
184
+ print(json.dumps(audit_report, indent=2))
185
+ sys.exit(0)
186
+
187
+
188
+ __all__ = [
189
+ "compute_custody_merkle_root",
190
+ "extract_structured_payload",
191
+ "main",
192
+ "parse_public_statement",
193
+ "verify_certificate_bundle",
194
+ ]
195
+
196
+
197
+ if __name__ == "__main__":
198
+ main()
File without changes
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.26.3"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "ariadne-verify"
7
+ version = "0.1.0"
8
+ description = "Air-gapped Ed25519 & SHA-256 Merkle compliance verifier for Ariadne Nexus ZK_PROV_V1 provenance certificates."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "Ariadne Nexus Engineering", email = "security@ariadnenexus.com" }]
13
+ keywords = ["mcp", "provenance", "ed25519", "merkle", "title-insurance", "zero-knowledge"]
14
+ classifiers = [
15
+ "Development Status :: 5 - Production/Stable",
16
+ "Intended Audience :: Financial and Insurance Industry",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "Topic :: Security :: Cryptography",
20
+ ]
21
+ dependencies = [
22
+ "cryptography>=43.0.3",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://ariadnenexus.com"
27
+ Specification = "https://ariadnenexus.com/rfc/zk-prov-v1"
28
+ Repository = "https://github.com/dotlink-ops/nexus-core"
29
+
30
+ [project.scripts]
31
+ ariadne-verify = "ariadne_verify.cli:main"
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ packages = ["ariadne_verify"]