Giter Club home page Giter Club logo

gkr's Introduction

Proof aggregator using recursive GKR scheme

This is Cli tool for generation of aggregated proof for multiple inputs.

In this version, it supports circom circuit.

Preliminaries

circom and snarkjs should be installed already.

You can check that by this command:

snarkjs --help
circom --help

How to use

1. Install gkr

cargo install --path ./rust

2. Move to ./rust

cd rust

3. Write a circuit in ./rust and inputs in ./rust/example/ (/example is not mandatory)

4. Create GKR proof for inputs

You can give inputs by commands:

gkr-aggregator prove -c circuit.circom -i ./example/input1.json ./example/input2.json ./example/input3.json

You can get a message from cli:

Proving by groth16 can be done

4. Prepare zkey

You should prepare an appropriate ptau file.

snarkjs groth16 setup aggregated.r1cs pot.ptau c0.zkey
snarkjs zkey contribute c0.zkey c1.zkey --name=“mock” -v

Give random string for contribution, and then

snarkjs zkey beacon c1.zkey c.zkey 0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 -n="Final Beacon phase2"

5. Create aggregated Groth16 proof

gkr-aggregator mock-groth -z c.zkey

You can get proof.json and public.json.

Implementation details

Internal

Initial round

Get input from input.json, make d in proof with it.
Parse r1cs file and convert it to GKRCircuit. (Let's call this $C$)
Make proof $\pi_0$ from d and GKRCircuit.

Iterative round (0 < $i$ < n)

There are two circuit $C_i$ and $C_{v_{i - 1}}$. $C_{v_{i - 1}}$ is circuit that can verify $C_{i - 1}$.
$C_{v_i}$ can be different form for each circuit $C_i$. To make aggregated proof for previous proof and current round's proof, we need

  • input (for $C_i$)
  • proof $\pi_{i - 1}$

Make integrated circuit $C'_i$.

Use those inputs, make proof $\pi_i$. To be specific, input and proof $\pi_{i - 1}$

Last round

Also there are two circuit $C_n$ and $C_{v_{n - 1}}$. To send aggregated proof to on-chain verifier, we can use groth16 prover in snarkjs.
Integrated circuit $C'_{n}$ can be proved with snarkjs also.
So final proof $\pi_n$ is groth16 or plonk proof

gkr's People

Contributors

jeong0982 avatar therealyingtong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gkr's Issues

Detach proving scheme from aggregation flow

Currently, GKR is used for many schemes to use its fast proving time. It will be helpful if it can provide proving scheme api and circuit construction by itself (cause it is hard to extract arithmetic circuit from circom itself).

Structure of GKR circuit

GKR circuit

GKR generates proofs for the data-parallel execution of a layered arithmetic circuit.
But users who want to make new circuit for using GKR may have difficulty for designing layered circuit.
For usability of GKR protocol, it should have programmable and intuitive abstract structure for circuit.

Naive approach

Just make Node and make directed acyclic graph with that. Users should make DAG on their own from Node.
For now, it will be okay but it should be revised. It is hard to build circuit with layer for large program.

From circom

Start from circom rust library, it have dag library inside. It can make DAG, but it would be implemented after implementation of whole protocol. If this circom -> GKR -> circom flow is implemented, recursive proof can be made from this.

Own IR and further

It is kind of ambitious work. Making IR for circuit. And it can be optimized to GKR protocol. (maybe)
[ZLW+ 21] proposed GKR protocol that applies directly to non-layered circuits.
Not sure for if it is available to implement, but it can be helpful for exploring way to use general circuit with GKR protocol.

Separate sumcheck protocol

Current status

  • GKR prover can be run with circuit, function $D$ that is claimed to equal $W_0$, and returns proof.
  • GKR verifier can be run with circuit, proof, z.
  • Integrated sumcheck protocol is implemented.

TODO

For now, sumcheck is integrated with prover and verifier.
To get sumcheck proof, it should be separate. With this, structure of GKR proof should be fixed.

  • Implement verify_sumcheck, prove_sumcheck
  • Define GKR proof structure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.