Skip to content

Zcash Integration

SIP Protocol integrates Zcash technology for privacy-preserving cross-chain transactions. This guide covers setup, usage, and best practices.

SIP leverages Zcash in three key ways:

FeatureDescriptionStatus
Zcash RPC ClientFull shielded transaction supportImplemented
Viewing KeysSelective disclosure inspired by ZcashImplemented
Proof CompositionHalo2 proofs + Mina verificationPlanned
Terminal window
npm install @sip-protocol/sdk
import { ZcashRPCClient, createZcashClient } from '@sip-protocol/sdk'
// Create client
const zcash = createZcashClient({
rpcUrl: 'http://localhost:8232',
rpcUser: 'your-rpc-user',
rpcPassword: 'your-rpc-password'
})
// Check connection
const info = await zcash.getBlockchainInfo()
console.log('Zcash network:', info.chain)

The ZcashRPCClient provides full access to Zcash’s shielded infrastructure.

interface ZcashRPCConfig {
rpcUrl: string // Zcash node RPC endpoint
rpcUser: string // RPC authentication user
rpcPassword: string // RPC authentication password
timeout?: number // Request timeout (ms, default: 30000)
}

Zcash uses HD (Hierarchical Deterministic) accounts for address generation:

// Create a new HD account
const { account } = await zcash.createAccount()
console.log('Account index:', account)
// Generate unified address for the account
const { address } = await zcash.getAddressForAccount(
account,
['sapling', 'orchard'] // Receiver types
)
console.log('Unified address:', address)
// Get shielded balance
const balance = await zcash.getShieldedBalance(zAddress)
console.log('Shielded balance:', balance, 'ZEC')
// Send shielded transaction
const txid = await zcash.sendShielded({
from: senderZAddress,
to: recipientZAddress,
amount: 1.5, // Amount in ZEC
memo: 'Private payment' // Optional encrypted memo
})
console.log('Transaction ID:', txid)
// List shielded transactions
const transactions = await zcash.listShieldedTransactions(zAddress)

Zcash Unified Addresses combine multiple receiver types in a single address:

// Generate address with all receiver types
const { address } = await zcash.getAddressForAccount(
account,
['orchard', 'sapling', 'p2pkh'] // Shielded + transparent
)
// Address format: u1...
// Contains:
// - Orchard receiver (latest shielded pool)
// - Sapling receiver (widely supported)
// - Transparent receiver (for compatibility)

SIP’s viewing key system is inspired by Zcash’s design, enabling selective disclosure for compliance.

TypeSee IncomingSee OutgoingSpend
Full Viewing KeyYesYesNo
Incoming Viewing KeyYesNoNo
Outgoing Viewing KeyNoYesNo
import { generateViewingKey, deriveViewingKeyHash } from '@sip-protocol/sdk'
// Generate viewing key pair
const { viewingKey, viewingKeyHash } = generateViewingKey(spendingKey)
// Viewing key can be shared with auditors
// viewingKeyHash is stored on-chain for verification
console.log('Share with auditor:', viewingKey)
console.log('On-chain hash:', viewingKeyHash)
import { SIP, PrivacyLevel } from '@sip-protocol/sdk'
const sip = new SIP({ network: 'mainnet' })
// Create compliant transaction (generates viewing key)
const intent = await sip
.intent()
.input('ethereum', 'ETH', amount)
.output('solana', 'SOL')
.privacy(PrivacyLevel.COMPLIANT) // Includes viewing key
.build()
// Extract viewing key for auditor
const viewingKey = intent.viewingKey
console.log('Auditor viewing key:', viewingKey)
// Auditor can verify transaction details
const details = await sip.decryptWithViewingKey(
intent.encryptedData,
viewingKey
)

SIP privacy levels map to Zcash concepts:

SIP LevelZcash EquivalentDescription
TRANSPARENTt-addressPublic, on-chain visible
SHIELDEDz-addressFull privacy, hidden amounts
COMPLIANTz-address + viewing keyPrivacy with audit capability
import { PrivacyLevel } from '@sip-protocol/sdk'
// Transparent (public) - like Zcash t-address
await sip.intent()
.privacy(PrivacyLevel.TRANSPARENT)
.build()
// Shielded (private) - like Zcash z-address
await sip.intent()
.privacy(PrivacyLevel.SHIELDED)
.build()
// Compliant (private + auditable) - z-address with viewing key
await sip.intent()
.privacy(PrivacyLevel.COMPLIANT)
.build()

Route swaps through Zcash’s shielded pool for maximum privacy:

import { SIP, PrivacyLevel } from '@sip-protocol/sdk'
const sip = new SIP({
network: 'mainnet',
zcashConfig: {
rpcUrl: 'http://localhost:8232',
rpcUser: 'user',
rpcPassword: 'pass'
}
})
// Swap ETH → ZEC (shielded)
const intent = await sip
.intent()
.input('ethereum', 'ETH', ethAmount)
.output('zcash', 'ZEC')
.recipientAddress(zAddress) // Shielded z-address
.privacy(PrivacyLevel.SHIELDED)
.build()

SIP’s roadmap includes composing proofs from multiple systems:

┌─────────────────────────────────────────────────────────────┐
│ PROOF COMPOSITION (Phase 3) │
├─────────────────────────────────────────────────────────────┤
│ Zcash (Halo2) → Privacy execution │
│ Mina (Kimchi) → Succinct verification │
│ Noir → Validity proofs │
│ │
│ Combined: Maximum privacy + minimal verification cost │
└─────────────────────────────────────────────────────────────┘
FeatureBenefit
No trusted setupEliminates ceremony risk
Recursive proofsProof aggregation
IPA commitmentsSmaller proof sizes
import { ZcashRPCError, hasErrorCode, ErrorCode } from '@sip-protocol/sdk'
try {
const txid = await zcash.sendShielded(params)
} catch (error) {
if (error instanceof ZcashRPCError) {
console.error('Zcash RPC error:', error.code, error.message)
// Common error codes
if (error.code === -6) {
console.error('Insufficient funds')
} else if (error.code === -28) {
console.error('Node is still syncing')
}
}
}
OperationTimeNotes
Create account<100msHD derivation
Generate address<100msAddress encoding
Send shielded2-40sProof generation
Verify proof~10msFast verification

Try the live demo at sip-protocol.org/demo to see Zcash integration in action.