Skip to main content

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 tooling (the runtime verifies through xian-tech-vm-core, which links this crate)
  • A pure Rust verifier core, linked into xian-vm-core and used 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

Bundle dimensions (tree_depth, leaf_capacity, max_inputs, max_outputs) are JSON integers, with booleans rejected. Note and command bundles require positive dimensions and sufficient capacity for the declared depth; capacity validation does not allocate a tree or construct an exponential integer.

Validation

  • cargo test --manifest-path packages/xian-zk/Cargo.toml --no-default-features
  • cargo run --manifest-path packages/xian-zk/Cargo.toml --no-default-features --example generate_test_vector
  • cargo run --manifest-path packages/xian-zk/Cargo.toml --no-default-features --example generate_shielded_note_fixture
  • cd packages/xian-zk && uv sync --group dev && uv run maturin develop && uv run pytest -q
  • cd 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 v4 for the note family and v5 for the command family. The circuits hash with Poseidon-BN254 (see src/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 ShieldedWallet abstraction 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.py operator helpers, and create catalog snippets for promoted ceremony artifacts. Keep private bundles offline; only registry manifests should be used for zk_registry registration.
  • 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 expose payload_tags so indexers can persist discovery metadata for later selective queries.
  • xian-zk-prover-service is 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-service defaults to 127.0.0.1. IPv6 literal binds are supported with ::1 or [::1]; non-loopback binds such as :: still require --unsafe-allow-remote-host and --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_root from append_state, which lets a client prove against a recent accepted root while projecting the canonical post-state from the current append frontier.
  • Python pytest excludes the slow proof-generation tests by default. Run pytest -m slow explicitly 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(...) and xian-zk-shielded-bundle generate-note generate 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.

Prover-service diagnostics

Unexpected HTTP failures return a generic 500 error with an incident_id, also included in the client-visible reference message. The xian_zk.prover_service logger emits a UTC error record with that identifier, exception type and bounded stack locations. It omits exception messages, locals, request paths, headers, witnesses and proof material. The package does not configure global logging; applications may attach their own handlers. A failed handler cannot prevent the generic response. Expected validation/authentication errors retain their existing HTTP statuses and are not logged as unexpected operator failures.

Metadata

Release files for xian-tech-zk 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xian-tech-zk 0.2.1
File Size Uploaded Provenance Actions
xian_tech_zk-0.2.1.tar.gz 90.5 kB With provenance Details for xian_tech_zk-0.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for xian-tech-zk 0.2.1
File Actions
xian_tech_zk-0.2.1-cp314-abi3-win_amd64.whl CPython 3.14 abi3 Windows x86-64 Details for xian_tech_zk-0.2.1-cp314-abi3-win_amd64.whl
xian_tech_zk-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.14 abi3 Linux glibc 2.17+ x86-64 Details for xian_tech_zk-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
xian_tech_zk-0.2.1-cp314-abi3-macosx_11_0_arm64.whl CPython 3.14 abi3 macOS 11.0+ ARM64 Details for xian_tech_zk-0.2.1-cp314-abi3-macosx_11_0_arm64.whl
xian_tech_zk-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl CPython 3.14 abi3 macOS 10.12+ x86-64 Details for xian_tech_zk-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl

Total release size: 5.0 MB

Release files / xian_tech_zk-0.2.1.tar.gz

Download URL xian_tech_zk-0.2.1.tar.gz
Size 90.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b5e81f742cd11ad921c11fba162ef9d1c5a7725aa6e2ebc75274568dadd5c4fe
BLAKE2b-256 checksum
How to use checksums
097ec48a75b997d1e546cad15411999a26fe616d93804f694b30a93f59bfd3ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_zk-0.2.1-cp314-abi3-win_amd64.whl

Download URL xian_tech_zk-0.2.1-cp314-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.14 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
3f0cc9150e258c9955c03b2739c694e3b256a54f1141e297e9147f006eee9b62
BLAKE2b-256 checksum
How to use checksums
fe0f4910306683961fa9081ab8b69dfc9d395b5387e5b9bf4502d63807b59aeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_zk-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL xian_tech_zk-0.2.1-cp314-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.3 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
64b3a324e157f1aa77ca3104e1aeed966172c5d2775128e3b2c774169c163256
BLAKE2b-256 checksum
How to use checksums
004037de6bb22a96ada6f1d39f501843ac263ea61cf1f136f23b80e0bee3d191
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_zk-0.2.1-cp314-abi3-macosx_11_0_arm64.whl

Download URL xian_tech_zk-0.2.1-cp314-abi3-macosx_11_0_arm64.whl
Size 1.2 MB
Tags CPython 3.14 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2c5e2e77d54c47487ba8b352d139f83e8656696fccdf34cc208b6a589caf972f
BLAKE2b-256 checksum
How to use checksums
93819c1abe55610dd3b1013ea4e6e9e6acb360318b55b140c4064ddf07f8b599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Release files / xian_tech_zk-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl

Download URL xian_tech_zk-0.2.1-cp314-abi3-macosx_10_12_x86_64.whl
Size 1.2 MB
Tags CPython 3.14 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
de6d16d40ba0a4da85805e505f8218cccfa6eb449e567064ab37585e114cb6b4
BLAKE2b-256 checksum
How to use checksums
dda8b9f2b916979a4d3c29b1282f7484d020aec76af2ccd9e3eff40bc7a2f138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

Security for xian-tech-zk 0.2.1

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for xian_tech_zk-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page