generated from mintlify/starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Add ZK documentation #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,5 @@ mintlify-docs/ | |
|
|
||
| # Dependencies | ||
| node_modules/ | ||
|
|
||
| stash | ||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| --- | ||
| argument-hint: <path_to_program> | ||
| description: Migrate Light Protocol program from v1 to v2 Merkle trees | ||
| allowed-tools: [Bash, Read, Glob, Grep, Task, WebFetch] | ||
| --- | ||
|
|
||
| Migrate this Light Protocol program from v1 to v2 Merkle trees. | ||
|
|
||
| ## Goal | ||
|
|
||
| Produce a **fully working migration** that builds and tests pass. | ||
|
|
||
| ## Available commands | ||
|
|
||
| Via Bash tool: | ||
| - `cargo build-sbf`, `cargo test-sbf`, `cargo fmt`, `cargo clippy` | ||
| - `anchor build`, `anchor test` | ||
| - `grep`, `sed` | ||
|
|
||
| ## Documentation | ||
|
|
||
| - Migration Guide: https://zkcompression.com/references/migration-v1-to-v2 | ||
| - Reference PR: https://github.com/Lightprotocol/program-examples/commit/54f0e7f15c2972a078f776cfb40b238d83c7e486 | ||
|
|
||
| ## Reference repos | ||
|
|
||
| program-examples/counter/anchor/ | ||
| ├── programs/counter/src/lib.rs # v2 patterns: derive_address, CpiAccounts | ||
| ├── Cargo.toml # v2 feature flags | ||
| └── tests/counter.ts # v2 client patterns | ||
|
|
||
| ## Workflow | ||
|
|
||
| ### Phase 1: Index program | ||
|
|
||
| Find all v1 patterns: | ||
|
|
||
| grep -r "::v1::" src/ tests/ | ||
| grep -r "ADDRESS_TREE_V1" src/ | ||
| grep -r "into_new_address_params_packed" src/ | ||
| grep -r "get_address_tree_v1" tests/ | ||
|
|
||
| ### Phase 2: Update dependencies | ||
|
|
||
| Add v2 feature to Cargo.toml: | ||
|
|
||
| [dependencies] | ||
| light-sdk = { version = "0.17", features = ["anchor", "v2"] } | ||
| light-sdk-types = { version = "0.17", features = ["v2"] } | ||
|
|
||
| [dev-dependencies] | ||
| light-program-test = { version = "0.17", features = ["v2"] } | ||
| light-client = { version = "0.17", features = ["v2"] } | ||
|
|
||
| ### Phase 3: Rust SDK replacements | ||
|
|
||
| | v1 Pattern | v2 Replacement | | ||
| |------------|----------------| | ||
| | address::v1::derive_address | address::v2::derive_address | | ||
| | cpi::v1::CpiAccounts | cpi::v2::CpiAccounts | | ||
| | cpi::v1::LightSystemProgramCpi | cpi::v2::LightSystemProgramCpi | | ||
| | constants::ADDRESS_TREE_V1 | light_sdk_types::ADDRESS_TREE_V2 | | ||
| | .into_new_address_params_packed(seed) | .into_new_address_params_assigned_packed(seed, Some(0)) | | ||
| | .add_system_accounts(config) | .add_system_accounts_v2(config) | | ||
|
|
||
| ### Phase 4: TypeScript SDK replacements | ||
|
|
||
| | v1 Pattern | v2 Replacement | | ||
| |------------|----------------| | ||
| | deriveAddress( | deriveAddressV2( | | ||
| | deriveAddressSeed( | deriveAddressSeedV2( | | ||
| | defaultTestStateTreeAccounts().addressTree | batchAddressTree | | ||
| | .newWithSystemAccounts( | .newWithSystemAccountsV2( | | ||
| | get_address_tree_v1() | get_address_tree_v2() | | ||
| | get_random_state_tree_info_v1() | get_random_state_tree_info() | | ||
|
|
||
| ### Phase 5: Build and test loop | ||
|
|
||
| **Required commands (no shortcuts):** | ||
|
|
||
| For Anchor programs: `anchor build && anchor test` | ||
|
|
||
| For Native programs: `cargo build-sbf && cargo test-sbf` | ||
|
|
||
| **NO shortcuts allowed:** | ||
|
|
||
| - Do NOT use `cargo build` (must use `cargo build-sbf`) | ||
| - Do NOT use `cargo test` (must use `cargo test-sbf`) | ||
| - Tests MUST run against real BPF bytecode | ||
|
|
||
| **On failure:** Spawn debugger agent with error context. | ||
|
|
||
| **Loop rules:** | ||
|
|
||
| 1. Each debugger gets fresh context + previous debug reports | ||
| 2. Each attempt tries something DIFFERENT | ||
| 3. **NEVER GIVE UP** - keep spawning until fixed | ||
|
|
||
| Do NOT proceed until all tests pass. | ||
|
|
||
| ## DeepWiki fallback | ||
|
|
||
| If no matching pattern in reference repos: | ||
|
|
||
| mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "How to migrate {pattern} from v1 to v2?") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| ```mermaid | ||
| sequenceDiagram | ||
| participant U as User | ||
| participant C as Client | ||
| participant P as Program | ||
| participant L as Light Protocol | ||
|
|
||
| U->>C: secret + verification_id | ||
| C->>C: nullifier = Poseidon(vid, secret) | ||
| C->>C: proof = Groth16.prove(...) | ||
| C->>P: create_nullifier(proof, vid, nullifier) | ||
| P->>P: Groth16.verify(proof) | ||
| P->>L: derive_address(nullifier, vid) | ||
| L-->>P: address | ||
| P->>L: create_account(address) | ||
| L-->>P: success/fail | ||
| P-->>U: tx result | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| | | Description | | ||
| |:--------|:------------| | ||
| | [ZK-ID](https://github.com/Lightprotocol/program-examples/tree/main/zk/zk-id) | Identity verification using Groth16 proofs. Issuers create credentials; users prove ownership without revealing the credential. | | ||
| | [Nullifier](https://github.com/Lightprotocol/program-examples/tree/main/zk/zk-nullifier) | Simple Program to Create Nullifiers. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| --- | ||
| title: Examples | ||
| description: Example projects for building privacy applications on Solana. | ||
| keywords: ["privacy examples solana", "zk examples solana", "private payments examples", "zk identity solana"] | ||
| --- | ||
|
|
||
| import ZkExamplesTable from "/snippets/overview-tables/zk-examples-table.mdx"; | ||
|
|
||
| <ZkExamplesTable /> | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version inconsistency with main migration guide.
The versions here (
0.17) differ from those in/references/migration-v1-to-v2.mdxwhich specifieslight-sdk = "0.16"andlight-sdk-types = "0.3". This could confuse users or AI agents following the migration instructions.🔧 Align versions or add a note
Either update to match the main guide:
Or add a note that versions should be verified against the latest documentation.
📝 Committable suggestion
🤖 Prompt for AI Agents