-
Notifications
You must be signed in to change notification settings - Fork 3
Add zk-nullifier example and reorganize zk/ folder #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
a35d669
1db7b62
41cdcff
6a46ccb
8e1920f
3b2d774
c4fea07
ca53572
88ab45c
f53b365
ef84fe2
7295adc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,8 @@ test-ledger | |
| .claude | ||
| build | ||
| pot | ||
|
|
||
| # ZK examples - not ready | ||
| zk/mixer/ | ||
| zk/shielded-pool/ | ||
| zk/zk-merkle-proof/ | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||||||
|
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Enhance the close operation description to mention rent reclamation. The description should highlight that close operations reclaim rent, which is a key benefit of this operation compared to burn. Based on learnings, close operations preserve the account address for potential reinitialization while reclaiming rent. 📝 Suggested enhancement-- **close** - Clear account data and preserve its address
+- **close** - Reclaim rent and preserve the account address for reinitialization📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| - **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) | ||||||||||
|
Comment on lines
+25
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Clarify that burn prevents address reuse. The description should explicitly state that burned accounts cannot have their addresses reused, which is the critical distinction from close operations. Based on learnings, burn operations permanently delete accounts so addresses cannot be reused, unlike close operations which preserve addresses for reinitialization. 📝 Suggested enhancement-- **burn** - Permanently delete a compressed account
+- **burn** - Permanently delete a compressed account (address cannot be reused)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| ### Counter Program | ||||||||||
|
|
||||||||||
|
|
@@ -45,9 +47,12 @@ 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/zk-id)** - Identity verification using Groth16 proofs. Issuers create credentials; users prove ownership without revealing the credential. | ||||||||||
| - **[nullifier](./zk/nullifier)** - Simple Program to Create Nullifiers. Requires no custom circuit. | ||||||||||
|
|
||||||||||
| - **[zk-id](./zk-id)** - A minimal zk id Solana program that uses zero-knowledge proofs for identity verification with compressed accounts. | ||||||||||
|
|
||||||||||
|
|
||||||||||
| ## Light Protocol dependencies | ||||||||||
|
|
||||||||||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| # Makefile for building and testing all ZK examples | ||
| # Usage: | ||
| # make all - Build and test all examples | ||
| # make build - Build all Solana programs | ||
| # make test-rust - Run all Rust tests | ||
| # make test-ts - Run all TypeScript tests | ||
| # make clean - Clean all build artifacts | ||
|
|
||
| SHELL := /bin/bash | ||
|
|
||
| # ZK example directories | ||
| ZK_EXAMPLES := nullifier zk-id | ||
|
|
||
| .PHONY: all build deploy test-rust test-ts clean setup help $(ZK_EXAMPLES) | ||
|
|
||
| help: | ||
| @echo "ZK Examples Makefile" | ||
| @echo "" | ||
| @echo "Usage:" | ||
| @echo " make all - Build and test all examples (Rust + TypeScript)" | ||
| @echo " make build - Build all Solana programs" | ||
| @echo " make deploy - Deploy all programs to validator (builds first)" | ||
| @echo " make test-rust - Run all Rust tests (cargo test-sbf)" | ||
| @echo " make test-ts - Run all TypeScript tests (deploys first)" | ||
| @echo " make setup - Setup circuits for all examples" | ||
| @echo " make clean - Clean all build artifacts" | ||
| @echo "" | ||
| @echo "Individual examples:" | ||
| @echo " make nullifier - Build and test nullifier" | ||
| @echo " make zk-id - Build and test zk-id" | ||
|
|
||
| all: build test-rust test-ts | ||
| @echo "All examples built and tested successfully!" | ||
|
|
||
| build: | ||
| @echo "Building all ZK examples..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Building $$dir..."; \ | ||
| cd $$dir && cargo build-sbf && cd ..; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| echo "Failed to build $$dir"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "$$dir built successfully"; \ | ||
| done | ||
| @echo "All programs built successfully!" | ||
|
|
||
| deploy: build | ||
| @echo "Deploying all ZK programs..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Deploying $$dir..."; \ | ||
| if [ -f "$$dir/target/deploy/"*.so ]; then \ | ||
| solana program deploy $$dir/target/deploy/*.so; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| echo "Failed to deploy $$dir"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "$$dir deployed successfully"; \ | ||
| else \ | ||
| echo "No .so file found for $$dir, skipping deploy"; \ | ||
| fi; \ | ||
| done | ||
| @echo "All programs deployed!" | ||
|
|
||
| test-rust: | ||
| @echo "Running Rust tests for all ZK examples..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Testing $$dir (Rust)..."; \ | ||
| cd $$dir && cargo test-sbf && cd ..; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| echo "Rust tests failed for $$dir"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "$$dir Rust tests passed"; \ | ||
| done | ||
| @echo "All Rust tests passed!" | ||
|
|
||
| test-ts: deploy | ||
| @echo "Running TypeScript tests for all ZK examples..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Testing $$dir (TypeScript)..."; \ | ||
| if [ -f "$$dir/package.json" ]; then \ | ||
| cd $$dir && npm run test:ts && cd ..; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| echo "TypeScript tests failed for $$dir"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "$$dir TypeScript tests passed"; \ | ||
| else \ | ||
| echo "No package.json found in $$dir, skipping TS tests"; \ | ||
| fi; \ | ||
| done | ||
| @echo "All TypeScript tests passed!" | ||
|
|
||
| setup: | ||
| @echo "Setting up circuits for all ZK examples..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Setting up $$dir..."; \ | ||
| if [ -f "$$dir/scripts/setup.sh" ]; then \ | ||
| cd $$dir && ./scripts/setup.sh && cd ..; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| echo "Setup failed for $$dir"; \ | ||
| exit 1; \ | ||
| fi; \ | ||
| echo "$$dir setup completed"; \ | ||
| else \ | ||
| echo "No setup script found in $$dir"; \ | ||
| fi; \ | ||
| done | ||
| @echo "All setups completed!" | ||
|
|
||
| clean: | ||
| @echo "Cleaning all ZK examples..." | ||
| @for dir in $(ZK_EXAMPLES); do \ | ||
| echo "Cleaning $$dir..."; \ | ||
| cd $$dir && cargo clean && cd ..; \ | ||
| if [ -d "$$dir/build" ]; then \ | ||
| rm -rf $$dir/build; \ | ||
| fi; \ | ||
| if [ -d "$$dir/node_modules" ]; then \ | ||
| rm -rf $$dir/node_modules; \ | ||
| fi; \ | ||
| done | ||
| @echo "All examples cleaned!" | ||
|
|
||
| # Individual example targets | ||
| nullifier: | ||
| @echo "Building, deploying, and testing nullifier..." | ||
| @cd nullifier && cargo build-sbf && cargo test-sbf | ||
| @solana program deploy nullifier/target/deploy/nullifier.so | ||
| @if [ -f "nullifier/package.json" ]; then \ | ||
| cd nullifier && npm run test:ts; \ | ||
| fi | ||
| @echo "nullifier completed!" | ||
|
|
||
| zk-id: | ||
| @echo "Building, deploying, and testing zk-id..." | ||
| @cd zk-id && cargo build-sbf && cargo test-sbf | ||
| @solana program deploy zk-id/target/deploy/zk_id.so | ||
| @if [ -f "zk-id/package.json" ]; then \ | ||
| cd zk-id && npm run test:ts; \ | ||
| fi | ||
| @echo "zk-id completed!" | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.