ZecPy
Shielded Zcash for Python backends, with privacy you can measure: across create, sync, receive, restart and send, ZecPy sends its light server zero identifying requests. Two reference wallets send 7 and 71.
Website and docs · Privacy report · Testnet run · Bugs found upstream · Checkout API example · Privacy model
Built for ZECATHON (Core & Tooling) on librustzcash, Orchard and Ironwood, with Tor via arti.
The problem
A Python developer who wants to accept ZEC today shells out to a CLI or runs a full wallet server, and the light wallet code they would build on asks its server questions that give the user away: which transparent addresses are theirs, which transactions are theirs, where their last sync stopped. "Shielded" on chain, identifiable at the server.
What ZecPy does
wallet, mnemonic = await Wallet.create("./shop", network="test", server="https://testnet.zec.rocks:443")
invoice = wallet.invoices.create(150_000, "order-77") # its own shielded address + ZIP-321 URI
async for event in wallet.invoices.watch(confirmations=3):
if event.state == "confirmed" and event.invoice_settled:
ship(event.invoice.reference) # exactly once, even across restarts
- Invoices with a fresh diversified address each: payments match during local trial
decryption, with no memo and no request to the server. Events are
detected,confirmedandreverted(a reorg removed the block), persisted so a restart never re-delivers. - Sending:
sendandsend_many(up to 50 recipients, one transaction), proved and signed locally. Transparent recipients raisePrivacyErrorunless explicitly allowed. - Cold signing: the server imports a viewing key only (
Wallet.watch), builds and proves a PCZT; the offlinezecpy-coldsigner shows what will leave the wallet and signs. - Tor by default: every sync session and every broadcast on its own isolated circuit, retried on fresh circuits, never falling back to a direct connection.
- Fee preview:
proposeshows the fee, the notes spent, the change and any value that would become public by crossing pools;send_proposalsends exactly that transaction. A crossing that publishes its amount raisesPrivacyErrorunless allowed. - Payment links for agents:
pay(uri, max_zat=...)pays a ZIP-321 request, refused whole if it asks for more than the budget or names no amount. - History and memos:
transactions()reads the local database only. Received memos are opt-in (fetch_memos), since compact blocks do not carry them: each real fetch goes out over Tor shuffled among 7 decoy transactions from nearby blocks. - Sweep:
propose_sweepempties a wallet, fee included, with nothing left behind.
How it works
python/zecpy/ Wallet, invoices, cold signer, async API (Python)
src/ PyO3 core: sync loop, send, PCZT, Tor connections (Rust)
└─ librustzcash: zcash_client_backend 0.25, zcash_client_sqlite 0.23,
orchard 0.16, pczt 0.10, zcash_proofs (bundled Sapling params)
tools/leak_audit/ gRPC proxy that decodes and classifies every request a wallet makes
devnet/ local regtest chain: zebrad 7.0.0 + lightwalletd 0.6.0, Ironwood active
No cryptography is reimplemented. Details: docs/architecture.md.
Technical highlights
- A leak in librustzcash's own sync, found by measuring.
sync::runasks for the tree state where the previous sync stopped, linking sessions. ZecPy's sync loop (src/sync.rs) takes the tip's state fromGetLatestTreeState, saves it, and splits batches only at absolute multiples of 1,000. - A reorg bug it also shares: a reorg onto a branch that is not yet longer went unnoticed.
ZecPy compares block hashes at the tip. Both are filed upstream with fixes:
librustzcash #3197,
PR #3198 and
PR #3199, plus a zcash-devtool bug
found the same way, its
pczt signskipping Ironwood spends (#266, fix PR #267). - A signer that does not trust the server.
zecpy-coldidentifies change outputs with its own viewing key, so a compromised server cannot disguise a payment to itself as change (src/cold.rs).
Quick start
pip install zecpy
Prebuilt wheels for Linux x86_64 and macOS on Apple silicon, Python 3.10 or newer: no Rust
toolchain, nothing to compile. Other platforms build from source (below). Each wheel is installed and smoke-tested on
its own platform in CI, including a wallet synced over Tor on public testnet
(tests/smoke.py).
import asyncio
from zecpy import Wallet
async def main():
wallet, mnemonic = await Wallet.create("./shop", network="test",
server="https://testnet.zec.rocks:443")
print(await wallet.sync(), wallet.address())
asyncio.run(main())
From source
Needs a Rust toolchain (tested with 1.99). The first build compiles librustzcash: 11 to 19 minutes on a 4-core machine, plus the time to download the crates.
git clone https://github.com/xerodahdev/zecpy && cd zecpy
uv venv .venv && . .venv/bin/activate # or python -m venv (Debian/Ubuntu: apt install python3-venv)
uv pip install -e '.[dev,examples]'
python -c "import zecpy; print(zecpy.__all__)"
Run the tests against a local chain (devnet/README.md lists the
binaries): devnet/up.sh <shielded address>, then pytest. Tor tests against public
testnet: pytest -m network.
What is real, what is not
- Real, tested: everything above, on a local regtest chain with real blocks, proofs and
reorgs (
invalidateblock): 78 tests. A send takes about 11 s on a 4-core VPS; the fee is 10,000 zatoshis. - Real, public network: a full merchant run on testnet against
testnet.zec.rocks(record). A watch-only shop was paid by zcash-devtool, matched the payment by address, read the memo among 7 real third-party decoys, and refunded through the offline signer. An agent wallet refused a payment link over budget, then paid it within budget over ZecPy's own Tor. Fourteen minutes, five transactions, all txids listed. The shop's 108 requests were audited on their way to the server over Tor: none identified it outside the opt-in memo fetch. No mainnet funds were moved. - Unit-tested only: the pool-crossing refusal. The regtest chain activates Ironwood at
height 1, so it never holds Orchard notes and no real crossing can be built there; the
per-pool calculation is tested on constructed inputs, and the ZIP 318 canonical check is
librustzcash's own
Step::is_canonical_crossing. - By design, not built: transparent receiving (it needs requests that identify the
wallet; see the table below). The
pcztdependency compiles librustzcash's transparent code in; ZecPy never calls it, and the leak audit checks that on every run.
What ZecPy deliberately does not do
Each of these is a request a light server could use to identify the wallet, or a feature whose privacy cost ZecPy will not hide behind a default.
| Not done | Why | Where it lives instead |
|---|---|---|
| Transparent receiving and shielding | Needs GetAddressUtxos/GetTaddressTxids queries that name the wallet's addresses |
zcash-devtool wallet shield |
| Memo fetching by default | Every fetch names a txid; ZecPy makes it opt-in and hides it among decoys | fetch_memos() |
| Mempool watching | Detection waits for the block; GetMempoolTx would send the txids the wallet knows |
Compact blocks at the next block |
| Status lookups for orphaned payments | GetTransaction by txid; an orphaned payment stays pending until re-mined |
See the privacy model |
| More than one account, multisig, hardware wallets | Out of scope for a backend SDK | zcash-devtool zip48, pczt |
Prior art
- zcash-devtool: the official CLI on the same librustzcash crates, and ZecPy's reference for how they fit together. It is the control wallet in the privacy report.
- pyzcash: PyO3 bindings for addresses, ZIP-321 and seed to Unified Address. No sync or send.
- zeccheckout: a Rust checkout service with viewing-key invoices on testnet. The same payment-detection idea as a service; ZecPy is a library.
- WebZjs and the mobile SDKs bring librustzcash to other languages, not Python.
Limitations and next
No Windows wheel yet. A reorg costs one identifying tree-state request, and an orphaned incoming payment stays pending until it is re-mined (details). Next: a Windows wheel, and the upstream fixes through review.
Metadata
Release files for zecpy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zecpy-0.1.0.tar.gz | 172.2 kB | Without provenance | Details for zecpy-0.1.0.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zecpy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for zecpy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl |
| zecpy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for zecpy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 129.0 MB
Release files / zecpy-0.1.0.tar.gz
| Download URL | zecpy-0.1.0.tar.gz |
|---|---|
| Size | 172.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
514a894fcbd7701c31c77ca0bf56ad140a2794b4d59c791e5edba9ff8c2ee68e
|
|
BLAKE2b-256 checksum How to use checksums |
4f3512ee9e33ec74835b4c07928315a11c89fe30d0ce2083b40f12a435e92759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / zecpy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | zecpy-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 64.7 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
fa0ad9606c9b52c2d1d3258832e3499a9e371b69e1f5344483b13354054ff716
|
|
BLAKE2b-256 checksum How to use checksums |
9b2f8230e024fcd51b37383cd4e6110646235b231acd91a8f9456ed1f5a39180
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / zecpy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | zecpy-0.1.0-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 64.1 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d350ba0016dbc1824330d3b42cf10186f5c0cb9939ca8ecffd5145d2ec49b72c
|
|
BLAKE2b-256 checksum How to use checksums |
e54bf9f226cc34314507698630797128c39f8163e9e5c1eb6b6e1150d32725ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for zecpy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.