Git Product home page Git Product logo

zeth's Introduction

Zeth - Zerocash on Ethereum

macOS build ubuntu build

๐Ÿšจ WARNING This project is a Proof of Concept. It is highly inefficient and has not been thoroughly reviewed. Please do not use in production!

Disclaimer: This work is inspired from babyzoe, Miximus. It follows and extends the design presented in zerocash-ethereum by adapting some code initially written by Zcash.

๐Ÿ‘‰ Check our paper, and the protocol specifications for more information about Zeth.

๐Ÿ™‹ Want to propose a protocol change? Amazing! Please consider writing a Zeth Protocol Improvement Proposal (ZPIP).

Building and running the project:

๐Ÿ’ป Warning This project primarily targets x86_64 Linux and macOS platforms.

Environment

In order to follow the README below, you will need:

  • Docker
  • Npm (at least version 6.9.0)
  • Node (recommended version v10 to be able to build and use the custom ganache-cli)
  • Python3 (at least version 3.7)
  • Pip (at least version 19.0.2)

Additionally, several tools from the GCC and LLVM tools suite are used to improve code quality and generate the documentation of the project. These are required in order to compile the project with all options enabled:

To use the Zeth functionality, 3 components are required:

  • An Ethereum network (the commands below use a local testnet) to host the Zeth contracts and handle transactions.
  • A running "prover_server" process, used by Zeth clients to generate proofs.
  • Client tools, which generate all inputs required for a Zeth operations, request proofs from the "prover_server", and transmit transactions to the Ethereum network holding the Zeth contract.

We use 3 terminals, one for each of the above components.

Note: Mac users should increase docker runtime memory from 2GB to 4GB to allow Terminal 1 to complete successfully.

Terminal 1:

We propose 2 alternatives to run the prover_server below.

Fetch the prover_server image (recommended)
docker pull ghcr.io/clearmatics/zeth:latest-prover
docker run -ti -p 50051:50051 --name prover ghcr.io/clearmatics/zeth:latest-prover prover_server
Build and run the prover_server in the development container
# Clone this repository:
git clone [email protected]:clearmatics/zeth.git
cd zeth

# Build the zeth-dev image
docker build -f Dockerfile-dev -t zeth-dev .
# Start the zeth development container
docker run -ti -p 50051:50051 --name zeth zeth-dev:latest

# All the commands below are run in the docker container
# Configure your environment
. ./setup_env.sh

# Compile the proving server
mkdir build
cd build
cmake .. [<flags (see below)>]
# Compile all libraries and tools, including the prover_server
make
# (optional) Run the unit tests
make test
# (optional) Run the all tests (unit tests, syntax checks, etc)
make check

# Start the prover_server process
prover_server

Note: By default, prover_server generates a key at startup. Flags can be used to force the server to load and/or save keys. Run prover_server --help for more details.

Build Options

Some flags to the cmake command can control the build configuration. -DCMAKE_BUILD_TYPE=Release or -DCMAKE_BUILD_TYPE=Debug can be used to force a release or debug build.

By default, zeth makes use of the GROTH16 zk-snark. To chose a different zksnark run the following: cmake -DZETH_SNARK=$ZKSNARK .. where $ZETH_SNARK is PGHR13 (see https://eprint.iacr.org/2013/279, http://eprint.iacr.org/2013/879) or GROTH16(see https://eprint.iacr.org/2016/260).

Terminal 2: Ethereum testnet

# Start the Ethereum test net by running the following commands
cd zeth_contracts

# If the install below fails with python errors, try running:
npm config set python python2.7

# Install dependencies
npm install

# Start a local Ethereum testnet
npm run testrpc

Terminal 3: Python client

# Configure your environment
. ./setup_env.sh

cd client

Follow the steps described in the client README to run tests or invoke the zeth tools.

Secure Multi Party Computation for the Groth16 SRS generation

See MPC for SRS generation documentation

Development dependencies (for building outside of the Docker container)

Immediate dependencies are provided as submodules and compiled during the Zeth build. Ensure submodules are synced.

The following libraries are also required to build:

  • grpc
  • gmp
  • boost
  • openssl

Generate the Doxygen documentation

To generate the documentation of Zeth:

cd build
cmake .. -DGEN_DOC=ON && make docs

Compile the project using 'sanitizers'

You can select the sanitizer of your choice (one of the sanitizers listed here) by passing the flag -DSANITIZER=<sanitizer> to cmake.

Example:

cd build
cmake -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DSANITIZER=Address -DCMAKE_BUILD_TYPE=Debug ..
make check

Docker images

Docker files Image Tags Description
./Dockerfile-prover ghcr.io/clearmatics/zeth:latest-prover latest-prover, X.Y.Z-prover - Release of zeth, git-%HASH%-prover - developers build by git-commit Zeth Prover Server. Image use zeth-base for building
./Dockerfile-client ghcr.io/clearmatics/zeth:latest-client latest-client, X.Y.Z-client - Release of zeth, git-%HASH%-client - developers build by git-commit Python client to interact with the prover
./Dockerfile-mpc ghcr.io/clearmatics/zeth:latest-mpc latest-mpc, X.Y.Z-mpc - Release of zeth, git-%HASH%-mpc - developers build by git-commit Tools for Multi-Party Computation. Image use zeth-base for building
./Dockerfile-base ghcr.io/clearmatics/zeth:latest-base latest-base, A.B.C-base - Release of zeth-base Base image for building other containers

Run analysis tools on the code

Several tools can be ran on the code. These can be enabled via a set of compilation options.

Note: The clang-tidy target runs a clang-tidy python script that should be fetched from here. To do so, run: cd build && wget https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Example:

# run-clang-tidy.py needs to be in the PATH to be found
PATH=$PATH:${PWD}
chmod +x run-clang-tidy.py

cmake -DUSE_CLANG_FORMAT=ON -DUSE_CPP_CHECK=ON -DUSE_CLANG_TIDY=ON ..
make cppcheck
make clang-format
make clang-tidy

Generate code coverage report

  1. Make sure to enable the CODE_COVERAGE option in the CMake configuration.
  2. Compile the tests
cd build && cmake -DCODE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug .. && make check
  1. Generate the coverage report:
make coverage

Note: In order to generate the coverage reports, you will need lcov, along with genhtml and xdg-open.

References and useful links

License notices:

Zcash

Copyright (c) 2016-2018 The Zcash developers
Copyright (c) 2009-2018 The Bitcoin Core developers
Copyright (c) 2009-2018 Bitcoin Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


The MIT software license (http://www.opensource.org/licenses/mit-license.php)
above applies to the code directly included in this source distribution.
Dependencies downloaded as part of the build process may be covered by other
open-source licenses. For further details see 'contrib/debian/copyright'.


This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit (https://www.openssl.org/). This product includes cryptographic
software written by Eric Young ([email protected]).


Although almost all of the Zcash code is licensed under "permissive" open source
licenses, users and distributors should note that when built using the default
build options, Zcash depends on Oracle Berkeley DB 6.2.x, which is licensed
under the GNU Affero General Public License.

Libsnark

The libsnark library is developed by SCIPR Lab (http://scipr-lab.org)
and contributors.

Copyright (c) 2012-2014 SCIPR Lab and contributors (see AUTHORS file).

All files, with the exceptions below, are released under the MIT License:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Miximus

barryWhiteHat/miximus GNU General Public License v3.0

zeth's People

Contributors

antoinerondelet avatar dependabot[bot] avatar dtebbs avatar riemann89 avatar rrtoledo avatar shapeshed avatar shirikatsu avatar

Watchers

 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.