This document provides a high-level introduction to the Light Protocol repository, explaining its purpose as a ZK Compression system for Solana and presenting the major components that comprise the protocol. For detailed information about specific subsystems, refer to the respective sections of this wiki.
Purpose: Light Protocol enables developers to create rent-free tokens and Program Derived Accounts (PDAs) on Solana using zero-knowledge compression technology README.md10-13 The protocol achieves this by storing account state in Merkle trees and proving state transitions using ZK proofs, reducing on-chain storage costs while maintaining performance and composability README.md27-30
Scope: This overview covers the repository structure, core architectural components, and their interactions. For detailed implementation information, see:
ZK Compression is a state compression mechanism that stores account data in on-chain Merkle trees rather than individual accounts. Account state is represented as leaves in these trees, and state transitions are validated using zero-knowledge proofs. This approach provides:
The protocol has been audited by OtterSec, Neodyme, and Zellic, with circuits formally verified by Reilabs README.md65-72
Sources: README.md10-72
The Light Protocol repository is organized as a multi-language monorepo containing Rust and JavaScript/TypeScript components:
Directory Layout:
programs/: On-chain Solana programs Cargo.toml22-25program-libs/: Shared Rust libraries used by on-chain programs Cargo.toml5-21sdk-libs/: Off-chain Rust SDKs for building applications Cargo.toml27-42program-tests/ and sdk-tests/: Comprehensive test suites Cargo.toml44-77forester/: Off-chain service for Merkle tree maintenance Cargo.toml79js/: JavaScript/TypeScript SDKs pnpm-lock.yaml178-234cli/: Command-line interface for development workflows pnpm-lock.yaml30-103xtask/: Development utilities (tree creation, benchmarking, deployment) xtask/src/main.rs1-152external/photon/: Git submodule for the Photon indexer Cargo.toml2For details, see Repository Structure.
Sources: Cargo.toml1-81 pnpm-lock.yaml1-234 README.md17-24
The following diagram bridges high-level operations with specific code entities:
Key Interaction Patterns:
photon-api client) to retrieve compressed account data and Merkle proofs needed for state transitions sdk-libs/client/Cargo.toml58light-prover-client sdk-libs/client/Cargo.toml59account-compression program verifies proofs and queues state updates Cargo.toml22forester service monitors queues, generates batch proofs, and submits them to finalize tree updates Cargo.toml79For details, see System Architecture.
Sources: sdk-libs/client/Cargo.toml1-81 Cargo.toml1-81 README.md17-18
Light Protocol consists of four core Solana programs:
| Program | Crate Name | Purpose |
|---|---|---|
account-compression | account-compression | Merkle tree operations, batch processing, ZKP verification Cargo.toml22 |
light-registry | light-registry | Forester coordination, epoch management, protocol config Cargo.toml25 |
light-system-program | light-system-program | ZK compression core, CPI framework Cargo.toml23 |
light-compressed-token | light-compressed-token | Compressed SPL token operations Cargo.toml24 |
Program Locations:
programs/account-compression/programs/registry/programs/system/programs/compressed-token/program/Deployment Verification: The programs use verifiable builds README.md32-43 See README.md45-63 for verification instructions using solana-verify.
Sources: Cargo.toml22-25 README.md32-63
Light Protocol provides SDKs for building compressed account applications:
Rust SDKs:
light-client (sdk-libs/client/): High-level client for interacting with compressed accounts and building transactions sdk-libs/client/Cargo.toml2-7light-sdk (sdk-libs/sdk/): Core SDK for programs using compressed state sdk-libs/sdk/Cargo.toml2-4light-token-sdk (sdk-libs/token-sdk/): SDK for compressed token operations Cargo.toml28light-program-test (sdk-libs/program-test/): Fast local testing environment using litesvm sdk-libs/program-test/Cargo.toml2-34JavaScript/TypeScript SDKs:
@lightprotocol/stateless.js: Core RPC interface for compressed accounts pnpm-lock.yaml41-43@lightprotocol/compressed-token: Token-specific operations pnpm-lock.yaml35-37cli: Command-line interface for development workflows pnpm-lock.yaml30-31Sources: sdk-libs/client/Cargo.toml1-81 sdk-libs/sdk/Cargo.toml1-87 sdk-libs/program-test/Cargo.toml1-72 pnpm-lock.yaml30-185
The protocol supports multiple Merkle tree implementations optimized for different use cases:
Implementations:
program-libs/concurrent-merkle-tree/ Cargo.toml17program-libs/indexed-merkle-tree/ Cargo.toml19program-libs/batched-merkle-tree/ Cargo.toml9sparse-merkle-tree/ Cargo.toml80Sources: Cargo.toml5-21 Cargo.toml80
Environment Setup:
scripts/install.sh to install dependencies and gnark keys README.md104-113scripts/devenv.sh README.md118-119solana-keygen new -o ~/.config/solana/id.json README.md171The xtask Utility:
The xtask crate provides critical development commands xtask/src/main.rs41-105:
GenerateVkeyRs: Generates verification keys from gnark keys xtask/src/main.rs49-50CreateStateTree: Initializes on-chain state trees xtask/src/main.rs57-60CreateCtokenAccount: Creates compressed token accounts xtask/src/main.rs97-100Bench: Generates compute unit and heap usage reports xtask/src/main.rs51-52Sources: README.md76-180 xtask/src/main.rs1-152
For deeper understanding of specific subsystems:
Sources: Wiki table of contents structure
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.