Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
- counter/native
- counter/pinocchio
- account-comparison
- zk-id
- zk/zk-id
- zk/zk-nullifier
- zk/zk-merkle-proof
- airdrop-implementations/simple-claim/program
include:
- example: basic-operations/native
Expand All @@ -51,10 +53,10 @@ jobs:
example: ${{ matrix.example }}
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
install-circom: ${{ matrix.example == 'zk-id' }}
install-circom: ${{ startsWith(matrix.example, 'zk/') || startsWith(matrix.example, 'zk/') }}

- name: Setup ZK circuits
if: matrix.example == 'zk-id'
if: startsWith(matrix.example, 'zk/') || startsWith(matrix.example, 'zk/')
working-directory: ${{ matrix.example }}
run: ./scripts/setup.sh

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ test-ledger
.claude
build
pot

# ZK examples - TypeScript tests not ready
zk/**/*.ts
zk/**/tsconfig.json
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@
For simple client side distribution visit [this example](https://github.com/Lightprotocol/example-token-distribution).

### Basic Operations
- **[create-nullifier](./basic-operations/anchor/create-nullifier)** - Basic Anchor example to create nullifiers.
- **[basic-operations/anchor](./basic-operations/anchor/)** - Anchor program with Rust and TypeScript tests
- **[basic-operations/native-rust](./basic-operations/native-rust/)** - Native Solana program with light-sdk and Rust tests.

Basic Operations include:
- **create** - Initialize a new compressed account.
- **update** - Modify data in an existing compressed account.
- **close** - Clear account data and preserve its address.
- **reinit** - Reinitialize a closed account with the same address.
- **burn** - Permanently delete a compressed account.
- **[create-nullifier](./basic-operations/anchor/create-nullifier)** - Basic Anchor example to create nullifiers for payments.
- **create** - Initialize a new compressed account
- [Anchor](./basic-operations/anchor/create) | [Native](./basic-operations/native/programs/create)
- **update** - Modify data in an existing compressed account
- [Anchor](./basic-operations/anchor/update) | [Native](./basic-operations/native/programs/update)
- **close** - Clear account data and preserve its address
- [Anchor](./basic-operations/anchor/close) | [Native](./basic-operations/native/programs/close)
- **reinit** - Reinitialize a closed account with the same address
- [Anchor](./basic-operations/anchor/reinit) | [Native](./basic-operations/native/programs/reinit)
- **burn** - Permanently delete a compressed account
- [Anchor](./basic-operations/anchor/burn) | [Native](./basic-operations/native/programs/burn)

### Counter Program

Expand All @@ -45,9 +47,16 @@ Full compressed account lifecycle (create, increment, decrement, reset, close):

- **[account-comparison](./account-comparison/)** - Compare compressed vs regular Solana accounts.

### zk-id Program
### ZK Programs

- **[zk-id](./zk-id)** - A minimal zk id Solana program that uses zero-knowledge proofs for identity verification with compressed accounts.
**Full Examples:**

- **[zk-id](./zk/zk-id)** - Identity verification using Groth16 proofs. Issuers create credentials; users prove ownership without revealing the credential.

**Basic Examples:**

- **[zk-nullifier](./zk/zk-nullifier)** - Creates one or four nullifiers. Uses Groth16 proofs and compressed accounts.
- **[zk-merkle-proof](./zk/zk-merkle-proof)** - Creates compressed accounts and verifies with Groth16 proofs (without nullifier).


## Light Protocol dependencies
Expand Down
20 changes: 20 additions & 0 deletions zk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# ZK Examples

Building a private Solana program requires a Merkle tree to store state, a way to track nullifiers, and an indexer to serve Merkle proofs.

You can use Light to:
- Track and store nullifiers rent-free in indexed address Merkle trees
- Store state rent-free in indexed state Merkle trees as compressed accounts

[Learn more in the documentation](https://www.zkcompression.com/zk/overview)

## Examples

**Full Examples:**

- **[zk-id](./zk/zk-id)** - Identity verification using Groth16 proofs. Issuers create credentials; users prove ownership without revealing the credential.

**Basic Examples:**

- **[zk-nullifier](./zk/zk-nullifier)** - Creates one or four nullifiers. Uses Groth16 proofs and compressed accounts.
- **[zk-merkle-proof](./zk/zk-merkle-proof)** - Creates compressed accounts and verifies with Groth16 proofs (without nullifier).
File renamed without changes.
23 changes: 23 additions & 0 deletions zk/zk-id/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[toolchain]
anchor_version = "0.31.1"

[features]
resolution = true
skip-lint = false

[workspace]
members = ["."]

[programs.localnet]
zk_id = "HNqStLMpNuNJqhBF1FbGTKHEFbBLJmq8RdJJmZKWz6jH"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"

File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions zk-id/Cargo.toml → zk/zk-id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ groth16-solana = { git = "https://github.com/Lightprotocol/groth16-solana", feat
[target.'cfg(not(target_os = "solana"))'.build-dependencies]
rust-witness = "0.1"
groth16-solana = { git = "https://github.com/Lightprotocol/groth16-solana", features = ["vk"], rev = "66c0dc87d0808c4d2aadb53c61435b6edb8ddfd9" }

[profile.release]
overflow-checks = true
8 changes: 5 additions & 3 deletions zk-id/README.md → zk/zk-id/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ This script will:

## Build and Test

**Build:**
```bash
# Build the program
cargo build-sbf
```

# Run tests and see tx
**Rust tests** (full ZK verification flow):
```bash
RUST_BACKTRACE=1 cargo test-sbf -- --nocapture
```

Expand All @@ -89,7 +91,7 @@ zk-id/
├── src/
│ └── lib.rs # Solana program implementation
└── tests/
└── test.rs # Integration tests
└── test.rs # Rust integration tests
```

## Cleaning Build Artifacts
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ template MerkleProof(levels) {

component switcher[levels];
component hasher[levels];

component indexBits = Num2Bits(levels);
indexBits.in <== leafIndex;

Expand Down
Loading
Loading