Full lesson
hush
Solana ZK privacy protocol
What it does
From the project README:
Hush is a privacy protocol on Solana, enabling private transactions powered by zero-knowledge proofs.
- Original
- bidhan-a/hush
- SuperStack fork
- Blockchains/hush @
e800a43 - Stars
- 1
- Last push (original)
- 2025-06-16
- Languages
- TypeScript, Rust, JavaScript, Circom, Shell, CSS
- Detected stack
- AnchorNext.jsweb3.js
- Categories
- Other
- Licence
- MIT
- Homepage
- https://hush-nu.vercel.app
Architecture
43 source files. By extension: .rs ×17, .ts ×13, .tsx ×10, .js ×3.
| Top-level directory | Source files |
|---|---|
ui | 20 |
programs | 17 |
circuits | 2 |
scripts | 2 |
migrations | 1 |
tests | 1 |
On-chain programs: programs/hush
Dapp: devnet deploy pending
⏳ Devnet deploy pending — goes live when the devnet wallet is topped up. This fork's own dapp is not deployed yet, so there is no program address or transaction to show. It is queued in dapp-queue.txt; once devnet SOL is available it is deployed, exercised with real devnet transactions, and this section switches to the live dapp at /dapps/hush/. Until then, the lesson and step-by-step guide below are complete, and you can run it locally with the commands below.
Key code, explained
Excerpts chosen automatically where the code uses the most Solana concepts, pinned to the fork's commit.
programs/hush/src/instructions/create_pool.rs L1–24 @ e800a43 · MIT · originaluse anchor_lang::prelude::*; use crate::errors::Error;use crate::state::{ConfigState, PoolState}; #[derive(Accounts)]#[instruction(amount: u64)]pub struct CreatePool<'info> { #[account(mut)] pub admin: Signer<'info>, #[account( seeds=[b"config"], bump=config.bump, constraint=config.admin.key() == admin.key() @ Error::PermissionDenied )] pub config: Box<Account<'info, ConfigState>>, #[account( init, payer=admin, seeds=[b"pool", amount.to_le_bytes().as_ref()], bump, space=PoolState::INIT_SPACE + 8- Line 10
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 13
seeds=[b"config"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 14
bump=config.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 20
init,: Creates and pays for a new account. Space and payer must be specified.
programs/hush/src/instructions/initialize.rs L1–23 @ e800a43 · MIT · originaluse anchor_lang::prelude::*; use crate::state::ConfigState; #[derive(Accounts)]pub struct Initialize<'info> { #[account(mut)] pub admin: Signer<'info>, #[account( init, payer=admin, seeds=[b"config"], bump, space=ConfigState::INIT_SPACE + 8 )] pub config: Box<Account<'info, ConfigState>>, #[account( seeds=[b"treasury"], bump )] pub treasury: SystemAccount<'info>,- Line 8
pub admin: Signer<'info>,: Requires this account to have signed the transaction. - Line 11
init,: Creates and pays for a new account. Space and payer must be specified. - Line 13
seeds=[b"config"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 14
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
programs/hush/src/instructions/deposit.rs L49–71 @ e800a43 · MIT · original init, payer=depositor, seeds=[b"deposit", pool.key().as_ref(), commitment.as_ref()], bump, space=DepositState::INIT_SPACE + 8 )] pub deposit: Box<Account<'info, DepositState>>, pub system_program: Program<'info, System>,} impl<'info> Deposit<'info> { pub fn deposit( &mut self, amount: u64, commitment: [u8; 32], bumps: &DepositBumps, ) -> Result<()> { // Ensure the merkle tree is not full. require!( self.pool.next_index < (1 << TREE_HEIGHT), Error::MerkleTreeFull );- Line 49
init,: Creates and pays for a new account. Space and payer must be specified. - Line 51
seeds=[b"deposit", pool.key().as_ref(), commitment.as_ref()],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 52
bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve. - Line 68
require!(: An explicit validation that aborts the instruction with an error.
programs/hush/src/instructions/withdraw.rs L1–24 @ e800a43 · MIT · originaluse anchor_lang::prelude::*; use crate::errors::Error;use crate::helpers::transfer_sol;use crate::state::{ConfigState, PoolState, WithdrawState};use crate::zk::verifier::verify_proof; #[derive(Accounts)]#[instruction(amount: u64, nullifier_hash: [u8; 32])]pub struct Withdraw<'info> { #[account(mut)] pub withdrawer: Signer<'info>, #[account( seeds=[b"config"], bump=config.bump, )] pub config: Box<Account<'info, ConfigState>>, #[account( mut, seeds=[b"pool", amount.to_le_bytes().as_ref()], bump=pool.pool_bump, )]- Line 12
pub withdrawer: Signer<'info>,: Requires this account to have signed the transaction. - Line 15
seeds=[b"config"],: Declares the PDA seeds. Anchor re-derives the address and rejects the account if it doesn't match. - Line 16
bump=config.bump,: Uses the bump seed, the extra byte that pushes the derived address off the ed25519 curve.
How to run, build and test
These commands come from the repo's own manifests (package.json scripts, Anchor.toml, Cargo, go.mod, Makefile). Check the README for prerequisites and environment variables.
| Directory | Command | Runs |
|---|---|---|
ui | npm run dev | next dev --turbopack |
ui | npm run start | next start |
ui | npm run build | next build |
ui | npm run lint | next lint |
. | anchor build | compile programs and generate IDLs |
. | anchor test | local validator + test suite |
. | anchor run test | yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts |
. | cargo build | Rust workspace build |
. | cargo test | Rust tests |
What you could build from it
- Fork the SuperStack copy and extend it within the Other gaps listed on the idea page.
- Learn the pattern first: Program Derived Addresses (PDAs)
- Learn the pattern first: Cross-Program Invocations (CPIs)