Skip to content

NilFoundation/proof-producer

Repository files navigation

Proof producer for the =nil; Proof Market

This repository contains the proof producer for the =nil; Proof Market, which is a part of the =nil; zkllvm toolchain for zk-enabled applications development.

How to use

The input for the proof producer is a circified version of the algorithm to be proven. This circified version of the algorithm is generated by the zkllvm toolchain.

Typically, you want to use the proof producer to participate in the =nil; Proof Market. In this case, you need to have a valid account on the =nil; Proof Market, which you can create through the Proof Market web interface or by using the Proof Market CLI.

Installation

All parts of the zkLLVM toolchain are distributed in form of deb packages. To install them, you need to add the =nil; repository to your systems package manager:

echo 'deb [trusted=yes]  http://deb.nil.foundation/ubuntu/ all main' >>/etc/apt/sources.list
apt update

Then, you can install the proof producer by running:

apt install proof-producer

Usage

The proof producer is a command line tool. To see the list of available options, run:

proof-generator --help

To produce a proof, you need to provide the proof producer with the file with the circuit definition and the assignment table with the values of the execution trace. You generate them from the zkllvm examples or download the existing ones using the Proof Market CLI.

When you have the circuit definition and the assignment table, you can produce a proof by running:

proof-generator --circuit <circuit-file> --assignment <assignment-file> --proof <proof-file>

Building from source

  1. Install dependencies:

    sudo apt-get install \
        build-essential \
        libsctp-dev \
        libssl-dev \
        libicu-dev \
        lsb-release \
        gnutls-dev \
        pkg-config
    
  2. Build with CMake:

    cd build
    cmake ..
    make -j $(nrpoc)
    

Sample calls to proof-producer

In all the calls you can change the executable name from proof-producer-single-threaded to proof-producer-multi-threaded to run on all the CPUs of your machine.

Generate a proof and verify it:

./build/bin/proof-producer/proof-producer-single-threaded --circuit="circuit.crct" --assignment-table="assignment.tbl" --proof="proof.bin" -q 10

Making a call to preprocessor:

./build/bin/proof-producer/proof-producer-single-threaded --stage="preprocess" --circuit="circuit.crct" --assignment-table="assignment.tbl" --common-data="preprocessed_common_data.dat" --preprocessed-data="preprocessed.dat" --commitment-state-file="commitment_state.dat" --assignment-description-file="assignment-description.dat" -q 10

Making a call to prover:

./build/bin/proof-producer/proof-producer-single-threaded --stage="prove" --circuit="circuit.crct" --assignment-table="assignment.tbl" --common-data="preprocessed_common_data.dat" --preprocessed-data="preprocessed.dat" --commitment-state-file="commitment_state.dat" --proof="proof.bin" -q 10

Verify generated proof:

./build/bin/proof-producer/proof-producer-single-threaded --stage="verify" --circuit="circuit.crct" --common-data="preprocessed_common_data.dat" --proof="proof.bin" --assignment-description-file="assignment-description.dat" -q 10

Aggregate challenges

./build/bin/proof-producer/proof-producer-single-threaded --stage="generate-aggregated-challenge" --input-challenge-files challenge1.dat challenge2.dat --aggregated-challenge-file="aggregated_challenge.dat"