Git Product home page Git Product logo

installzokratesonmac's Introduction

Installing ZoKrates on Mac with All Proving Schemes Enabled

I recently started to learn how to use ZoKrates. The default installation only supports the proving scheme G16, which is malleable, that is, an attacker can easily generate another valid proof if he/she sees a valid proof.

It took me quite some time to figure out how to properly install ZoKrates on my Mac to enable the other two proving schemes and I feel like it is worth sharing with others.

Installation Step

  1. Download ZoKrates using git clone https://github.com/Zokrates/ZoKrates.git

  2. Modify $zokrates_home/zokrates_core/build.rs as follows:

    let libsnark = cmake::Config::new(libsnark_source_path)
            .define("WITH_SUPERCOP", "OFF")
            .define("WITH_PROCPS", "OFF")
            .define("CURVE", "ALT_BN128")
            .define("USE_PT_COMPRESSION", "OFF")
            .define("MONTGOMERY_OUTPUT", "ON")
            .define("BINARY_OUTPUT", "ON")
            .build();       
  3. Make sure that openssl has been installed. Otherwise, install via brew install openssl.

  4. Set export PKG_CONFIG_PATH=$(brew --prefix openssl)/lib/pkgconfig

  5. Set export WITH_LIBSNARK=1

  6. Run build_release.sh and the compiled executable zokrates can be found in $zokrates_home/target/release/

A Simple Example

As a simple example, I want to prove my knowledge of two secret numbers whose sum equals 10. To do that using ZoKrates, we first write file simple_add.code as:

def main(private field a, private field b) -> (field):
    a+b == 10
    return 1

Suppose we want to use proving scheme GM17 and the secret numbers are 3 and 7, we do:

zokrates setup -s gm17
zokrates export-verifier -s gm17
zokrates compute-witness -a 3 7 
zokrates generate-proof -s gm17

Within the current folder, we can see the exported contract verifier.sol that implements the verification function and the proof proof.json.

installzokratesonmac's People

Contributors

zzghzz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.