Creating simple zero-knowledge verifier contract with ZoKrates (0.5.0) solidity (0.5.0)


Step by step guide

  1. Create a folder named code to put the code
  2. Create the square.code file with this content:
def main(private field a, field b) -> (field):
field result = if a * a == b then 1 else 0 fi
return result

3. Start docker

4. Open the terminal run this command:

docker run -v <PATH_TO_FOLDER>:/home/zokrates/code -ti zokrates/zokrates /bin/bash

In my case that PATH_TO_FOLDER is were I created the square.code file which is:

docker run -v /Users/andi/Downloads/UdacityGithubNeu-master/zokrates/code:/home/zokrates/code -ti zokrates/zokrates /bin/bash

5. Change directory to code:

cd code

6. Run this commands to create the proof and verifier

# compile
zokrates compile -i square.code
# perform the setup phase
zokrates setup
# execute the program
zokrates compute-witness -a 3 9
# generate a proof of computation
zokrates generate-proof
# export a solidity verifier
zokrates export-verifier

6. Open remix IDE, create a contract and copy paste the contents of verifier.sol:

7. Compile

8. Deploy

9. Call the verifyTx function:




Love podcasts or audiobooks? Learn on the go with our new app.

Measure Twice, Cut Once — Note to any Developer.

Avoid these 8 mistakes which most of the programmers do

How many ways we can read multiple sources (csv, text, url, etc…..)?

Learning to Code? Fall in Love With Errors

Git basics in a FLASH!

grind, polish, scour, improve, brush (teeth)

How to: Azure DevOps Service health using maps in Power BI

The other thing wrong with James Damore’s Manifesto

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alvaro Andres Pinzon Cortes

Alvaro Andres Pinzon Cortes

More from Medium

Creating simple zero-knowledge verifier contract with ZoKrates (0.7.13) solidity (0.8.0)

Transactions in Ethereum

Diagram showing transaction and internal transaction.

Getting Loopy with Solidity

5 Tools for Analysing the Security of Solidity Smart Contracts In 2022