Skip to main content

Overview

This guide covers installing all dependencies needed to build and run Privacy Cash from source. If you’re integrating Privacy Cash into an existing project, see the Privacy Cash SDK instead.

System requirements

Operating system

Linux, macOS, or Windows with WSL2

RAM

8GB minimum, 16GB recommended

Disk space

At least 10GB free space

Internet

Required for downloading dependencies

Install Solana CLI

1

Download and install Solana CLI

Install version 2.1.18 or later:
sh -c "$(curl -sSfL https://release.solana.com/v2.1.18/install)"
2

Add Solana to your PATH

Add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
Then reload your shell:
source ~/.bashrc  # or source ~/.zshrc
3

Verify installation

solana --version
You should see output like:
solana-cli 2.1.18 (src:00000000; feat:1234567890)
Privacy Cash requires Solana CLI 2.1.18 or later for compatibility with the latest program features.

Install Rust

1

Install Rust using rustup

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Follow the prompts to complete installation.
2

Install Rust 1.79.0

Privacy Cash requires Rust 1.79.0 or a compatible version:
rustup install 1.79.0
rustup default 1.79.0
3

Verify Rust installation

rustc --version
cargo --version
You should see:
rustc 1.79.0 (129f3b996 2024-06-10)
cargo 1.79.0 (ffa9cf99a 2024-06-03)

Install Anchor

1

Install Anchor version manager (avm)

cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
2

Install Anchor 0.31.1

avm install 0.31.1
avm use 0.31.1
3

Verify Anchor installation

anchor --version
You should see:
anchor-cli 0.31.1
Privacy Cash is built with Anchor 0.31.1. Using a different version may cause compilation errors.

Install Node.js and npm

1

Install Node.js 16 or later

Using nvm (recommended):
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc  # or source ~/.zshrc
nvm install 18
nvm use 18
Or download directly from nodejs.org.
2

Verify Node.js and npm

node --version
npm --version
You should see:
v18.x.x
9.x.x

Install Circom

Circom is required to work with zero-knowledge circuits.
1

Install dependencies

sudo apt-get install build-essential libgmp-dev libsodium-dev nasm git
2

Download and install Circom v2.2.2

git clone https://github.com/iden3/circom.git
cd circom
git checkout v2.2.2
cargo build --release
cargo install --path circom
3

Verify Circom installation

circom --version
You should see:
circom compiler 2.2.2
Circom is used to compile the zero-knowledge circuits in the circuits/ directory. The compiled artifacts are already included in artifacts/circuits/, so you only need Circom if you’re modifying circuits.

Install project dependencies

Once all system tools are installed, set up the Privacy Cash project:
1

Clone the repository

git clone https://github.com/Privacy-Cash/privacy-cash.git
cd privacy-cash/anchor
2

Install npm dependencies

The project uses yarn as the package manager (configured in Anchor.toml):
yarn install
Or if using npm:
npm install
This installs all required packages including:
  • @coral-xyz/anchor - Anchor framework client
  • @solana/spl-token - SPL token utilities
  • snarkjs - Zero-knowledge proof library
  • @lightprotocol/hasher.rs - Poseidon hash implementation
  • circomlib - Circuit library
3

Build the program

anchor build
This compiles the Rust program and generates TypeScript types.

Verify installation

Run the test suite to ensure everything is working:
npm run test:sol
You should see output indicating tests are passing:
zkcash
  ✓ Double spend attack fails (15234ms)
  ✓ Can execute both deposit and withdraw instruction for correct input, with positive fee (18567ms)
  ✓ Can execute both deposit and withdraw instruction to PDA recipient, with positive fee (17891ms)

3 passing (52s)
The first test run may take longer as it compiles the circuits and generates proving keys.

Package versions

For reference, here are the exact package versions used by Privacy Cash:
{
  "dependencies": {
    "@coral-xyz/anchor": "^0.31.0",
    "@solana/spl-token": "^0.4.14",
    "circomlib": "^2.0.5",
    "ffjavascript": "^0.3.1"
  },
  "devDependencies": {
    "@ethersproject/sha2": "^5.8.0",
    "@lightprotocol/hasher.rs": "^0.2.1",
    "@types/bn.js": "^5.1.0",
    "@types/chai": "^4.3.0",
    "@types/mocha": "^9.0.0",
    "bn.js": "^5.2.2",
    "borsh": "^2.0.0",
    "chai": "^4.3.4",
    "ethers": "^6.13.7",
    "mocha": "^9.0.3",
    "prettier": "^2.6.2",
    "snarkjs": "^0.7.5",
    "tmp-promise": "^3.0.2",
    "ts-mocha": "^10.0.0",
    "typescript": "^5.7.3"
  }
}

Troubleshooting

Ensure you’re using Rust 1.79.0:
rustup default 1.79.0
Clean and rebuild:
anchor clean
anchor build
This package requires Rust to build native modules. Ensure you have:
  1. Rust installed and in your PATH
  2. Build tools installed (gcc, make, etc.)
On Ubuntu/Debian:
sudo apt-get install build-essential
On macOS:
xcode-select --install
Tests generate zero-knowledge proofs which are CPU-intensive:
  1. Ensure you have at least 8GB RAM available
  2. Close other applications to free up CPU
  3. Increase the Mocha timeout in package.json if needed
The test script already sets a high timeout:
"test": "yarn run ts-mocha -p ./tsconfig.json -t 1000000"
Ensure Solana is in your PATH:
which solana
If not found, add to your shell profile:
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"

Next steps

Quick start guide

Build and test Privacy Cash

Introduction

Learn how Privacy Cash works

Privacy Cash SDK

Integrate into your project

GitHub Issues

Get help or report problems

Build docs developers (and LLMs) love