Lightprotocol / light-protocol

The ZK Compression Protocol For Solana
https://www.zkcompression.com
GNU General Public License v3.0
157 stars 27 forks source link

Light Protocol

Light Protocol

Discord Workflow Status

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...

The documentation is available here: https://github.com/Lightprotocol/developer-content/tree/main/docs.

Verifiable Build

Prerequisites:

./scripts/build-verifiable.sh

Verify Deployment

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

Security

Light Protocol programs have been audited, and Light protocol circuits are formally verified:

Note: All other tooling such as light-sdk-macros and light-sdk are in active development and unaudited.

Development environment

There are three ways of setting up the development environment:

devenv.sh

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

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.

Development Containers

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:

Manual setup

If you still want to setup dependencies manually, these are the requirements:

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

Building

To build the project, use the following commands:

./scripts/build.sh

Solana keypair

Before doing any development or running any tests, you need to generate a new local keypair:

solana-keygen new -o ~/.config/solana/id.json

Tests

Global

./scripts/test.sh

Program tests

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

SDK tests

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