Skip to main content

Overview

NEXUS-Zcash extends the NEXUS metaprotocol to Zcash, enabling full smart contract programmability and unified liquidity. Deploy the same WASM contracts on Zcash L1 as on Bitcoin and Dogecoin.

Trustless Verification

NEXUS-Zcash is fully trustless - no federation, no multisig, no trusted third parties.

How Trustlessness is Achieved

  1. Cryptographic Proofs: Every state transition is proven via Groth16 ZK-SNARKs
  2. On-Chain Verification: Proofs are verified directly on Zcash L1
  3. Economic Security: Provers post bonds that are slashed for invalid states
  4. Permissionless Challenges: Anyone can challenge invalid state transitions
  5. Self-Custody: Users always retain escape hatch to recover funds
┌─────────────────────────────────────────────────────────────────┐
│                    Trustless Verification Flow                   │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  1. Prover executes WASM contracts                              │
│                    │                                             │
│                    ▼                                             │
│  2. Generates Groth16 proof of correct execution                │
│                    │                                             │
│                    ▼                                             │
│  3. Posts state commitment + proof to Zcash L1 (OP_RETURN)      │
│                    │                                             │
│                    ▼                                             │
│  4. Anyone can verify proof on-chain                            │
│                    │                                             │
│                    ▼                                             │
│  5. Invalid proofs → Prover bond slashed                        │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Security Model

Cryptographic Soundness (Groth16)

NEXUS-Zcash leverages Zcash’s native Groth16 ZK-SNARK infrastructure for on-chain proof verification:
  • Groth16 proofs - Succinct proofs (~200 bytes) with fast verification
  • Zcash’s Trusted Setup - Uses Zcash’s Powers of Tau ceremony (Sapling MPC)
  • Native On-Chain Verification - Zcash nodes natively verify Groth16 proofs
  • Efficient - Constant-size proofs regardless of computation complexity

Zcash Native Proof Verification

Unlike Bitcoin where proof verification requires BitVM2 bisection games, Zcash can natively verify Groth16 proofs on-chain. This is because Zcash already has built-in support for Groth16 verification (used for shielded transactions).
┌─────────────────────────────────────────────────────────────────┐
│              Zcash Native Proof Verification                     │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  NEXUS Prover                      Zcash L1                     │
│  ┌─────────────┐                   ┌─────────────────────────┐  │
│  │ Execute     │                   │                         │  │
│  │ WASM        │──── Groth16 ────► │  Native Groth16         │  │
│  │ Contracts   │     Proof         │  Verifier (built-in)    │  │
│  │             │                   │                         │  │
│  │ Generate    │                   │  ✓ Verify proof         │  │
│  │ Proof       │                   │  ✓ Check public inputs  │  │
│  └─────────────┘                   │  ✓ Accept/Reject        │  │
│                                    └─────────────────────────┘  │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Why Zcash’s Trusted Setup?

NEXUS-Zcash uses Zcash’s existing trusted setup from the Sapling MPC ceremony:
AspectDetails
CeremonyZcash Sapling Powers of Tau (2018)
Participants90+ independent participants
SecurityOnly 1 honest participant needed
VerificationPublicly verifiable transcript
ReuseNo new ceremony required for NEXUS
By using Zcash’s existing trusted setup, NEXUS-Zcash inherits the security of the largest MPC ceremony ever conducted for a cryptocurrency.

Why Groth16 for Zcash?

PropertyGroth16ZK-STARK
Proof Size~200 bytes~50-100 KB
Verification Time~10ms~100ms
Trusted SetupRequired (Zcash has it)Not required
Zcash Native✅ Yes❌ No
On-Chain Verify✅ Direct❌ Requires BitVM

Fraud Proofs

  • Provers post bonds on Zcash L1
  • State commitments via OP_RETURN outputs
  • Invalid state transitions can be challenged
  • Groth16 proofs verified directly by Zcash nodes
  • Fraudulent provers lose bonds to challengers

Combined Model

Groth16 Proofs (Zcash Native Verification) + Economic Bonds (Zcash L1)
                    =
         Trustless Verification with Direct On-Chain Proof Checking

Full WASM Smart Contracts

NEXUS-Zcash supports the complete WASM smart contract system - the same contracts that run on Bitcoin and Dogecoin run identically on Zcash.

Contract Capabilities

FeatureSupportDescription
WASM ExecutionFull WebAssembly runtime
Cross-Contract CallsCall any deployed contract
Delegate CallsExecute code in caller’s context
Contract DeploymentDeploy new contracts from contracts
StoragePersistent key-value storage
EventsEmit events for indexing
Reentrancy GuardsBuilt-in protection

Cross-Contract Calls (xcc)

Contracts can call other contracts seamlessly:
use nexus_sdk::contract_api::xcc;

// Call another contract
nexus_fn! {
    fn swap_zec_for_token(token: Address, amount: U256, min_out: U256) {
        // Get token balance before
        let balance_before = xcc::call(&token.0, "balanceOf", &encode_addr(&self_addr));
        
        // Call AMM router to swap
        xcc::call(&AMM_ROUTER.0, "swapExactTokensForTokens", &encode_swap_args(
            amount, min_out, &[WZEC, token], &sender, deadline
        ));
        
        // Verify we received tokens
        let balance_after = xcc::call(&token.0, "balanceOf", &encode_addr(&self_addr));
        require!(balance_after > balance_before, "Swap failed");
        
        ret::u32(1)
    }
}

Delegate Calls

Execute another contract’s code in the current contract’s storage context:
use nexus_sdk::contract_api::xcc;

// Delegate call - runs target code with our storage
nexus_fn! {
    fn upgrade_implementation(new_impl: Address) {
        let sender = Blockchain::msg.sender();
        require!(sender == OWNER.get(&b"val".as_slice()), "Not owner");
        
        // Delegate to new implementation
        xcc::delegate_call(&new_impl.0, "initialize", &[]);
        
        IMPLEMENTATION.set(&b"val".as_slice(), new_impl);
        ret::u32(1)
    }
}

Contract Deployment from Contracts

Deploy child contracts with deterministic addresses:
// Factory pattern - deploy new contracts
nexus_fn! {
    fn createPair(tokenA: Address, tokenB: Address) {
        // Embedded pair bytecode
        const PAIR_CODE: &[u8] = include_bytes!("../../pair.wasm");
        
        // CREATE2-style deterministic deployment
        let mut salt = Vec::new();
        salt.extend_from_slice(&tokenA.0);
        salt.extend_from_slice(&tokenB.0);
        
        let pair_addr = xcc::deploy(PAIR_CODE, &[], &salt);
        
        // Initialize the new pair
        xcc::call(&pair_addr.0, "init_pair", &encode_init_args(&tokenA, &tokenB));
        
        PAIRS.set(&key, Address(pair_addr));
        emit("PairCreated", &[]);
        ret::address(&pair_addr)
    }
}

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                       NEXUS-Zcash                                │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                     Zcash L1                              │   │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐       │   │
│  │  │ Transparent │  │  Groth16    │  │    State    │       │   │
│  │  │   Vaults    │  │   Proofs    │  │   Commits   │       │   │
│  │  └─────────────┘  └─────────────┘  └─────────────┘       │   │
│  └──────────────────────────────────────────────────────────┘   │
│                              │                                   │
│                              ▼                                   │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    NEXUS Layer                            │   │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐       │   │
│  │  │   WASM VM   │  │  Cross-     │  │   Unified   │       │   │
│  │  │  Contracts  │  │  Contract   │  │  Liquidity  │       │   │
│  │  │             │  │   Calls     │  │             │       │   │
│  │  └─────────────┘  └─────────────┘  └─────────────┘       │   │
│  └──────────────────────────────────────────────────────────┘   │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘

Key Features

Transparent Vaults (t-address)

NEXUS-Zcash currently supports transparent addresses (t-addr) only:
Vault Address (t-addr)
├── Protocol Path: L1 balance = L2 balance (1:1 backing)
└── Escape Path: User recovery after timelock
Shielded transactions (z-addr) and privacy features are planned for V2.

Unified Liquidity (V2)

Cross-chain unified liquidity pools with BTC/ZEC/DOGE are planned for V2 via intent exchange:
┌─────────────────────────────────────────────────────────────────┐
│                    V2: Intent Exchange                           │
├─────────────────────────────────────────────────────────────────┤
│                                                                  │
│  BTC ◄─────────────────────────────────────────────────► ZEC    │
│           │                                      │               │
│           │         Intent Matching              │               │
│           │        BTC + ZEC + DOGE              │               │
│           │                                      │               │
│  DOGE ◄────────────────────────────────────────────────►        │
│                                                                  │
└─────────────────────────────────────────────────────────────────┘
V1 supports ZEC deposits, withdrawals, and smart contracts. Unified liquidity with BTC/DOGE via intent exchange is coming in V2.

Supported Features

FeatureStatusDescription
Transparent Depositst-addr vault deposits
Transparent WithdrawalsWithdraw to t-addr
State CommitsOn-chain commitments
WASM ContractsFull smart contract support
Cross-Contract Callsxcc and delegate calls
ZEC/BTC Swaps🔄 V2Via intent exchange
ZEC/DOGE Swaps🔄 V2Via intent exchange
Unified Liquidity🔄 V2Cross-chain pools
Shielded Deposits🔄 V2z-addr support coming
Shielded Withdrawals🔄 V2z-addr support coming
Privacy Features🔄 V2Full privacy in V2

Deposit Flow

// Get vault address (transparent t-addr)
const vault = await client.getVaultAddress('zcash');
console.log('Deposit ZEC to:', vault.vaultAddress);

// Send ZEC (using zcash-cli)
// zcash-cli sendtoaddress <VAULT_ADDRESS> 1.0

Withdrawal Flow

// Withdraw to transparent address
await client.requestWithdrawal(tAddress, amount, 'zcash');

State Commitments

NEXUS posts state commitments to Zcash blockchain:
Zcash Block 1000: State Root 0xabc... (OP_RETURN)
Zcash Block 1100: State Root 0xdef... (OP_RETURN)

Configuration

[zcash]
rpc_url = "http://localhost:8232"
rpc_user = "user"
rpc_password = "password"
network = "regtest"  # mainnet, testnet, regtest

[zcash.vault]
escape_timelock = 576  # ~1 day in blocks (2.5 min blocks)

[zcash.state_commit]
interval_blocks = 100

Cross-Chain Swaps (V2)

Cross-chain swaps between ZEC/BTC/DOGE will be available in V2 via intent exchange.

ZEC → BTC (V2)

// V2: Intent-based cross-chain swap
const intent = await client.createSwapIntent({
  fromChain: 'zcash',
  toChain: 'bitcoin',
  fromAmount: zecAmount,
  minToAmount: minBtcOut,
  recipient: btcAddress
});

// Intent matched and executed by solvers
await client.waitForIntentFulfillment(intent.id);

BTC → ZEC (V2)

// V2: Intent-based cross-chain swap
const intent = await client.createSwapIntent({
  fromChain: 'bitcoin',
  toChain: 'zcash',
  fromAmount: btcAmount,
  minToAmount: minZecOut,
  recipient: tAddress  // t-addr only in V2
});

Roadmap

V1 (Current)

  • ✅ Transparent address (t-addr) support
  • ✅ Full WASM smart contracts
  • ✅ Cross-contract calls & delegate calls
  • ✅ Groth16 proof verification
  • ✅ ZEC deposits and withdrawals

V2 (Planned)

  • 🔄 Unified liquidity with BTC/DOGE via intent exchange
  • 🔄 Shielded address (z-addr) deposits
  • 🔄 Shielded withdrawals
  • 🔄 Privacy-preserving operations
  • 🔄 Private DeFi transactions

Reorg Handling

NEXUS handles Zcash reorgs automatically:
  1. Monitor for chain reorganizations
  2. Revert affected deposits/withdrawals
  3. Re-process transactions on new chain
  4. Maintain consistency with L1

Comparison

FeatureNEXUS-ZcashNative ZcashWrapped ZEC
Smart Contracts✅ Full WASMDepends on chain
Privacy🔄 V2✅ Full
Cross-Chain
TrustlessUsually ❌
DeFiLimitedDepends