Native Groth16 BN254 verification primitives for the Xian stack
Project description
xian-tech-zk
Small native zero-knowledge verification and proving primitives for the Xian workspace.
Purpose
- This package exposes the narrow verifier surface used by the Xian runtime.
- It exposes an external proving toolkit for the shielded-note-token development flow.
- It is intentionally small. It is not a general-purpose zk framework.
Current Scope
- Groth16 verification
- BN254
- Python bindings for runtime integration
- A pure Rust verifier core for cargo-level testing and fixtures
- Shielded-note proving circuits and proof generation helpers
- Shielded scheduler-update authorization circuit and proof helpers
- Deterministic dev bundle generation for local shielded-note workflows
- Note math helpers for commitments, nullifiers, asset ids, and Merkle roots
- Trusted local prover-service support for note, command, and relay proof generation
flowchart LR
Wallet["Shielded wallet"] --> Request["Proof request"]
Request --> Prover["xian-zk prover toolkit"]
Prover --> Proof["Groth16 proof and public inputs"]
Proof --> Contract["Shielded contract"]
Contract --> Registry["zk_registry verifying key"]
Contract --> Bridge["contract-side zk bridge"]
Bridge --> Verifier["xian-zk verifier"]
API
Python module xian_zk exposes:
- raw and prepared Groth16 BN254 verification
- native public-input, payload-hash, tree, and command digest helpers
- shielded note request/result/prover/wallet types
- shielded command request/result/prover/wallet types
- shielded relay transfer request/result/prover/wallet types
- shielded scheduler authorization request/result/prover types
- registry manifest helpers for note, command, relay, and scheduler authorization verifying keys
- note encryption/decryption, discovery-tag, sync-hint, and wallet sync helpers
- local prover service clients and
ShieldedZkProverService
CLI entrypoints:
uv run xian-zk-shielded-bundle generate-note --output-dir ...uv run xian-zk-shielded-bundle generate-command --output-dir ...uv run xian-zk-shielded-bundle import-note --bundle ... --output-dir ...uv run xian-zk-shielded-bundle import-command --bundle ... --output-dir ...uv run xian-zk-shielded-bundle validate-note --bundle ...uv run xian-zk-shielded-bundle validate-command --bundle ...uv run xian-zk-shielded-bundle promote --network ... --contract-name ...--note-bundle ... --relay-command-bundle ... --output-dir ...uv run xian-zk-prover-service --host 127.0.0.1 --port 8787 ...
The Rust crate exposes the verifier core, shielded fixture builders, and proof generation helpers used by the Python bindings and tests.
Encoding
- Verifying keys: compressed canonical bytes as
0x-prefixed hex - Proofs: compressed canonical bytes as
0x-prefixed hex - Public inputs: 32-byte big-endian field elements as
0x-prefixed hex
Validation
cargo test --manifest-path packages/xian-zk/Cargo.toml --no-default-featurescargo run --manifest-path packages/xian-zk/Cargo.toml --no-default-features --example generate_test_vectorcargo run --manifest-path packages/xian-zk/Cargo.toml --no-default-features --example generate_shielded_note_fixturecd packages/xian-zk && uv sync --group dev && uv run maturin develop && uv run pytest -qcd packages/xian-zk && uv run pytest -q -m slow
Build performance: the [profile.dev] block in Cargo.toml sets opt-level = 3,
so even a plain maturin develop produces optimized proving/setup. Without it an
unoptimized build is ~25x slower (Groth16 setup ~100s vs ~4s) — do not lower it.
Published/CI wheels build --release regardless.
Notes
- The runtime-facing verifier surface is intentionally narrow.
- The shielded-note proving helpers are an external proving toolkit slice, not a broad proving framework.
- The shielded-note circuits use Merkle auth paths instead of witnessing the
whole leaf set, and the shipped dev bundle / fixture ids are
v4for the note family andv5for the command family. The circuits hash with Poseidon-BN254 (seesrc/poseidon.rs). - The scheduler authorization circuit is intentionally small: it proves knowledge of a hidden owner secret for a public owner commitment and derives an update nullifier from that secret plus the exact public update digest.
- Shielded outputs are addressed to
owner_public, not to the recipient's spending secret. That lets senders create recipient outputs without learning the recipient's private shielded spend key. - The Python toolkit separates spending and viewing authority. A wallet can disclose note contents by sharing only a viewing key or by adding explicit extra viewers to an encrypted note payload without exposing the spend key.
- The Python toolkit ships a first-class
ShieldedWalletabstraction for seed backup, state snapshots, record sync, note selection, and request planning for deposit / transfer / withdraw flows. - The package ships deployment CLI helpers that generate or import proving
bundles, emit public registry manifests, write
register_and_bind.pyoperator helpers, and create catalog snippets for promoted ceremony artifacts. Keep private bundles offline; only registry manifests should be used forzk_registryregistration. - The encrypted payload format supports owner delivery plus optional disclosed viewers inside a single on-chain payload blob.
- The encrypted payload format uses anonymous per-viewer discovery tags and ephemeral keys for payloads, so recipient viewing keys are not embedded in cleartext.
ShieldedWallet.sync_records(...)prefilters candidate payloads before full decryption, and note records exposepayload_tagsso indexers can persist discovery metadata for later selective queries.xian-zk-prover-serviceis a trusted local proving companion, not a true split-prover protocol. It improves deployability and wallet ergonomics, but the service sees witness material.xian-zk-prover-servicedefaults to127.0.0.1. IPv6 literal binds are supported with::1or[::1]; non-loopback binds such as::still require--unsafe-allow-remote-hostand--auth-token.- Exact withdraws do not need a forced change note. A withdraw can spend a note set down to zero shielded outputs when value conservation closes exactly.
- The proving requests separate
old_rootfromappend_state, which lets a client prove against a recent accepted root while projecting the canonical post-state from the current append frontier. - Python
pytestexcludes the slow proof-generation tests by default. Runpytest -m slowexplicitly when you want the proving-toolkit path. - The contract runtime prefers registry-backed verification by
vk_id; this package exposes the lower-level raw and prepared-key verifier primitives that runtime builds on. ShieldedNoteProver.build_insecure_dev_bundle()is for local development and tests only. Its deterministic setup seed exposes toxic waste and must never be used for a real network.ShieldedNoteProver.build_random_bundle(...)andxian-zk-shielded-bundle generate-notegenerate a single-party random trusted setup. That is appropriate for deployment tooling, but it is not an MPC ceremony.- Proof generation uses real randomness even when the proving bundle is a deterministic dev bundle.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xian_tech_zk-0.2.0.tar.gz.
File metadata
- Download URL: xian_tech_zk-0.2.0.tar.gz
- Upload date:
- Size: 84.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b74f27fc876d85844b8d79997ae7787619d3d85e92cf562bc96de58145f9c340
|
|
| MD5 |
bbc7800a29f29d677734c91a6c5ba4f5
|
|
| BLAKE2b-256 |
84d61d5c28f58bfade74411d69a78df0b74d7dc4dcfb3621c02f4c00ae97e7e4
|
Provenance
The following attestation bundles were made for xian_tech_zk-0.2.0.tar.gz:
Publisher:
release.yml on xian-technology/xian-contracting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_zk-0.2.0.tar.gz -
Subject digest:
b74f27fc876d85844b8d79997ae7787619d3d85e92cf562bc96de58145f9c340 - Sigstore transparency entry: 2139153460
- Sigstore integration time:
-
Permalink:
xian-technology/xian-contracting@157a02d4e999e39a943d87dc0787f28b2a463628 -
Branch / Tag:
refs/tags/zk-v0.2.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@157a02d4e999e39a943d87dc0787f28b2a463628 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_zk-0.2.0-cp314-abi3-win_amd64.whl.
File metadata
- Download URL: xian_tech_zk-0.2.0-cp314-abi3-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.14+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e94e9c4a33df500ddc5c72e31e3338cdc2cd007e513469372cee11e365ca7c9
|
|
| MD5 |
bdc053ecfe87e583ef52d0de0c0e24ab
|
|
| BLAKE2b-256 |
5044b0464c5dcf5802907ba002d7e67ee2e05fa1f9126947ccea4d8d8e963e2e
|
Provenance
The following attestation bundles were made for xian_tech_zk-0.2.0-cp314-abi3-win_amd64.whl:
Publisher:
release.yml on xian-technology/xian-contracting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_zk-0.2.0-cp314-abi3-win_amd64.whl -
Subject digest:
1e94e9c4a33df500ddc5c72e31e3338cdc2cd007e513469372cee11e365ca7c9 - Sigstore transparency entry: 2139153570
- Sigstore integration time:
-
Permalink:
xian-technology/xian-contracting@157a02d4e999e39a943d87dc0787f28b2a463628 -
Branch / Tag:
refs/tags/zk-v0.2.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@157a02d4e999e39a943d87dc0787f28b2a463628 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_zk-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: xian_tech_zk-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.14+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80dbdbea00fa167b8068f718b8b670882738ce2a333f6be661300cddbf79270
|
|
| MD5 |
4a6b677d31891da8e85f275eb5a74ada
|
|
| BLAKE2b-256 |
cd6e3685ad25fe094394f0149fe1e6cf767de01e2f06a7df0c89f78769f13932
|
Provenance
The following attestation bundles were made for xian_tech_zk-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on xian-technology/xian-contracting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_zk-0.2.0-cp314-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
e80dbdbea00fa167b8068f718b8b670882738ce2a333f6be661300cddbf79270 - Sigstore transparency entry: 2139153628
- Sigstore integration time:
-
Permalink:
xian-technology/xian-contracting@157a02d4e999e39a943d87dc0787f28b2a463628 -
Branch / Tag:
refs/tags/zk-v0.2.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@157a02d4e999e39a943d87dc0787f28b2a463628 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_zk-0.2.0-cp314-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: xian_tech_zk-0.2.0-cp314-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.14+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58f943a59f909c15387de69484f7bfae0ca4e7eae7b836fe5b163d998599c91b
|
|
| MD5 |
558aa87f96462d72699d3208ae5d619f
|
|
| BLAKE2b-256 |
2423567cb2f80b99995507de12f15e8782e75d94bdec955a9d65208f10b22aef
|
Provenance
The following attestation bundles were made for xian_tech_zk-0.2.0-cp314-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on xian-technology/xian-contracting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_zk-0.2.0-cp314-abi3-macosx_11_0_arm64.whl -
Subject digest:
58f943a59f909c15387de69484f7bfae0ca4e7eae7b836fe5b163d998599c91b - Sigstore transparency entry: 2139153511
- Sigstore integration time:
-
Permalink:
xian-technology/xian-contracting@157a02d4e999e39a943d87dc0787f28b2a463628 -
Branch / Tag:
refs/tags/zk-v0.2.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@157a02d4e999e39a943d87dc0787f28b2a463628 -
Trigger Event:
push
-
Statement type:
File details
Details for the file xian_tech_zk-0.2.0-cp314-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: xian_tech_zk-0.2.0-cp314-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.14+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d8479113e13d57123baf6c7d4359f525d7a8b0583dfcffbac76659d9178c341
|
|
| MD5 |
d0093bb70f752f2b4c573acff64edf9f
|
|
| BLAKE2b-256 |
bfe75d657f0076058a6eac31dc979c7a51a244b6167afd5252468251d4546a58
|
Provenance
The following attestation bundles were made for xian_tech_zk-0.2.0-cp314-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on xian-technology/xian-contracting
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
xian_tech_zk-0.2.0-cp314-abi3-macosx_10_12_x86_64.whl -
Subject digest:
4d8479113e13d57123baf6c7d4359f525d7a8b0583dfcffbac76659d9178c341 - Sigstore transparency entry: 2139153687
- Sigstore integration time:
-
Permalink:
xian-technology/xian-contracting@157a02d4e999e39a943d87dc0787f28b2a463628 -
Branch / Tag:
refs/tags/zk-v0.2.0 - Owner: https://github.com/xian-technology
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@157a02d4e999e39a943d87dc0787f28b2a463628 -
Trigger Event:
push
-
Statement type: