feat: add Zcash chain support with PCZT signing and unified addresses#204
feat: add Zcash chain support with PCZT signing and unified addresses#204Kenbak wants to merge 1 commit intoopen-wallet-standard:mainfrom
Conversation
|
@Kenbak is attempting to deploy a commit to the MoonPay Team on Vercel. A member of the Team first needs to authorize it. |
bf90b48 to
ed4e72c
Compare
ed4e72c to
5aa40d7
Compare
| ))); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Transparent PCZT signing only handles address index zero
Low Severity
In sign_pczt, transparent input signing always derives the secret key at NonHardenedChildIndex::ZERO. Transparent inputs belonging to the same account but at a higher address index (analogous to Bitcoin change addresses) will be silently skipped by the TransparentSign error handler, producing a partially-signed PCZT that fails during finalization.
Reviewed by Cursor Bugbot for commit 5aa40d7. Configure here.
5aa40d7 to
806fe01
Compare
806fe01 to
0466199
Compare
Add Zcash as the first privacy-preserving chain in OWS, with full shielded transaction support via the PCZT format. Chain registration: - ChainType::Zcash with CAIP-2 namespace, coin type 133 - Default lightwalletd endpoints (zec.rocks mainnet/testnet) Wallet creation (ows wallet create): - ZIP-32 key derivation from BIP-39 seed (needs_raw_seed trait extension) - Unified address with Orchard + Sapling receivers, shielded by default PCZT signing (ows sign tx --chain zcash): - Orchard spend authorization (RedPallas) - Sapling spend authorization (Jubjub) - Transparent spend authorization (secp256k1) - Skips non-matching/dummy actions per standard Orchard builder behavior - Key material zeroized after use Sign + broadcast (ows sign send-tx --chain zcash): - PCZT finalization via TransactionExtractor - Broadcast via lightwalletd gRPC with TLS Feature-gated behind zcash-shielded (enabled by default in CLI). Without the feature, falls back to transparent-only t-address support. Dependencies: zcash_keys, pczt, orchard, sapling-crypto, zcash_transparent, zcash_protocol, zcash_primitives (all from librustzcash, maintained by ZODL). Tests: 27 Zcash-specific tests (15 signer unit tests + 12 library integration tests). All 465 workspace tests pass. Docs: zcash-guide.md covering wallet creation, PCZT pipeline, security model, configuration, and end-to-end workflow.
0466199 to
ede3e58
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit ede3e58. Configure here.
| buf.push(0xFF); | ||
| buf.extend_from_slice(&(n as u64).to_le_bytes()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Duplicated encode_compact_size function across signers
Low Severity
The encode_compact_size function in zcash.rs is an exact copy of the one in bitcoin.rs. This duplicated logic increases the risk of inconsistent bug fixes if the varint encoding ever needs to change. It belongs in a shared utility module.
Reviewed by Cursor Bugbot for commit ede3e58. Configure here.
There was a problem hiding this comment.
Intentional — both signers are standalone modules with no shared dependency between them. Extracting a common utility crate for a single 10-line function would add coupling without meaningful benefit. Each chain signer should remain self-contained so it can be enabled/disabled independently via feature flags.


Summary
Adds full Zcash support to OWS, including:
ChainSignertrait gainsneeds_raw_seed()andderive_address_from_seed()methods so Zcash can derive keys from the raw BIP-39 seed.u1…unified addresses containing Orchard + Sapling receivers (privacy-by-default, transparent omitted).sign send-txfinalizes the signed PCZT and broadcasts the raw transaction to Zcash's lightwalletd via gRPC.librustzcash,pczt,orchard,sapling-crypto) are behind azcash-shieldedfeature flag, so builds that don't need Zcash stay lean.What changed
chain.rs,config.rsChainType::Zcash, CAIP-2 namespacezcash,zcash:mainnetin known chainszcash.rs(new, 638 lines)ZcashSignerwith ZIP-32 derivation, unified address generation, PCZT signing, message signing. 15+ unit tests.traits.rsneeds_raw_seed(),derive_address_from_seed()ops.rs,lwd_grpc.rs(new)sign_and_broadcast_zcashpipeline, lightwalletd gRPC client. 12 integration tests.derive.rs,sign_transaction.rs,send_transaction.rszcash-guide.md(new),07-supported-chains.md,CONTRIBUTING.mdPCZT pipeline
OWS receives a proved PCZT, signs all pool inputs with the ZIP-32 spending key, extracts the finalized transaction, and broadcasts it. This matches OWS's existing model where the wallet is a signing primitive — transaction construction is the caller's responsibility.
Tested on mainnet
End-to-end verified: PCZT created externally → signed by OWS → broadcast via lightwalletd → confirmed on-chain.
c0a16bbf385dd6d17cbc29b07c998c73a7eba6b3fc12e8051eaa52044b79e29fTest plan
cargo test --workspace— all 465 tests passcargo test --features zcash-shielded— all 12 Zcash integration tests passcargo build --releasewithoutzcash-shielded— clean build, no Zcash deps pulledNote
High Risk
High risk because it adds new chain support that touches key derivation/signing paths and introduces a new broadcast transport (lightwalletd gRPC) plus substantial new crypto dependencies behind feature flags.
Overview
Adds first-class Zcash support across core, signer, library, and CLI, including
ChainType::Zcash, CAIP-2 IDs/aliases, and default RPC endpoints forzcash:mainnet/zcash:testnet.Introduces feature-gated shielded functionality (
zcash-shielded) with ZIP-32 raw-seed derivation via newChainSignerhooks (needs_raw_seed,derive_address_from_seed) and a newZcashSignerthat derives unified addresses and signs PCZTs (transparent + Sapling + Orchard).Extends signing and send flows to route Zcash transactions through PCZT signing/finalization and broadcast via lightwalletd gRPC (
lwd_grpc), updates CLI behavior accordingly (including disallowing message signing for shielded Zcash), and adds extensive Zcash-focused tests and documentation.Reviewed by Cursor Bugbot for commit ede3e58. Bugbot is set up for automated code reviews on this repo. Configure here.