Getting Started


One-line install

We provide a one-line install for Linux, MacOS and FreeBSD:

curl -LSfs | sh


ZoKrates is available on Dockerhub.

docker run -ti zokrates/zokrates /bin/bash

From there on, you can use the zokrates CLI.

From source

You can build the container yourself from source with the following commands:

git clone
cd ZoKrates
cargo +nightly build --release
cd target/release

Hello ZoKrates!

First, create the text-file root.code and implement your program. In this example, we will prove knowledge of the square root a of a number b:

def main(private field a, field b) -> (field):
  field result = if a * a == b then 1 else 0 fi
  return result

Some observations:

  • The keyword field is the basic type we use, which is an element of a given prime field.
  • The keyword private signals that we do not want to reveal this input, but still prove that we know its value.

Then run the different phases of the protocol:

# compile
./zokrates compile -i root.code
# perform the setup phase
./zokrates setup
# execute the program
./zokrates compute-witness -a 337 113569
# generate a proof of computation
./zokrates generate-proof
# export a solidity verifier
./zokrates export-verifier

The CLI commands are explained in more detail in the CLI reference.