Privacy Cash Rust SDK
Pure Rust SDK for Privacy Cash - Privacy-preserving transactions on Solana using Zero-Knowledge Proofs.
Created by Nova Shield
Features
- Private Transactions - Send SOL and SPL tokens with complete privacy using ZK proofs
- Pure Rust ZK Proofs - Native Groth16 proof generation, no external dependencies
- Multi-Token Support - SOL, USDC, USDT, and more
- One Function API -
send_privately()handles deposit + withdraw in one call - Partner Fee Integration - Earn fees by integrating this SDK into your platform
- Configurable - Customize RPC, fees, and referrer via environment variables
Installation
Add to your Cargo.toml:
[]
= { = "https://github.com/NovaShieldWallet/privacy-cash-rust-sdk" }
= { = "1", = ["full"] }
Circuit Files (Required)
The SDK requires circuit files for ZK proof generation.
This repo vendors the required artifacts at:
circuit/transaction2.wasmcircuit/transaction2.zkey
See circuit/README.md for provenance and licensing details.
Quick Start - ONE Function!
use send_privately;
async
The send_privately() function automatically:
- Deposits your tokens into Privacy Cash
- Waits for blockchain confirmation
- Withdraws the maximum amount to the recipient
API
SendPrivatelyResult
Supported Tokens
| Token | Minimum | Fee |
|---|---|---|
| SOL | 0.02 SOL | ~0.006 SOL |
| USDC | 2 USDC | ~0.85 USDC |
| USDT | 2 USDT | ~0.85 USDT |
Partner/Platform Fee Integration
Platforms integrating this SDK can earn fees on transactions. Configure via environment variables:
| Variable | Description | Default |
|---|---|---|
PARTNER_FEE_WALLET |
Your wallet address to receive fees | Nova Shield wallet |
PARTNER_FEE_RATE |
Fee rate (e.g., "0.01" for 1%, "0" to disable) | 0.01 (1%) |
PARTNER_REFERRER |
Referrer wallet for Privacy Cash referral program | Nova Shield wallet |
Example setup:
# 0.5% fee
Configuration
All configuration can be set via environment variables:
| Variable | Description | Default |
|---|---|---|
SOLANA_PRIVATE_KEY |
Base58-encoded Solana keypair | Required |
SOLANA_RPC_URL |
Solana RPC endpoint | Mainnet |
PARTNER_FEE_WALLET |
Partner fee recipient wallet | Default wallet |
PARTNER_FEE_RATE |
Partner fee rate (0-1) | 0.01 |
PARTNER_REFERRER |
Referrer for Privacy Cash | Default wallet |
Examples
Tip: Copy .env.local.example to .env.local (gitignored) and set your variables.
# Check balances
SOLANA_PRIVATE_KEY="your-key"
# Send 0.02 SOL privately
SOLANA_PRIVATE_KEY="your-key"
# Send 10 USDC privately to a recipient
SOLANA_PRIVATE_KEY="your-key"
# Same send test via helper script (prompts for SOLANA_PRIVATE_KEY if not set)
Security
- Never hardcode private keys in your code
- Use environment variables or secure key management
- Private keys are used locally and never sent to any server
- All ZK proofs are generated client-side
License
SDK code is MIT-licensed (see LICENSE). Circuit artifacts in circuit/ have their own upstream license—see circuit/README.md.