ailgo / demo-zk

This project is a demo of a simple ZK application that allows verifying a proof generated using the groth16 scheme and the BLS12_381 curve.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Demo ZK

⚠️ This is a demo project, it is not intended to be used in production. ⚠️

This project is a demo of a simple ZK application that allows verifying a proof generated using the groth16 scheme and the BLS12_381 curve.

This demo only shows the verification of a proof using BLS12_381 but BN254 is also supported in the AVM. However, Zokrates does not support BN254 curve, so a different library will be needed to generate a proof for that curve.

Use

First clone this repo down

Note: This demo requires Python >= 3.10

Node Setup

In the sandbox directory, run ./setup.sh to

  1. clone down the sandbox
  2. setup configuration, so it may run with the EC math ops
  3. start the sandbox node

Note: This will start a sandbox node using the barnjamin/ec-math-wiggle branch of go-algorand, which has the EC math ops enabled in version 8 of the AVM. The AVM version they'll be enabled with is more likely to be version 10, but this is sufficient to start testing.

Demo Setup

Install Zokrates using the instructions here.

Run the generate_proof script to generate the Verification Key and Proof

./generate_proof.sh

Note: This must be done prior to running the contract since it relies on the Verification Key and Proof generated during this step

Demo

Install python prerequisites

$ python -m venv .venv
$ source .venv/bin/activate
(.venv) $ pip install -r requirements.txt

Run the demo

(.venv) $ cd contracts 
(.venv) $ python main.py
Created app: 1
Contract verified? True

Going Further

Modify the .zok file to change the proof that is generated to something more interesting.

Generate a proof using a different library to use the BN254 curve

About

This project is a demo of a simple ZK application that allows verifying a proof generated using the groth16 scheme and the BLS12_381 curve.


Languages

Language:Python 95.8%Language:Shell 4.2%