zerynex-python 0.2.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.
- zerynex_python-0.2.0/LICENSE +21 -0
- zerynex_python-0.2.0/PKG-INFO +287 -0
- zerynex_python-0.2.0/README.md +265 -0
- zerynex_python-0.2.0/pyproject.toml +48 -0
- zerynex_python-0.2.0/setup.cfg +4 -0
- zerynex_python-0.2.0/src/zerynex_py/__init__.py +21 -0
- zerynex_python-0.2.0/src/zerynex_py/agent_workflows.py +125 -0
- zerynex_python-0.2.0/src/zerynex_py/client.py +406 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/clean-v6.bin +0 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/refund-isolated.json +21 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/refund-regression-expanded.json +29 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/refund-risky.json +21 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/rule-catalog.json +95 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/transparent-v6.bin +0 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/zallet-pczt-lifecycle-contract.json +87 -0
- zerynex_python-0.2.0/src/zerynex_py/fixtures/zallet-pczt-lifecycle-synthetic-openrpc.json +127 -0
- zerynex_python-0.2.0/src/zerynex_py/mcp_doctor.py +152 -0
- zerynex_python-0.2.0/src/zerynex_py/mcp_server.py +391 -0
- zerynex_python-0.2.0/src/zerynex_py/node.py +189 -0
- zerynex_python-0.2.0/src/zerynex_py/preflight.py +42 -0
- zerynex_python-0.2.0/src/zerynex_py/project.py +313 -0
- zerynex_python-0.2.0/src/zerynex_py/refund_privacy.py +252 -0
- zerynex_python-0.2.0/src/zerynex_py/refund_workflows.py +118 -0
- zerynex_python-0.2.0/src/zerynex_py/rpc_contract.py +172 -0
- zerynex_python-0.2.0/src/zerynex_py/rules.py +55 -0
- zerynex_python-0.2.0/src/zerynex_py/z3.py +107 -0
- zerynex_python-0.2.0/src/zerynex_py/zallet_fixture.py +158 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/PKG-INFO +287 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/SOURCES.txt +41 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/dependency_links.txt +1 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/entry_points.txt +10 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/requires.txt +6 -0
- zerynex_python-0.2.0/src/zerynex_python.egg-info/top_level.txt +1 -0
- zerynex_python-0.2.0/tests/test_agent_workflows.py +108 -0
- zerynex_python-0.2.0/tests/test_client.py +207 -0
- zerynex_python-0.2.0/tests/test_mcp_protocol.py +147 -0
- zerynex_python-0.2.0/tests/test_mcp_security.py +54 -0
- zerynex_python-0.2.0/tests/test_node.py +152 -0
- zerynex_python-0.2.0/tests/test_project.py +196 -0
- zerynex_python-0.2.0/tests/test_refund_privacy.py +217 -0
- zerynex_python-0.2.0/tests/test_refund_workflows.py +68 -0
- zerynex_python-0.2.0/tests/test_rule_vectors.py +65 -0
- zerynex_python-0.2.0/tests/test_z3.py +78 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zerynex contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zerynex-python
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Local Zcash PCZT developer toolkit: privacy policy analysis, synthetic MCP integrations, refund risk checks and infrastructure adapters
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://zerynex.vercel.app
|
|
7
|
+
Project-URL: Documentation, https://zerynex.vercel.app/docs
|
|
8
|
+
Project-URL: Repository, https://github.com/Oluwa-Laughter/zerynex
|
|
9
|
+
Project-URL: Issues, https://github.com/Oluwa-Laughter/zerynex/issues
|
|
10
|
+
Keywords: zcash,privacy,pczt,cryptography,developer-tools
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Provides-Extra: mcp
|
|
18
|
+
Requires-Dist: mcp<3,>=2; extra == "mcp"
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# zerynex-python
|
|
24
|
+
|
|
25
|
+
Python 3.11+ adapter for **local Rust-backed** Zcash PCZT privacy analysis.
|
|
26
|
+
This package is not yet published on PyPI. A source-free wheel has been
|
|
27
|
+
built and tested in a clean Python virtualenv against the real Rust CLI.
|
|
28
|
+
See [release artifact downloads](https://zerynex.vercel.app/docs/releases).
|
|
29
|
+
|
|
30
|
+
## Installation from this checkout
|
|
31
|
+
|
|
32
|
+
First compile the Rust CLI:
|
|
33
|
+
|
|
34
|
+
cargo build --locked --release
|
|
35
|
+
|
|
36
|
+
Then install the Python SDK from the repo:
|
|
37
|
+
|
|
38
|
+
python -m venv .venv
|
|
39
|
+
.venv/bin/python -m pip install ./packages/python
|
|
40
|
+
|
|
41
|
+
Or with uv:
|
|
42
|
+
|
|
43
|
+
uv pip install ./packages/python
|
|
44
|
+
|
|
45
|
+
Pass the trusted Rust executable explicitly:
|
|
46
|
+
|
|
47
|
+
from pathlib import Path
|
|
48
|
+
from zerynex_py import ZerynexClient, Policy
|
|
49
|
+
|
|
50
|
+
client = ZerynexClient(cli=Path("./target/release/zerynex"))
|
|
51
|
+
result = client.analyze_file(
|
|
52
|
+
"apps/web/public/examples/transparent-v6.bin",
|
|
53
|
+
Policy(deny_transparent=True),
|
|
54
|
+
)
|
|
55
|
+
print(result.agent_summary())
|
|
56
|
+
|
|
57
|
+
The sample should flag a transparent output using the same Rust rules as the
|
|
58
|
+
Next.js Studio, Rust CLI and TypeScript SDK.
|
|
59
|
+
|
|
60
|
+
## Installable offline RPC contract checker
|
|
61
|
+
|
|
62
|
+
The Python wheel also installs `zerynex-rpc-check`, a standalone **offline**
|
|
63
|
+
OpenRPC compatibility checker. It does not require the Rust executable,
|
|
64
|
+
connect to Zallet, or process PCZT bytes. Only method names and argument
|
|
65
|
+
requirements from explicitly selected local JSON files are compared:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
zerynex-rpc-check \
|
|
69
|
+
--schema tests/fixtures/rpc/zallet-pczt-lifecycle-synthetic-openrpc.json \
|
|
70
|
+
--contract tests/fixtures/rpc/zallet-pczt-lifecycle-contract.json \
|
|
71
|
+
--deny-new-required --json
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The fixture is synthetic, not a capture from an upstream Zallet release.
|
|
75
|
+
Exit codes: `0` pass, `1` invalid input, `2` contract drift.
|
|
76
|
+
For production integrations, pin an actual Zallet release and inspect its
|
|
77
|
+
protected local `rpc.discover` response instead. See `docs/rpc-contracts.md`.
|
|
78
|
+
|
|
79
|
+
## Installable local PCZT producer-fixture checker
|
|
80
|
+
|
|
81
|
+
The wheel also installs `zerynex-zallet-fixture-check`. Supply a protected
|
|
82
|
+
local manifest and canonical base64 `.b64` PCZT fixtures, plus the trusted
|
|
83
|
+
Rust CLI path:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
zerynex-zallet-fixture-check \
|
|
87
|
+
--manifest /protected/local/manifest.json --cli /absolute/path/to/zerynex
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The command checks file digests and exact policy findings without an RPC or
|
|
91
|
+
network connection. Its producer release label is supplied by the manifest
|
|
92
|
+
author, not authenticated by Zerynex. The clean-wheel consumer test uses
|
|
93
|
+
synthetic PCZTs, so it does not establish live Zallet compatibility. See
|
|
94
|
+
`docs/zallet-pczt-handoff.md` for the manifest and exit codes.
|
|
95
|
+
|
|
96
|
+
## Agent/MCP extra
|
|
97
|
+
|
|
98
|
+
pip install './packages/python[mcp]'
|
|
99
|
+
|
|
100
|
+
Use the **local-only** MCP server after specifying a dedicated sandbox directory
|
|
101
|
+
containing synthetic fixtures:
|
|
102
|
+
|
|
103
|
+
ZERYNEX_CLI=/absolute/path/to/zerynex
|
|
104
|
+
ZERYNEX_AGENT_ALLOWED_ROOT=/absolute/path/to/synthetic-fixtures
|
|
105
|
+
zerynex-mcp
|
|
106
|
+
|
|
107
|
+
Run a real local stdio MCP diagnostic before connecting an AI assistant:
|
|
108
|
+
|
|
109
|
+
zerynex-mcp-doctor --server /abs/path/to/zerynex-mcp --cli /abs/path/to/zerynex --fixtures /abs/path/to/synthetic-fixtures
|
|
110
|
+
|
|
111
|
+
It discovers twelve tools, checks four Rust-backed synthetic PCZT expectations, and verifies the unified developer preflight, bundled refund scenarios, and an expected RPC regression.
|
|
112
|
+
Exit 0 means all matched, 1 means setup failed, 2 means a test mismatched.
|
|
113
|
+
The public /agents frontend also generates client-specific configuration
|
|
114
|
+
for common MCP hosts; it does not execute the MCP process in-browser.
|
|
115
|
+
|
|
116
|
+
The MCP server exposes strictly read-only policy checks through stdio. It
|
|
117
|
+
accepts only simple fixture filenames inside the configured directory. It
|
|
118
|
+
never reads arbitrary host paths or sends PCZT bytes to the model. The
|
|
119
|
+
underlying Rust process may inspect the bytes locally.
|
|
120
|
+
|
|
121
|
+
## Security
|
|
122
|
+
|
|
123
|
+
This package has no direct network operations, agent LLM calls, signers or
|
|
124
|
+
custody code. The analyzer output contains only the limited rule IDs and
|
|
125
|
+
field paths enforced by Rust. The user controls which executable is trusted.
|
|
126
|
+
|
|
127
|
+
Future direction: use PyO3/maturin to ship native wheels based on the same
|
|
128
|
+
Rust core, avoiding the CLI dependency. This is not implemented yet.
|
|
129
|
+
|
|
130
|
+
## Z3 local diagnostics
|
|
131
|
+
|
|
132
|
+
Use zerynex-z3-check to probe only Zebra's documented loopback-bound
|
|
133
|
+
/healthy and /ready endpoints:
|
|
134
|
+
|
|
135
|
+
zerynex-z3-check --host 127.0.0.1 --port 8080
|
|
136
|
+
|
|
137
|
+
See docs/z3-local.md. This checks two readiness signals only, not Zcash
|
|
138
|
+
consensus, Zallet wallet operation or Zaino gRPC.
|
|
139
|
+
|
|
140
|
+
## Consume a locally held Zallet PCZT without a temporary file
|
|
141
|
+
|
|
142
|
+
For a trusted application with an in-memory base64 PCZT string:
|
|
143
|
+
|
|
144
|
+
from zerynex_py import ZerynexClient, Policy
|
|
145
|
+
result = ZerynexClient(cli="/path/to/zerynex").analyze_base64(
|
|
146
|
+
pczt_base64, Policy(deny_transparent=True)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
The Python adapter passes the encoded bytes over Rust CLI stdin and only
|
|
150
|
+
returns sanitized report fields. Do not provide confidential intermediates
|
|
151
|
+
to a cloud agent or to CI. See docs/zallet-pczt-handoff.md.
|
|
152
|
+
|
|
153
|
+
## Compare PCZT role handoffs
|
|
154
|
+
|
|
155
|
+
result = client.compare_files(
|
|
156
|
+
"path/to/before-synthetic.pczt",
|
|
157
|
+
"path/to/after-synthetic.pczt",
|
|
158
|
+
Policy(deny_transparent=True),
|
|
159
|
+
)
|
|
160
|
+
print(result.agent_summary())
|
|
161
|
+
|
|
162
|
+
This produces rule and pool-component differences using the same local
|
|
163
|
+
Rust engine. Not a transaction equivalence or proof validator.
|
|
164
|
+
See docs/pczt-stage-regression.md.
|
|
165
|
+
|
|
166
|
+
## Real MCP developer workflows
|
|
167
|
+
|
|
168
|
+
Nine read-only tools are available through the official MCP protocol:
|
|
169
|
+
analyze_synthetic_pczt, compare_synthetic_pczt_stages,
|
|
170
|
+
list_synthetic_fixtures, explain_zerynex_rule,
|
|
171
|
+
run_synthetic_smoke_suite, zerynex_policy_schema,
|
|
172
|
+
zerynex_core_capabilities, check_synthetic_zallet_rpc_contract,
|
|
173
|
+
run_zerynex_developer_preflight, and zerynex_rule_catalog.
|
|
174
|
+
|
|
175
|
+
A tested host workflow can list allowed .bin fixtures, analyze a synthetic
|
|
176
|
+
transparent output, explain the corresponding privacy rule, and compare
|
|
177
|
+
clean and flagged fixture stages. The smoke suite checks four fixed
|
|
178
|
+
expected outcomes through real Rust CLI calls, not mocked reports.
|
|
179
|
+
For instructions and security boundaries see docs/agents.md.
|
|
180
|
+
|
|
181
|
+
## Discover CLI support before integrating
|
|
182
|
+
|
|
183
|
+
The trusted local CLI exposes versioned JSON without reading PCZT contents:
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
from zerynex_py import ZerynexClient
|
|
187
|
+
|
|
188
|
+
client = ZerynexClient(cli="/absolute/path/to/zerynex")
|
|
189
|
+
caps = client.capabilities()
|
|
190
|
+
print(caps.version, caps.operations, caps.max_decoded_pczt_bytes)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The wrapper rejects unsupported capability versions and unsafe output. This does not imply any live Zallet wallet or network compatibility. See `docs/cli-capabilities.md`.
|
|
194
|
+
|
|
195
|
+
## Unified CLI + MCP + agent preflight
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
zerynex-agent-preflight --cli /absolute/path/to/zerynex \
|
|
199
|
+
--fixtures /absolute/path/to/approved-synthetic-fixtures --json
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The command works without MCP or network dependencies. It checks the installed
|
|
203
|
+
Rust CLI's capabilities, four real synthetic PCZT invariants and a bundled
|
|
204
|
+
Zallet-style synthetic RPC contract. Exit codes: pass `0`, input/error `1`,
|
|
205
|
+
regression mismatch `2`. The agent MCP tools use the same implementation,
|
|
206
|
+
including a fixed RPC regression scenario menu with **no arbitrary files**.
|
|
207
|
+
See `docs/agents.md` for the trust boundaries.
|
|
208
|
+
|
|
209
|
+
## Read-only local Zcash node readiness
|
|
210
|
+
|
|
211
|
+
`zerynex-node-check --host 127.0.0.1 --port 8232 --expect-network test`
|
|
212
|
+
reads one local `getblockchaininfo` response and emits only network/sync readiness
|
|
213
|
+
fields. Use `--cookie-file /path/to/owner-private/.cookie` for nodes requiring
|
|
214
|
+
RPC authentication. It never takes a password in argv, connects to public
|
|
215
|
+
hosts, or exposes arbitrary wallet RPCs.
|
|
216
|
+
|
|
217
|
+
Python applications may use `inspect_node_local()` or pass an already obtained
|
|
218
|
+
response to `evaluate_blockchain_info()`. The pure `evaluate_blockchain_info()`
|
|
219
|
+
function has no network dependency. A lack of sync/status fields fails closed.
|
|
220
|
+
See `docs/node-readiness.md` for API examples and limitations.
|
|
221
|
+
|
|
222
|
+
## Project bootstrap (offline)
|
|
223
|
+
|
|
224
|
+
The wheel installs `zerynex-project`. This command creates an integration
|
|
225
|
+
inside an existing Zcash application rather than connecting this website to
|
|
226
|
+
a developer machine:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
zerynex-project init --project /absolute/path/to/my-zcash-app --ci --json
|
|
230
|
+
zerynex-project verify --project /absolute/path/to/my-zcash-app --cli /absolute/path/to/zerynex --json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Initialization refuses existing files and symlinked destination directories,
|
|
234
|
+
and creates only a reviewed policy, manifest, bundled nonspendable synthetic
|
|
235
|
+
PCZT fixtures and optional GitHub Action pinned to an immutable commit.
|
|
236
|
+
Verification checks those bytes and executes the **actual local Rust CLI**
|
|
237
|
+
against both fixtures. Passing proves only the local toolchain's expected
|
|
238
|
+
synthetic behavior, not wallet connectivity, chain consensus or anonymity.
|
|
239
|
+
No private PCZT, signing key, RPC endpoint or wallet connection is accessed.
|
|
240
|
+
|
|
241
|
+
### Explicit project PCZT policy checks
|
|
242
|
+
|
|
243
|
+
After `init`, developers can opt in to analyzing an actual local PCZT.
|
|
244
|
+
These commands **never discover** private files, use the network, or
|
|
245
|
+
automatically change a wallet transaction. `--pczt`, `--before` and
|
|
246
|
+
`--after` must be existing, regular files **inside** the selected project.
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
zerynex-project check --project /path/to/app --pczt data/my.pczt --cli /path/to/zerynex --json
|
|
250
|
+
zerynex-project compare --project /path/to/app --before data/unsigned.pczt --after data/signed.pczt --cli /path/to/zerynex --json
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
`check` uses the project's strict `.zerynex/policy.json`, which the
|
|
254
|
+
developer may customize, and returns only a result, finding count and
|
|
255
|
+
recognized rule IDs. `compare` returns before/after counts and added or
|
|
256
|
+
resolved known rule IDs, without exporting PCZT field contents.
|
|
257
|
+
Exit code `0` means no selected policy findings/regressions,
|
|
258
|
+
`2` means findings, and `1` means invalid input or execution failure.
|
|
259
|
+
Use a trusted local workspace and CLI. Do not put real private PCZTs into
|
|
260
|
+
public CI, browser demos, external MCP hosts, or logs.
|
|
261
|
+
|
|
262
|
+
## Swap refund and viewing-key privacy metadata audit
|
|
263
|
+
|
|
264
|
+
The installed `zerynex-refund-audit` command checks a strict, local JSON manifest of **opaque non-secret identifiers**, not Zcash addresses or keys. Its static findings cover refund-address reuse, shared viewing-key scope, public refund exposure, refund query disclosure and unsupported custody assertions. This is a threat-model integration aid, not a post-quantum cryptography implementation or real wallet inspection. See `docs/refund-privacy-audit.md` for schema, examples and limitations.
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
### Compare refund integration revisions
|
|
268
|
+
|
|
269
|
+
Use `zerynex-refund-audit --baseline /path/to/before.json --manifest /path/to/after.json --json` to detect **new per-flow** exposure declarations. A newly affected flow triggers a regression even if the same rule ID already applied to another flow. Exit `0` means no *new* declared risk events, exit `2` means new events, and exit `1` is invalid input. No private values or flow references are returned. Source manifests must contain **non-secret metadata only**. This does not attest wallet isolation or quantum safety. See `docs/refund-privacy-audit.md`.
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
The packaged refund-audit SDK also exports `audit_manifest`, `compare_manifests`, `sarif_report` and `RefundAuditInputError`. Add `--sarif` instead of `--json` when integrating with SARIF-capable tooling. The exported SARIF contains no source locations or opaque references and only covers **declared** risk categories.
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
## Refund privacy checks for local MCP agents
|
|
276
|
+
|
|
277
|
+
The optional read-only MCP server exposes
|
|
278
|
+
`audit_synthetic_refund_privacy(scenario)` and
|
|
279
|
+
`compare_synthetic_refund_privacy(baseline, candidate)`. Only the three
|
|
280
|
+
bundled scenario names `isolated`, `risky` and `regression-expanded`
|
|
281
|
+
are accepted; arbitrary paths and JSON are denied. The packaged
|
|
282
|
+
`zerynex-agent-preflight` verifies six offline, synthetic refund-privacy
|
|
283
|
+
expectations and the MCP doctor checks these tools via a real stdio host.
|
|
284
|
+
Agents never receive viewing keys, wallet data, refund addresses or flow
|
|
285
|
+
identifiers, and a passing synthetic declaration is **not** a post-quantum
|
|
286
|
+
privacy certification. For actual application-owned, public-safe metadata
|
|
287
|
+
use the standalone `zerynex-refund-audit` CLI in a trusted environment.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# zerynex-python
|
|
2
|
+
|
|
3
|
+
Python 3.11+ adapter for **local Rust-backed** Zcash PCZT privacy analysis.
|
|
4
|
+
This package is not yet published on PyPI. A source-free wheel has been
|
|
5
|
+
built and tested in a clean Python virtualenv against the real Rust CLI.
|
|
6
|
+
See [release artifact downloads](https://zerynex.vercel.app/docs/releases).
|
|
7
|
+
|
|
8
|
+
## Installation from this checkout
|
|
9
|
+
|
|
10
|
+
First compile the Rust CLI:
|
|
11
|
+
|
|
12
|
+
cargo build --locked --release
|
|
13
|
+
|
|
14
|
+
Then install the Python SDK from the repo:
|
|
15
|
+
|
|
16
|
+
python -m venv .venv
|
|
17
|
+
.venv/bin/python -m pip install ./packages/python
|
|
18
|
+
|
|
19
|
+
Or with uv:
|
|
20
|
+
|
|
21
|
+
uv pip install ./packages/python
|
|
22
|
+
|
|
23
|
+
Pass the trusted Rust executable explicitly:
|
|
24
|
+
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from zerynex_py import ZerynexClient, Policy
|
|
27
|
+
|
|
28
|
+
client = ZerynexClient(cli=Path("./target/release/zerynex"))
|
|
29
|
+
result = client.analyze_file(
|
|
30
|
+
"apps/web/public/examples/transparent-v6.bin",
|
|
31
|
+
Policy(deny_transparent=True),
|
|
32
|
+
)
|
|
33
|
+
print(result.agent_summary())
|
|
34
|
+
|
|
35
|
+
The sample should flag a transparent output using the same Rust rules as the
|
|
36
|
+
Next.js Studio, Rust CLI and TypeScript SDK.
|
|
37
|
+
|
|
38
|
+
## Installable offline RPC contract checker
|
|
39
|
+
|
|
40
|
+
The Python wheel also installs `zerynex-rpc-check`, a standalone **offline**
|
|
41
|
+
OpenRPC compatibility checker. It does not require the Rust executable,
|
|
42
|
+
connect to Zallet, or process PCZT bytes. Only method names and argument
|
|
43
|
+
requirements from explicitly selected local JSON files are compared:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
zerynex-rpc-check \
|
|
47
|
+
--schema tests/fixtures/rpc/zallet-pczt-lifecycle-synthetic-openrpc.json \
|
|
48
|
+
--contract tests/fixtures/rpc/zallet-pczt-lifecycle-contract.json \
|
|
49
|
+
--deny-new-required --json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The fixture is synthetic, not a capture from an upstream Zallet release.
|
|
53
|
+
Exit codes: `0` pass, `1` invalid input, `2` contract drift.
|
|
54
|
+
For production integrations, pin an actual Zallet release and inspect its
|
|
55
|
+
protected local `rpc.discover` response instead. See `docs/rpc-contracts.md`.
|
|
56
|
+
|
|
57
|
+
## Installable local PCZT producer-fixture checker
|
|
58
|
+
|
|
59
|
+
The wheel also installs `zerynex-zallet-fixture-check`. Supply a protected
|
|
60
|
+
local manifest and canonical base64 `.b64` PCZT fixtures, plus the trusted
|
|
61
|
+
Rust CLI path:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
zerynex-zallet-fixture-check \
|
|
65
|
+
--manifest /protected/local/manifest.json --cli /absolute/path/to/zerynex
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The command checks file digests and exact policy findings without an RPC or
|
|
69
|
+
network connection. Its producer release label is supplied by the manifest
|
|
70
|
+
author, not authenticated by Zerynex. The clean-wheel consumer test uses
|
|
71
|
+
synthetic PCZTs, so it does not establish live Zallet compatibility. See
|
|
72
|
+
`docs/zallet-pczt-handoff.md` for the manifest and exit codes.
|
|
73
|
+
|
|
74
|
+
## Agent/MCP extra
|
|
75
|
+
|
|
76
|
+
pip install './packages/python[mcp]'
|
|
77
|
+
|
|
78
|
+
Use the **local-only** MCP server after specifying a dedicated sandbox directory
|
|
79
|
+
containing synthetic fixtures:
|
|
80
|
+
|
|
81
|
+
ZERYNEX_CLI=/absolute/path/to/zerynex
|
|
82
|
+
ZERYNEX_AGENT_ALLOWED_ROOT=/absolute/path/to/synthetic-fixtures
|
|
83
|
+
zerynex-mcp
|
|
84
|
+
|
|
85
|
+
Run a real local stdio MCP diagnostic before connecting an AI assistant:
|
|
86
|
+
|
|
87
|
+
zerynex-mcp-doctor --server /abs/path/to/zerynex-mcp --cli /abs/path/to/zerynex --fixtures /abs/path/to/synthetic-fixtures
|
|
88
|
+
|
|
89
|
+
It discovers twelve tools, checks four Rust-backed synthetic PCZT expectations, and verifies the unified developer preflight, bundled refund scenarios, and an expected RPC regression.
|
|
90
|
+
Exit 0 means all matched, 1 means setup failed, 2 means a test mismatched.
|
|
91
|
+
The public /agents frontend also generates client-specific configuration
|
|
92
|
+
for common MCP hosts; it does not execute the MCP process in-browser.
|
|
93
|
+
|
|
94
|
+
The MCP server exposes strictly read-only policy checks through stdio. It
|
|
95
|
+
accepts only simple fixture filenames inside the configured directory. It
|
|
96
|
+
never reads arbitrary host paths or sends PCZT bytes to the model. The
|
|
97
|
+
underlying Rust process may inspect the bytes locally.
|
|
98
|
+
|
|
99
|
+
## Security
|
|
100
|
+
|
|
101
|
+
This package has no direct network operations, agent LLM calls, signers or
|
|
102
|
+
custody code. The analyzer output contains only the limited rule IDs and
|
|
103
|
+
field paths enforced by Rust. The user controls which executable is trusted.
|
|
104
|
+
|
|
105
|
+
Future direction: use PyO3/maturin to ship native wheels based on the same
|
|
106
|
+
Rust core, avoiding the CLI dependency. This is not implemented yet.
|
|
107
|
+
|
|
108
|
+
## Z3 local diagnostics
|
|
109
|
+
|
|
110
|
+
Use zerynex-z3-check to probe only Zebra's documented loopback-bound
|
|
111
|
+
/healthy and /ready endpoints:
|
|
112
|
+
|
|
113
|
+
zerynex-z3-check --host 127.0.0.1 --port 8080
|
|
114
|
+
|
|
115
|
+
See docs/z3-local.md. This checks two readiness signals only, not Zcash
|
|
116
|
+
consensus, Zallet wallet operation or Zaino gRPC.
|
|
117
|
+
|
|
118
|
+
## Consume a locally held Zallet PCZT without a temporary file
|
|
119
|
+
|
|
120
|
+
For a trusted application with an in-memory base64 PCZT string:
|
|
121
|
+
|
|
122
|
+
from zerynex_py import ZerynexClient, Policy
|
|
123
|
+
result = ZerynexClient(cli="/path/to/zerynex").analyze_base64(
|
|
124
|
+
pczt_base64, Policy(deny_transparent=True)
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
The Python adapter passes the encoded bytes over Rust CLI stdin and only
|
|
128
|
+
returns sanitized report fields. Do not provide confidential intermediates
|
|
129
|
+
to a cloud agent or to CI. See docs/zallet-pczt-handoff.md.
|
|
130
|
+
|
|
131
|
+
## Compare PCZT role handoffs
|
|
132
|
+
|
|
133
|
+
result = client.compare_files(
|
|
134
|
+
"path/to/before-synthetic.pczt",
|
|
135
|
+
"path/to/after-synthetic.pczt",
|
|
136
|
+
Policy(deny_transparent=True),
|
|
137
|
+
)
|
|
138
|
+
print(result.agent_summary())
|
|
139
|
+
|
|
140
|
+
This produces rule and pool-component differences using the same local
|
|
141
|
+
Rust engine. Not a transaction equivalence or proof validator.
|
|
142
|
+
See docs/pczt-stage-regression.md.
|
|
143
|
+
|
|
144
|
+
## Real MCP developer workflows
|
|
145
|
+
|
|
146
|
+
Nine read-only tools are available through the official MCP protocol:
|
|
147
|
+
analyze_synthetic_pczt, compare_synthetic_pczt_stages,
|
|
148
|
+
list_synthetic_fixtures, explain_zerynex_rule,
|
|
149
|
+
run_synthetic_smoke_suite, zerynex_policy_schema,
|
|
150
|
+
zerynex_core_capabilities, check_synthetic_zallet_rpc_contract,
|
|
151
|
+
run_zerynex_developer_preflight, and zerynex_rule_catalog.
|
|
152
|
+
|
|
153
|
+
A tested host workflow can list allowed .bin fixtures, analyze a synthetic
|
|
154
|
+
transparent output, explain the corresponding privacy rule, and compare
|
|
155
|
+
clean and flagged fixture stages. The smoke suite checks four fixed
|
|
156
|
+
expected outcomes through real Rust CLI calls, not mocked reports.
|
|
157
|
+
For instructions and security boundaries see docs/agents.md.
|
|
158
|
+
|
|
159
|
+
## Discover CLI support before integrating
|
|
160
|
+
|
|
161
|
+
The trusted local CLI exposes versioned JSON without reading PCZT contents:
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from zerynex_py import ZerynexClient
|
|
165
|
+
|
|
166
|
+
client = ZerynexClient(cli="/absolute/path/to/zerynex")
|
|
167
|
+
caps = client.capabilities()
|
|
168
|
+
print(caps.version, caps.operations, caps.max_decoded_pczt_bytes)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The wrapper rejects unsupported capability versions and unsafe output. This does not imply any live Zallet wallet or network compatibility. See `docs/cli-capabilities.md`.
|
|
172
|
+
|
|
173
|
+
## Unified CLI + MCP + agent preflight
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
zerynex-agent-preflight --cli /absolute/path/to/zerynex \
|
|
177
|
+
--fixtures /absolute/path/to/approved-synthetic-fixtures --json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The command works without MCP or network dependencies. It checks the installed
|
|
181
|
+
Rust CLI's capabilities, four real synthetic PCZT invariants and a bundled
|
|
182
|
+
Zallet-style synthetic RPC contract. Exit codes: pass `0`, input/error `1`,
|
|
183
|
+
regression mismatch `2`. The agent MCP tools use the same implementation,
|
|
184
|
+
including a fixed RPC regression scenario menu with **no arbitrary files**.
|
|
185
|
+
See `docs/agents.md` for the trust boundaries.
|
|
186
|
+
|
|
187
|
+
## Read-only local Zcash node readiness
|
|
188
|
+
|
|
189
|
+
`zerynex-node-check --host 127.0.0.1 --port 8232 --expect-network test`
|
|
190
|
+
reads one local `getblockchaininfo` response and emits only network/sync readiness
|
|
191
|
+
fields. Use `--cookie-file /path/to/owner-private/.cookie` for nodes requiring
|
|
192
|
+
RPC authentication. It never takes a password in argv, connects to public
|
|
193
|
+
hosts, or exposes arbitrary wallet RPCs.
|
|
194
|
+
|
|
195
|
+
Python applications may use `inspect_node_local()` or pass an already obtained
|
|
196
|
+
response to `evaluate_blockchain_info()`. The pure `evaluate_blockchain_info()`
|
|
197
|
+
function has no network dependency. A lack of sync/status fields fails closed.
|
|
198
|
+
See `docs/node-readiness.md` for API examples and limitations.
|
|
199
|
+
|
|
200
|
+
## Project bootstrap (offline)
|
|
201
|
+
|
|
202
|
+
The wheel installs `zerynex-project`. This command creates an integration
|
|
203
|
+
inside an existing Zcash application rather than connecting this website to
|
|
204
|
+
a developer machine:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
zerynex-project init --project /absolute/path/to/my-zcash-app --ci --json
|
|
208
|
+
zerynex-project verify --project /absolute/path/to/my-zcash-app --cli /absolute/path/to/zerynex --json
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Initialization refuses existing files and symlinked destination directories,
|
|
212
|
+
and creates only a reviewed policy, manifest, bundled nonspendable synthetic
|
|
213
|
+
PCZT fixtures and optional GitHub Action pinned to an immutable commit.
|
|
214
|
+
Verification checks those bytes and executes the **actual local Rust CLI**
|
|
215
|
+
against both fixtures. Passing proves only the local toolchain's expected
|
|
216
|
+
synthetic behavior, not wallet connectivity, chain consensus or anonymity.
|
|
217
|
+
No private PCZT, signing key, RPC endpoint or wallet connection is accessed.
|
|
218
|
+
|
|
219
|
+
### Explicit project PCZT policy checks
|
|
220
|
+
|
|
221
|
+
After `init`, developers can opt in to analyzing an actual local PCZT.
|
|
222
|
+
These commands **never discover** private files, use the network, or
|
|
223
|
+
automatically change a wallet transaction. `--pczt`, `--before` and
|
|
224
|
+
`--after` must be existing, regular files **inside** the selected project.
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
zerynex-project check --project /path/to/app --pczt data/my.pczt --cli /path/to/zerynex --json
|
|
228
|
+
zerynex-project compare --project /path/to/app --before data/unsigned.pczt --after data/signed.pczt --cli /path/to/zerynex --json
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
`check` uses the project's strict `.zerynex/policy.json`, which the
|
|
232
|
+
developer may customize, and returns only a result, finding count and
|
|
233
|
+
recognized rule IDs. `compare` returns before/after counts and added or
|
|
234
|
+
resolved known rule IDs, without exporting PCZT field contents.
|
|
235
|
+
Exit code `0` means no selected policy findings/regressions,
|
|
236
|
+
`2` means findings, and `1` means invalid input or execution failure.
|
|
237
|
+
Use a trusted local workspace and CLI. Do not put real private PCZTs into
|
|
238
|
+
public CI, browser demos, external MCP hosts, or logs.
|
|
239
|
+
|
|
240
|
+
## Swap refund and viewing-key privacy metadata audit
|
|
241
|
+
|
|
242
|
+
The installed `zerynex-refund-audit` command checks a strict, local JSON manifest of **opaque non-secret identifiers**, not Zcash addresses or keys. Its static findings cover refund-address reuse, shared viewing-key scope, public refund exposure, refund query disclosure and unsupported custody assertions. This is a threat-model integration aid, not a post-quantum cryptography implementation or real wallet inspection. See `docs/refund-privacy-audit.md` for schema, examples and limitations.
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
### Compare refund integration revisions
|
|
246
|
+
|
|
247
|
+
Use `zerynex-refund-audit --baseline /path/to/before.json --manifest /path/to/after.json --json` to detect **new per-flow** exposure declarations. A newly affected flow triggers a regression even if the same rule ID already applied to another flow. Exit `0` means no *new* declared risk events, exit `2` means new events, and exit `1` is invalid input. No private values or flow references are returned. Source manifests must contain **non-secret metadata only**. This does not attest wallet isolation or quantum safety. See `docs/refund-privacy-audit.md`.
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
The packaged refund-audit SDK also exports `audit_manifest`, `compare_manifests`, `sarif_report` and `RefundAuditInputError`. Add `--sarif` instead of `--json` when integrating with SARIF-capable tooling. The exported SARIF contains no source locations or opaque references and only covers **declared** risk categories.
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
## Refund privacy checks for local MCP agents
|
|
254
|
+
|
|
255
|
+
The optional read-only MCP server exposes
|
|
256
|
+
`audit_synthetic_refund_privacy(scenario)` and
|
|
257
|
+
`compare_synthetic_refund_privacy(baseline, candidate)`. Only the three
|
|
258
|
+
bundled scenario names `isolated`, `risky` and `regression-expanded`
|
|
259
|
+
are accepted; arbitrary paths and JSON are denied. The packaged
|
|
260
|
+
`zerynex-agent-preflight` verifies six offline, synthetic refund-privacy
|
|
261
|
+
expectations and the MCP doctor checks these tools via a real stdio host.
|
|
262
|
+
Agents never receive viewing keys, wallet data, refund addresses or flow
|
|
263
|
+
identifiers, and a passing synthetic declaration is **not** a post-quantum
|
|
264
|
+
privacy certification. For actual application-owned, public-safe metadata
|
|
265
|
+
use the standalone `zerynex-refund-audit` CLI in a trusted environment.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=75", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "zerynex-python"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Local Zcash PCZT developer toolkit: privacy policy analysis, synthetic MCP integrations, refund risk checks and infrastructure adapters"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
dependencies = []
|
|
13
|
+
keywords = ["zcash", "privacy", "pczt", "cryptography", "developer-tools"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
17
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Homepage = "https://zerynex.vercel.app"
|
|
22
|
+
Documentation = "https://zerynex.vercel.app/docs"
|
|
23
|
+
Repository = "https://github.com/Oluwa-Laughter/zerynex"
|
|
24
|
+
Issues = "https://github.com/Oluwa-Laughter/zerynex/issues"
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
mcp = ["mcp>=2,<3"]
|
|
28
|
+
dev = ["pytest>=8"]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
zerynex-mcp = "zerynex_py.mcp_server:main"
|
|
32
|
+
zerynex-mcp-doctor = "zerynex_py.mcp_doctor:main"
|
|
33
|
+
zerynex-z3-check = "zerynex_py.z3:main"
|
|
34
|
+
zerynex-node-check = "zerynex_py.node:main"
|
|
35
|
+
zerynex-rpc-check = "zerynex_py.rpc_contract:main"
|
|
36
|
+
zerynex-zallet-fixture-check = "zerynex_py.zallet_fixture:main"
|
|
37
|
+
zerynex-agent-preflight = "zerynex_py.preflight:main"
|
|
38
|
+
zerynex-project = "zerynex_py.project:main"
|
|
39
|
+
zerynex-refund-audit = "zerynex_py.refund_privacy:main"
|
|
40
|
+
|
|
41
|
+
[tool.setuptools.packages.find]
|
|
42
|
+
where = ["src"]
|
|
43
|
+
|
|
44
|
+
[tool.pytest.ini_options]
|
|
45
|
+
testpaths = ["tests"]
|
|
46
|
+
|
|
47
|
+
[tool.setuptools.package-data]
|
|
48
|
+
zerynex_py = ["fixtures/*.json", "fixtures/*.bin"]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from .node import NodeReadiness, evaluate_blockchain_info, inspect_node_local
|
|
2
|
+
from .rules import bundled_rule_catalog
|
|
3
|
+
from .refund_privacy import audit_manifest, compare_manifests, sarif_report, RefundAuditInputError
|
|
4
|
+
"""Local Python adapter for the shared Zerynex Rust PCZT privacy engine.
|
|
5
|
+
|
|
6
|
+
Use with a trusted Zerynex CLI executable. This package contains NO alternate
|
|
7
|
+
Zcash parser, remote upload service, signing functionality or LLM dependency.
|
|
8
|
+
"""
|
|
9
|
+
from .z3 import ZebraHealthReport, check_zebra_local
|
|
10
|
+
from .client import (
|
|
11
|
+
CliCapabilities,
|
|
12
|
+
Finding,
|
|
13
|
+
Policy,
|
|
14
|
+
Report,
|
|
15
|
+
StageComparison,
|
|
16
|
+
ZerynexClient,
|
|
17
|
+
ZerynexError,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
__all__ = ["bundled_rule_catalog", "CliCapabilities", "Finding", "Policy", "Report", "StageComparison", "ZerynexClient", "ZerynexError", "NodeReadiness", "evaluate_blockchain_info", "inspect_node_local", "ZebraHealthReport", "check_zebra_local", "audit_manifest", "compare_manifests", "sarif_report", "RefundAuditInputError"]
|
|
21
|
+
__version__ = "0.1.0"
|