The ZK Layer for Solana
Light is a zkLayer enabling private program execution, purpose-built for Solana.
Developers can use Light to build applications such as
- encrypted orderbooks
- private governance
- on-chain games with private state
- zk-identity
ZK Anchor is what we call the collection of developer tools for writing Private Solana Programs (PSPs). It consists of the following:
- Macro Circom DSL for writing PSPs.
- CLI for writing and testing full Applications
- RPC Node (relayer) - for indexing and forwarding Light transactions to the Solana network.
- zk.js - web3.js-esque helpers to build transactions and interact with your PSP.
Note: All these tools and the protocol are in active development and unaudited. You can currently test and deploy your PSP on Localnet, Testnet, and Devnet.
To get started, a good PSP reference implementation is available here.
Otherwise, to work with this Monorepo, read below:
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.
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). If you want to install Redis (needed
only for the relayer), use the --enable-redis
option.
./scripts/install.sh
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 (16.16 LTS)
- Anchor (0.26.0)
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
cd light-verifier-sdk/
cargo test
cd zk.js/
pnpm test
cd light-circuits
pnpm test
Tests are located in tests/
directory.
The default test is a functional test, setting up a test environment with a Merkle tree and an spl token, conducting two shields and unshields.
Tests can be executed in bulk or one by one.
cd zk.js/
pnpm test
pnpm test-verifiers
pnpm test-merkle-tree
If you're seeing this error:
error: package `solana-program v1.16.4` cannot be built because it requires rustc 1.68.0 or newer, while the currently active rustc version is 1.65.0-dev
update your solana-cli version to >=1.16.4.
For more support from the community and core developers, open a GitHub issue or join the Light Protocol Discord: https://discord.gg/J3KvDfZpyp