Giter Club home page Giter Club logo

gzkbpp's Introduction

Generalized ZKB++

This is an implementation of the ZKB++ proof system, where the inner circuit can easily be exchanged.

Dependencies

The OpenSSL library is required.

Compilation

Use the provided _compile_zkbpp.sh file to compile the program:

  1. chmod +x _compile_zkbpp.sh
  2. ./_compile_zkbpp.sh

The implementation was tested on CentOS 7.5 and by using Valgrind 3.13.0.

Usage

After compilation, the program can be used with the following parameters:

./zkbpp_test <field_size> <num_branches> <field_type> <cipher_type> <print_result>

where

  • field_size specifies the field size in bits,
  • num_branches specifies the number of branches,
  • field_type specifies the type of the field (0 for prime field, 1 for binary field),
  • cipher_type specifies the cipher being used, and
  • print_result specifies whether results should be printed to the console.

Circuits

Adding Circuits

New circuits can be implemented by adding three specific methods to the CircuitContainer class (replace "Instance" with the name of the new circuit):

  1. initInstance(.)

    This method initializes a new circuit. Typical values for block ciphers include the number of rounds or the number of branches for Feistel-based constructions. Any necessary precompution (e.g. round keys, round constants) should also be done in this method. Note that in ZKB++, each multiplication gate requires a set of random values, and therefore the number of multiplication gates must also be set here. Moreover, the necessary function pointers are also set in this method.

  2. directInstance(.)

    This method is a direct evaluation of the specified circuit, without any multi-party computations, shares, or random numbers for the multiplications.

  3. circuitInstance(.)

    The MPC version of the circuit is implemented in this method. The function pointers previously defined in beforeSign(.) and beforeVerify(.) have to be used here, because this method is called both during proof generation and proof verification.

Circuit Gates

A few circuit gates are already implemented. Common circuit gates include addition and multiplication, both with shared or constant values. Note that some circuit gates are implemented differently for proof generation and proof verification. If additional gates are needed, they can be added by using the same techniques found in e.g. addSharedSign(.) or addSharedVerify(.).

Field Arithmetic

The BigIntLib class includes methods for computations in a set of predefined finite fields, in particular prime fields and binary fields. New methods can easily be added for finite fields of different sizes. Currently, the Solinas reduction [1] is used for prime fields, and a fast word-wise reduction [2] is used for binary fields.

As an example circuit, MiMC is included. This circuit can be tested with ./zkbpp_test 256 1 0 1 1.

[1] Jerome A. Solinas: Generalized Mersenne Numbers
[2] Darrel Hankerson, Alfred Menezes and Scott Vanstone: Guide to Elliptic Curve Cryptography

gzkbpp's People

Contributors

mschof 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.