Skip to content

Lightprotocol/gnark-mt-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Light Protocol Trusted Setup

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.

How to Participate in the Trusted Setup

Requirements

  • your machine must have Bash and curl installed. (Verify by running bash --version and curl --version)

Steps

  1. (Recommended) Verify the current contribution you're building on using the verification script. (See "How to Verify")
  2. 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.
  3. Please store your contribution hash and attest to it (e.g., social media, PGP signed email).
  4. Take steps to defend against attacks as you deem necessary, e.g. by wiping your RAM/SSD after you're done.

How to Verify

As a non-coordinator

Run the verification of all previous contributions:

  1. Download this repo or pull the latest commits.

    git clone https://github.com/Lightprotocol/gnark-mt-setup.git
    
  2. Activate the virtual environment:

    python3 -m venv venv
    source venv/bin/activate
    pip3 install boto3
    
  3. Run the verification script:

    python3 coordinator/verify_contributions.py --local
    
  4. Check the contribution hashes in ./contributions/hashes or in the log files (verify_logs) against those attested to by the respectiveparticipants.

Coordinator Section

The coordinator is responsible for managing the setup process.

These steps have been executed once (Do not run again)

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

  1. Set up an AWS S3 bucket with object lock and versioning enabled
  2. Rename the initial contributions (phase 2 files) in the format: <circuit_name><your_name>_contribution_0.ph2
  3. Upload them to the AWS S3 bucket.

These steps must be repeated for every contribution:

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

  1. Requirements:
  1. Activate the virtual environment:

    python3 -m venv venv
    source venv/bin/activate
    pip3 install boto3
    
  2. 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:

  1. a curl command that will exeucte a gist with presigned URLs (recommmended)
  2. 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.

Thank You

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published