Crate privacy_cash

Crate privacy_cash 

Source
Expand description

§Privacy Cash Rust SDK

A Rust SDK for interacting with Privacy Cash on Solana. Provides privacy-preserving deposit and withdrawal functionality using zero-knowledge proofs.

§Features

  • SOL Operations: Deposit and withdraw native SOL privately
  • SPL Token Operations: Deposit and withdraw SPL tokens (USDC, USDT, etc.)
  • Balance Queries: Check private balances without revealing identity
  • UTXO Management: Automatic UTXO consolidation and caching

§Example

use privacy_cash::PrivacyCash;
use solana_sdk::signature::Keypair;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create client
    let keypair = Keypair::new();
    let client = PrivacyCash::new(
        "https://api.mainnet-beta.solana.com",
        keypair,
    )?;

    // Check private balance
    let balance = client.get_private_balance().await?;
    println!("Private balance: {} lamports", balance.lamports);

    // Deposit SOL
    let result = client.deposit(10_000_000).await?; // 0.01 SOL
    println!("Deposit tx: {}", result.signature);

    Ok(())
}

Re-exports§

pub use client::PrivacyCash;
pub use config::Config;
pub use config::SupportedToken;
pub use error::PrivacyCashError;
pub use error::Result;
pub use keypair::ZkKeypair;
pub use utxo::Utxo;
pub use constants::*;

Modules§

bridge
TypeScript Bridge for ZK proof generation
client
Main Privacy Cash client
config
Configuration fetching from the relayer API
constants
Constants used throughout the Privacy Cash SDK
deposit
Deposit functionality for native SOL
deposit_spl
Deposit functionality for SPL tokens
encryption
Encryption service for UTXO data
error
Error types for Privacy Cash SDK
get_utxos
UTXO fetching and management for native SOL
get_utxos_spl
UTXO fetching and management for SPL tokens
keypair
ZK Keypair for Privacy Cash
merkle_tree
Merkle tree implementation using Poseidon hashing
prover
ZK Proof generation for Privacy Cash
storage
Local storage for caching UTXOs and offsets
utils
Utility functions for Privacy Cash SDK
utxo
UTXO (Unspent Transaction Output) model for Privacy Cash
withdraw
Withdrawal functionality for native SOL
withdraw_spl
Withdrawal functionality for SPL tokens

Structs§

Keypair
A vanilla Ed25519 key pair
Pubkey
The address of a Solana account.

Traits§

Signer
The Signer trait declares operations that all digital signature providers must support. It is the primary interface by which signers are specified in Transaction signing interfaces