Home

Awesome

# THIS PROJECT HAS BEEN SUNSET AND IT IS NOT ACTIVELY MAINTAINED ANYMORE

Chiquito

Chiquito is a high-level structured language for implementing zero knowledge proof applications.

Chiquito is being implemented in the DSL Working Group of PSE, Ethereum Foundation.

<p align="center"> <img src="https://hackmd.io/_uploads/HyuEr1cB2.png" width="180" height="80" alt="Image 2"> &nbsp; &nbsp; &nbsp; <img src="https://hackmd.io/_uploads/HyZ0rycS2.png" width="70" height="100" alt="Image 3"> </p>

Why is chiquito different from other ZKP DSLs?

Most ZKP DSLs are based on writing constraints, witness generation and some abstraction for DRY like templates or gadgets.

Chiquito allows the developer to think in more high-level and structured abstractions that most ZKP DSLs, while not sacrificing performance.

What is the chiquito programming model?

Chiquito starts from the idea that every zero knowledge proof represents a program (the setup), which can have many computations (the trace) that is proven for a certain input, output and intermediate values (the witness).

The main structured abstraction in chiquito is the step. Any computation can be divided in individual steps. A program is represented by a circuit that has one or many step types, a particular computation is represented as a series of step instances that can have arbitrary order.

A step type contains:

A chiquito circuit contains a trace function that for a given input will generate the step instances in a particular order and use the step type witness generation.

Another important piece of Chiquito are the signals. They represent elements of the witness.

There are several types:

Chiquito has many more features, but these are enough to start writing basic circuits.

What proving system chiquito uses?

Currently Halo2 backend is implemented, but we are looking into implementing other backends.

Chiquito frontend comes in two flavours: rust and python, so you can write Chiquito applications in either Rust or Python. PyChiquito, and any other language interface in the future, uses ChiquitoCore for most of its work, so adding new languages is easy.

What are the features of chiquito?

PLONKish-specific features:

Planned:

In research:

Fibonnaci circuit in Chiquito's Python frontend.

But better see for yourself:

class FiboStep(StepType):
    def setup(self: FiboStep):
        self.c = self.internal("c")
        self.constr(eq(self.circuit.a + self.circuit.b, self.c))
        self.transition(eq(self.circuit.b, self.circuit.a.next()))
        self.transition(eq(self.c, self.circuit.b.next()))

    def wg(self: FiboStep, args: Tuple[int, int]):
        a_value, b_value = args
        self.assign(self.circuit.a, F(a_value))
        self.assign(self.circuit.b, F(b_value))
        self.assign(self.c, F(a_value + b_value))

class Fibonacci(Circuit):
    def setup(self: Fibonacci):
        self.a: Queriable = self.forward("a")
        self.b: Queriable = self.forward("b")

        self.fibo_step = self.step_type(FiboStep(self, "fibo_step"))

        self.pragma_num_steps(11)

    def trace(self: Fibonacci, args: Any):
        self.add(self.fibo_step, (1, 1))
        a = 1
        b = 2
        for i in range(1, 11):
            self.add(self.fibo_step, (a, b))
            prev_a = a
            a = b
            b += prev_a

fibo = Fibonacci()
fibo_witness = fibo.gen_witness(None)
fibo.halo2_mock_prover(fibo_witness)

This is explained in more detail in the tutorial, but you can see already how concise and clear it is.

Getting Started

Read the tutorial

All located in the tutorial folder.

Run the tutorial locally

Follow Part 2: Quick Start of the tutorial folder.

Writing a chiquito circuit in your project

To use chiquito in Python, just need to install it with pip:

pip install chiquito

To use chiquito in Rust (TODO)

Build from source

Chiquito is built in Rust. First install Rust. Then clone this repo and enter the repo directory.

git clone https://github.com/privacy-scaling-explorations/chiquito
cd chiquito

Then to build Python chiquito with maturin

python -m venv .env
source .env/bin/activate
pip install -r requirements.txt
maturin develop

Testing and Links

API documentation: cargo doc --no-deps --package chiquito --open

Also auto-published here for the latest commit to main: docs.pecadorplonkish.xyz/

Licenses

MIT OR Apache-2.0