causeway_sapling/lib.rs
1//! Causeway off-chain helpers for Zcash Sapling shielded assets.
2//!
3//! Sapling addresses are 43 bytes raw (11-byte diversifier ‖ 32-byte
4//! `pk_d`) wrapped in a network-specific bech32 envelope:
5//!
6//! - `zs1…` — mainnet
7//! - `ztestsapling1…` — testnet
8//! - `zregtestsapling1…` — regtest
9//!
10//! This crate ships pure parse/encode helpers. Building / signing the
11//! actual Sapling spend (PCZT, Groth16, FROST) lives entirely in the
12//! coordinator daemon and is opaque to SDK consumers — a tenant
13//! program or off-chain caller passes a recipient z-address through
14//! the on-chain `request_signing` flow and the coordinator handles
15//! the rest.
16//!
17//! No coordinator gRPC client is included by design: this crate is
18//! the off-chain mirror of the Sapling address-derivation surface,
19//! same as `causeway-zec` is for transparent ZEC. Coordinator-driving
20//! belongs in tenant-specific code, not in the per-asset SDK crates.
21//!
22//! # Example
23//!
24//! ```
25//! use causeway_sapling::{decode_sapling_address, encode_sapling_address, Network};
26//!
27//! let z = "zregtestsapling1euldd485nn489mlc9qs7g0vt9em845mfzehcp8sverxtwczhyuwhu8jzexhk8z6w4xt2wld40jr";
28//! let parsed = decode_sapling_address(z).unwrap();
29//! assert_eq!(parsed.network, Network::Regtest);
30//! assert_eq!(parsed.raw.len(), 43);
31//! let round_trip = encode_sapling_address(parsed.network, &parsed.raw).unwrap();
32//! assert_eq!(round_trip, z);
33//! ```
34
35#![forbid(unsafe_code)]
36
37pub mod address;
38
39pub use address::{decode_sapling_address, encode_sapling_address, Network, SaplingAddress, SaplingError};