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

Prerequisites

Step by step guide

  1. Create a folder named code to put the code
  2. Create the square.zok file with this content:
def main(private field a, field b):
assert(a * a == b)
return

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.zok 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.zok
# 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

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

7. Compile

8. Deploy

9. The function verifyTx requires an array because structs in solidity map to arrays in the ABI:

Make sure to encapsulate the proof inside [ ] just like in the image.

10. Call the verifyTx function:

--

--

--

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

How to configure a Jenkins job to run Selenium Python tests using BrowserStack?

[LeetCode] First Unique Number

⚔️ 3 REASONS WHY YOU FAILED IN THE PVP?

Multiple Superpeers Post 5/8

Bitcoin Trade Automation with Awesome Oscillator in Python

Recruiters, don’t be *this* guy

Docker Size Investigation

O-HERA, The Open Group Healthcare Enterprise Reference Architecture

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.5.0) solidity (0.5.0)

01 Basics of Smart Contracts

Course 2 Project: Design and Development of Smart Contract

Solidity : Value Type