The ZK Compression Protocol for Solana
Light is a ZK protocol enabling stateless program execution that is purpose-built for Solana.
Developers can use Light to...
- reduce the cost of state on the Solana L1 via ZK Compression.
- build zk applications that compose with Light state such as
- offchain orderbooks
- zk-coprocessors
- zk-identity
The documentation is available here: https://github.com/Lightprotocol/developer-content/tree/main/docs.
Prerequisites:
- solana-verify
- docker
Install
solana-verify
withcargo-install solana-verify
or see github for alternative install instructions. See https://docs.docker.com/engine/install/ fordocker
install instructions.
./scripts/build-verifiable.sh
Release 1.0 commit hash: 1cb0f067b3d2d4e012e76507c077fc348eb88091
$ solana-verify verify-from-repo --program-id Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX -u main --library-name light_registry --commit-hash 1cb0f067b3d2d4e012e76507c077fc348eb88091 https://github.com/Lightprotocol/light-protocol
$ solana-verify verify-from-repo --program-id compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq -u main --library-name account_compression --commit-hash 1cb0f067b3d2d4e012e76507c077fc348eb88091 https://github.com/Lightprotocol/light-protocol
$ solana-verify verify-from-repo --program-id SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7 -u main --library-name light_system_program --commit-hash 1cb0f067b3d2d4e012e76507c077fc348eb88091 https://github.com/Lightprotocol/light-protocol
$ solana-verify verify-from-repo --program-id cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m -u main --library-name light_compressed_token --commit-hash 1cb0f067b3d2d4e012e76507c077fc348eb88091 https://github.com/Lightprotocol/light-protocol
Light Protocol programs have been audited, and Light protocol circuits are formally verified:
- OtterSec (Programs audit): View Full Report
- Neodyme (Programs audit): View Full Report
- Reilabs (Circuits Formal verification): View Full Report
Note: All other tooling such as light-sdk-macros and light-sdk are in active development and unaudited.
There are three ways of setting up the development environment:
- devenv.sh script - the most recommended one, both for Linux and macOS. Works with Bash and zsh.
- Development Containers - recommended on Linux, unfortunately has performance problems on macOS.
- Manual setup - not recommended, but may be useful if the methods above don't work for you.
- Windows is not supported.
- Ubuntu,
sudo apt-get install lld clang
- Fedora,
sudo dnf install clang lld
- Arch,
sudo pacman -S lld clang
- Mac,
brew install llvm
The easiest way to setup the development environment is to use our scripts and development environment.
First, install the dependencies (they will be installed in the .local
directory inside your repository clone).
./scripts/install.sh
By default, this will install a subset of gnark keys with Merkle tree heights sufficient for running tests. If you need the full set of production keys, you can use the --full-keys flag:
./scripts/install.sh --full-keys
Note: The default subset of keys is adequate for most development and testing purposes. The full set of keys is larger and includes additional Merkle tree heights used in production environments.
Then, activate the development environment:
./scripts/devenv.sh
Then follow the sections below, which describe the usage of build.sh
and
test.sh
scripts.
When the development environment is active, you can manually run commands
like pnpm
, cargo
, solana
, solana-test-validator
. They are going to
use the dependencies installed in .local
directory, so even if you have
different global installations, they are not going to interfere.
Light Protocol fully embraces Development Containers, providing a ready-to-use Docker container image that comes pre-configured with all necessary dependencies for building and testing.
Support for Development Containers (either native or through a plugin) is provided by the following IDEs and editors:
If you still want to setup dependencies manually, these are the requirements:
- Rust installed with Rustup, stable and nightly toolchains
- NodeJS (20.9.0 LTS)
- Anchor (0.29.0)
If you are using Ubuntu and encounter errors during the build process, you may need to install additional dependencies. Use the following command:
sudo apt install build-essential autoconf automake libtool zlib1g-dev pkg-config libssl-dev
To build the project, use the following commands:
./scripts/build.sh
Before doing any development or running any tests, you need to generate a new local keypair:
solana-keygen new -o ~/.config/solana/id.json
./scripts/test.sh
Program tests are located in test-programs.
Many tests start a local prover server.
To avoid conflicts between local prover servers run program tests with --test-threads=1
so that tests are executed in sequence.
cargo test-sbf -p account-compression-test -- --test-threads=1
cd js/stateless.js
pnpm test
cd js/compressed-token.js
pnpm test
For more support from the community and core developers, open a GitHub issue or join the Light Protocol Discord: https://discord.gg/x4nyjT8fK5