Light introduces ZK Compression, a primitive in Solana scaling and interop. Light compresses account state by committing data as leaves to Merkle trees, allowing apps and smart contracts to interact with data stored outside the onchain account space. To keep the witness size small, Light uses Gnark groth16 proofs based on Worldcoin's Semaphore adaptation.
Groth16 proofs require a two-phase trusted setup:
- (1) Universal "Powers of Tau" ceremony (phase 1)
- (2) Circuit-specific setup (phase 2)
For (1) we are using the Perpetual Powers of Tau ceremony (up to contribution #80). We used a deserializer built by the Worldcoin team to convert it from the .ptau format into the .ph1 format used by gnark and initialized a phase 2 using Worldcoin's fork of a ceremony coordinator wrapper on top of gnark built by the zkbnb team.
- your machine must have Bash and curl installed. (Verify by running
bash --version
andcurl --version
)
- (Recommended) Verify the current contribution you're building on using the verification script. (See "How to Verify")
- Run the contribute curl command sent to you by the coordinator:
- Executes the
./contribute.sh
gist (here) script with your name/pseudonym, the contribution number, and the presigned URLs received from the coordinator. - The scripts downloads dependencies, the last contribution, adds your own, and uploads the result to the coordinator's s3 bucket.
- Executes the
- Please store your contribution hash and attest to it (e.g., social media, PGP signed email).
- Take steps to defend against attacks as you deem necessary, e.g. by wiping your RAM/SSD after you're done.
- Python 3.10+
- Git: Git Installation Guide
- Go: Go Installation Guide
- Curl
- Minimum 16GB RAM
Run the verification of all previous contributions:
-
Download this repo or pull the latest commits.
git clone https://github.com/Lightprotocol/gnark-mt-setup.git
-
Activate the virtual environment:
python3 -m venv venv source venv/bin/activate pip3 install boto3
-
Run the verification script:
python3 coordinator/verify_contributions.py --local
-
Check the contribution hashes in
./contributions/hashes
or in the log files (verify_logs) against those attested to by the respectiveparticipants.
The coordinator is responsible for managing the setup process.
- In light-protocol monorepo, checkout: swen/t-setup, then run:
./scripts/tsc-create-r1cs.sh
(This will download the ptau for power 16, convert it into a ph1 file, and extract the R1CS and convert it into .ph2 files for all our circuits.)
- Set up an AWS S3 bucket with object lock and versioning enabled
- Rename the initial contributions (phase 2 files) in the format:
<circuit_name><your_name>_contribution_0.ph2
- Upload them to the AWS S3 bucket.
- Use the coordinator script to create presigned URLs and manage contributions:
brew install awscli && aws configure
Ensure you have a valid AWS access key for the bucket used and use the correct region_name in the following scripts.
- Requirements:
- Python 3.10+
- Git: Git Installation Guide
- Go: Go Installation Guide
- Curl
-
Activate the virtual environment:
python3 -m venv venv source venv/bin/activate pip3 install boto3
-
Create presigned URLs:
python3 coordinator/create-urls.py <bucket_name> <next_contributor_name> <last_contribution_number> <last_contributor_name> <expiration_seconds> <region_name>
This command will output two sections:
- a curl command that will exeucte a gist with presigned URLs (recommmended)
- a command to run it without curl, but inside this repo (not recommended)
- Copy one of these outputs to clipboard and share it with the next contributor via a secure channel.
- Once the contributor has uploaded their new ph2 files, verify the new contributions by running:
python3 coordinator/verify_contributions.py <bucket_name> <region_name>
This will download all new ph2 files and store them and their hashes in the ./contributions folder.
- git push the latest diff (contribution) to this repo.
Now, anyone can verify the new contribution without AWS access by pulling the latest commit and running:
python3 coordinator/verify_contributions.py --local
Repeat this process for every new contribution. Before you create and send new presigned URLs, make sure to have verified against the AWS bucket and git pushed the latest diff to this repo.
Special thanks to:
- dcbuilder and worldcoin (for the semaphore-mtb-setup tools)
- the snarkjs team (for hosting the ptau files)
- the zk community (for the ptau ceremony)