Skip to main content

Crate zync_core

Crate zync_core 

Source
Expand description

§zync-core

Trust-minimized Zcash light client primitives. Remaining trust assumptions: the hardcoded activation block hash, the cryptographic proof systems (ligerito, NOMT, Halo 2), and your key material.

§Trust model

A zync-powered light client verifies every claim the server makes:

  1. Header chain. ligerito polynomial commitment proofs over block headers. The prover encodes headers into a trace polynomial and commits to the evaluation; the verifier checks the commitment in O(log n) without seeing any headers. Public outputs (block hashes, state roots, commitments) are transcript-bound but NOT evaluation-proven — the ligerito proximity test does not constrain which values the polynomial contains. Soundness relies on the honest-prover assumption; cross-verification (item 4) detects a malicious prover. Proven roots anchor subsequent steps.

  2. State proofs. NOMT sparse merkle proofs for note commitments and nullifiers. Each proof binds to the tree root proven by the header chain. Commitment proofs verify that received notes exist in the global tree. Nullifier proofs verify spent/unspent status without trusting the server.

  3. Actions integrity. A running Blake2b commitment chain over per-block orchard action merkle roots. Verified against the header-proven value to detect block action tampering (inserted, removed, or reordered actions).

  4. Cross-verification. BFT majority consensus against independent lightwalletd nodes. Tip and activation block hashes are compared with

    2/3 agreement required. Prevents single-server eclipse attacks.

  5. Trial decryption. Orchard note scanning with cmx recomputation. After decryption, the note commitment is recomputed from the decrypted fields and compared against the server-provided cmx. A malicious server cannot craft ciphertexts that decrypt to fake notes with arbitrary values.

§Modules

  • verifier: ligerito header chain proof verification (epoch + tip, parallel)
  • nomt: NOMT sparse merkle proof verification (commitments + nullifiers)
  • actions: actions merkle root computation and running commitment chain
  • scanner: orchard note trial decryption (native + WASM parallel)
  • sync: sync verification primitives (proof validation, cross-verify, memo extraction)
  • prover: ligerito proof generation from header chain traces
  • trace: header chain trace encoding (headers to polynomial)
  • client: gRPC clients for zidecar and lightwalletd (feature-gated)

§Platform support

Default features (client, parallel) build a native library with gRPC clients and rayon-based parallel scanning. For WASM, disable defaults and enable wasm or wasm-parallel:

zync-core = { version = "0.4", default-features = false, features = ["wasm-parallel"] }

WASM parallel scanning requires SharedArrayBuffer (COOP/COEP headers) and builds with:

RUSTFLAGS='-C target-feature=+atomics,+bulk-memory,+mutable-globals' \
  cargo build --target wasm32-unknown-unknown

§Minimal sync loop

use zync_core::{sync, verifier, Scanner, OrchardFvk};

// 1. fetch header proof from zidecar
let (proof_bytes, _, _) = client.get_header_proof().await?;

// 2. verify and extract proven NOMT roots
let proven = sync::verify_header_proof(&proof_bytes, tip, true)?;

// 3. scan compact blocks for owned notes
let scanner = Scanner::from_fvk(&fvk);
let notes = scanner.scan(&actions);

// 4. verify commitment proofs for received notes
sync::verify_commitment_proofs(&proofs, &cmxs, &proven, &server_root)?;

// 5. verify nullifier proofs for unspent notes
let spent = sync::verify_nullifier_proofs(&nf_proofs, &nullifiers, &proven, &nf_root)?;

// 6. verify actions commitment chain
sync::verify_actions_commitment(&running, &proven.actions_commitment, true)?;

Re-exports§

pub use error::Result;
pub use error::ZyncError;
pub use scanner::BatchScanner;
pub use scanner::DecryptedNote;
pub use scanner::ScanAction;
pub use scanner::Scanner;
pub use client::LightwalletdClient;
pub use client::ZidecarClient;

Modules§

actions
Actions merkle root computation and running commitment chain.
client
gRPC clients for Zcash light wallet services
endpoints
Public lightwalletd endpoints for cross-verification.
error
error types for zync
nomt
NOMT proof verification primitives shared between zcli and zidecar.
prover
Ligerito proof generation for header chain traces.
scanner
WASM-compatible parallel note scanner for Orchard
sync
Sync verification primitives for Zcash light clients.
trace
Header chain trace encoding for ligerito polynomial commitment proofs.
verifier
ligerito proof verification with continuity checking

Structs§

IncomingViewingKey
A key that provides the capability to detect and decrypt incoming notes from the block chain, without being able to spend the notes or detect when they are spent.
OrchardFvk
A key that provides the capability to view incoming and outgoing transactions.
SpendingKey
A spending key, from which all key material is derived.

Enums§

Scope
The scope of a viewing key or address.

Constants§

ACTIVATION_HASH_MAINNET
orchard activation block hash (mainnet, LE internal order)
DOMAIN_EPOCH_PROOF
domain separator for epoch proof hash
DOMAIN_IVK_COMMIT
domain separator for ivk commitment
DOMAIN_WALLET_STATE
domain separator for wallet state commitment
EMPTY_SMT_ROOT
empty sparse merkle tree root
EPOCH_PROOF_TRACE_LOG_SIZE
polynomial size exponent for epoch proofs (2^26 config)
EPOCH_SIZE
blocks per epoch (~21 hours at 75s/block)
FIELDS_PER_ACTION
fields encoded per action in trace polynomial
FIELDS_PER_HEADER
fields encoded per block header in trace polynomial
GENESIS_EPOCH_HASH
genesis epoch hash (all zeros)
MAX_ACTIONS_PER_BLOCK
max orchard actions per block
ORCHARD_ACTIVATION_HEIGHT
orchard activation height (mainnet)
ORCHARD_ACTIVATION_HEIGHT_TESTNET
orchard activation height (testnet)
SECURITY_BITS
security parameter (bits)
TIP_SENTINEL_SIZE
sentinel row size appended after all headers in trace
TIP_TRACE_LOG_SIZE
polynomial size exponent for tip proofs (2^20 config, max ~32K headers)

Functions§

epoch_end
helper: get end height of epoch (inclusive)
epoch_for_height
helper: calculate epoch number from block height
epoch_proof_prover_config
ligerito prover config for epoch proofs (2^26)
epoch_start
helper: get start height of epoch
prover_config_for_size
select the appropriate prover config for a given trace size
tip_prover_config
ligerito prover config for tip proofs (2^20)
verifier_config_for_log_size
select the appropriate verifier config for a given log size