Skip to content

Commit

Permalink
Removed all miximus related work from project, made importing via CMa…
Browse files Browse the repository at this point in the history
…ke much easier
  • Loading branch information
HarryR authored and HarryR committed Nov 27, 2018
1 parent d111f3e commit 967308c
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 923 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
build/
bin/
.keys/
*.pyc
*.swp
*.swo
Expand Down
29 changes: 21 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.8)

project(ethsnarks)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

include(CTest)
enable_testing()


set(
Expand Down Expand Up @@ -38,6 +39,14 @@ set(
"Optionally specify the dependency installation directory relative to the source directory (default: inside dependency folder)"
)

set(
DEPENDS_DIR_LIBFQFFT
"${DEPENDS_DIR_LIBSNARK}/depends/libfqfft/"
CACHE
STRING
"Optionally specify the dependency installation directory relative to the source directory (default: inside dependency folder)"
)

set(
OPT_FLAGS
""
Expand Down Expand Up @@ -142,7 +151,7 @@ endif()

if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Common compilation flags and warning configuration
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wfatal-errors -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wfatal-errors -Wno-unused-variable")
if("${MULTICORE}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
endif()
Expand Down Expand Up @@ -195,13 +204,9 @@ else()
add_definitions(-DNO_PROCPS)
endif()

set(OPENSSL_ROOT_DIR /usr/local/opt/openssl/)
find_package(OpenSSL REQUIRED)

include_directories(
${DEPENDS_DIR}/libsnark
${DEPENDS_DIR}/libsnark/depends/libff
${DEPENDS_DIR}/libsnark/depends/libfqfft)


add_library(
ff
Expand All @@ -217,6 +222,14 @@ add_library(
${DEPENDS_DIR_LIBFF}/libff/common/utils.cpp
)

target_include_directories(ff PUBLIC
${DEPENDS_DIR_LIBSNARK} ${DEPENDS_DIR_LIBFF} ${DEPENDS_DIR_LIBFQFFT})
target_compile_features(ff PUBLIC cxx_std_11)

target_include_directories(ff INTERFACE
${DEPENDS_DIR_LIBSNARK} ${DEPENDS_DIR_LIBFF} ${DEPENDS_DIR_LIBFQFFT})
target_compile_features(ff INTERFACE cxx_std_11)

target_link_libraries(ff GMP::gmp ${PROCPS_LIBRARIES})

add_subdirectory(src)
77 changes: 23 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ PIP_ARGS ?= --user
PYTHON ?= python3
NAME ?= ethsnarks
NPM ?= npm

GANACHE ?= $(ROOT_DIR)/node_modules/.bin/ganache-cli
TRUFFLE ?= $(ROOT_DIR)/node_modules/.bin/truffle
COVERAGE = $(PYTHON) -mcoverage run --source=$(NAME) -p

PINOCCHIO = build/src/pinocchio/pinocchio
PINOCCHIO_TESTS=$(wildcard test/pinocchio/*.circuit)


#######################################################################


all: build/src/libmiximus.$(DLL_EXT) truffle-compile
all: node_modules build/src/verify truffle-compile

clean: coverage-clean python-clean
rm -rf build
Expand All @@ -41,12 +43,6 @@ clean: coverage-clean python-clean
build: depends/libsnarks/CMakeLists.txt
mkdir -p build

bin/miximus_genKeys: build/Makefile
make -C build

build/src/libmiximus.$(DLL_EXT): build/Makefile
make -C build

cmake-debug: build
cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..

Expand All @@ -57,6 +53,9 @@ release: cmake-release all

debug: cmake-debug all

build/src/verify: build/Makefile
make -C build

build/Makefile: build CMakeLists.txt
cd build && cmake ..

Expand All @@ -68,49 +67,23 @@ depends/libsnarks/CMakeLists.txt:


.PHONY: test
test: pinocchio-test cxx-tests python-test truffle-test
test: pinocchio-test cxx-tests hashpreimage-tests python-test truffle-test

python-test:
$(COVERAGE) -m unittest discover test/

cxx-tests-gadgets:
./bin/test_field_packing > /dev/null
./bin/test_hashpreimage
./bin/test_longsightl
./bin/test_longsightl_hash_mp
./bin/test_merkle_tree
./bin/test_one_of_n
./bin/test_r1cs_gg_ppzksnark_zok
./bin/test_shamir_poly
./bin/test_sha256_full_gadget
./bin/test_sha256_many > /dev/null
./bin/test_lookup_1bit
./bin/test_lookup_2bit
./bin/test_lookup_3bit
./bin/test_subadd > /dev/null
./bin/test_isnonzero
./bin/test_field2bits

cxx-tests-jubjub:
./bin/test_jubjub_add
./bin/test_jubjub_dbl
./bin/test_jubjub_mul
./bin/test_jubjub_mul_fixed
./bin/test_jubjub_mul_fixed_zcash
./bin/test_jubjub_point
./bin/test_jubjub_isoncurve > /dev/null
./bin/test_jubjub_hash
./bin/test_jubjub_eddsa

cxx-tests: zksnark_element/miximus.vk.json cxx-tests-gadgets cxx-tests-jubjub
time ./bin/hashpreimage_cli genkeys zksnark_element/hpi.pk.raw zksnark_element/hpi.vk.json
ls -lah zksnark_element/hpi.pk.raw
time ./bin/hashpreimage_cli prove zksnark_element/hpi.pk.raw 0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a089f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 zksnark_element/hpi.proof.json
time ./bin/hashpreimage_cli verify zksnark_element/hpi.vk.json zksnark_element/hpi.proof.json
time ./bin/test_load_proofkey zksnark_element/hpi.pk.raw

zksnark_element/miximus.vk.json:
time ./bin/miximus_cli genkeys zksnark_element/miximus.pk.raw zksnark_element/miximus.vk.json
cxx-tests:
make -C build test

.keys:
mkdir -p $@

hashpreimage-tests: .keys
time ./build/src/hashpreimage_cli genkeys .keys/hpi.pk.raw .keys/hpi.vk.json
ls -lah .keys/hpi.pk.raw
time ./build/src/hashpreimage_cli prove .keys/hpi.pk.raw 0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a089f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 .keys/hpi.proof.json
time ./build/src/hashpreimage_cli verify .keys/hpi.vk.json .keys/hpi.proof.json
time ./build/src/test/benchmark/benchmark_load_proofkey .keys/hpi.pk.raw


#######################################################################
Expand All @@ -122,8 +95,8 @@ pinocchio-test: $(addsuffix .result, $(basename $(PINOCCHIO_TESTS)))
pinocchio-clean:
rm -f test/pinocchio/*.result

test/pinocchio/%.result: test/pinocchio/%.circuit test/pinocchio/%.test test/pinocchio/%.input ./bin/pinocchio
./bin/pinocchio $< eval $(basename $<).input > $@
test/pinocchio/%.result: test/pinocchio/%.circuit test/pinocchio/%.test test/pinocchio/%.input $(PINOCCHIO)
$(PINOCCHIO) $< eval $(basename $<).input > $@
diff -ru $(basename $<).test $@ || rm $@


Expand Down Expand Up @@ -182,7 +155,7 @@ ubuntu-dependencies:
apt-get install cmake make g++ libgmp-dev libboost-all-dev libprocps-dev python3-pip

mac-dependencies:
brew install pkg-config boost cmake gmp openssl || true
brew install python3 pkg-config boost cmake gmp openssl || true


#######################################################################
Expand All @@ -202,12 +175,8 @@ nvm-install:
node_modules:
$(NPM) install

$(TRUFFLE): node_modules

$(GANACHE): node_modules

.PHONY: truffle-test
truffle-test: $(TRUFFLE) zksnark_element/miximus.vk.json
truffle-test: $(TRUFFLE)
$(NPM) run test

truffle-migrate: $(TRUFFLE)
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ EthSnarks is participating in the Ethereum Foundation's grants program Wave 4, o

## Examples

### Miximus

Miximus is a self-service coin mixer and anonymous transfer method for Ethereum, it accepts deposits of 1 ETH, then allows you to withdraw coins by providing a zkSNARK proof that proves you know the spend key for one unspent coin without revealing which one it is.

For more information, see:

* [Miximus.sol](contracts/Miximus.sol)
* [miximus.py](ethsnarks/mod/miximus.py)
* [test_miximus.py](test/test_miximus.py)
* [miximus.cpp](src/mod/miximus.cpp)

The zkSNARK prover is built as a native library which can plug-in to your application, when provided with the correct arguments it returns the zkSNARK proof as JSON. While you may think of zkSNARKs as being slow - the algorithms chosen for Miximus mean proofs can be made in 5 seconds, however we're still studying their security properties.
* [Miximus - a self-service coin mixer and anonymous transfer method for Ethereum](https://github.com/HarryR/ethsnarks-miximus)

## Building

[![Build Status](https://travis-ci.org/HarryR/ethsnarks.svg?branch=master)](https://travis-ci.org/HarryR/ethsnarks) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/137909bd889347728818d0aa5570fa9a)](https://www.codacy.com/project/HarryR/ethsnarks/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=HarryR/ethsnarks&amp;utm_campaign=Badge_Grade_Dashboard) [![BCH compliance](https://bettercodehub.com/edge/badge/HarryR/ethsnarks?branch=master)](https://bettercodehub.com/)
[![Build Status](https://travis-ci.org/HarryR/ethsnarks.svg?branch=master)](https://travis-ci.org/HarryR/ethsnarks) [![BCH compliance](https://bettercodehub.com/edge/badge/HarryR/ethsnarks?branch=master)](https://bettercodehub.com/)

Type `make` - the first time you run it will retrieve submodules, setup cmake and build everything, for more information about the build process see the [Travis-CI build logs](https://travis-ci.org/HarryR/ethsnarks).

Expand Down
90 changes: 0 additions & 90 deletions ethsnarks/mod/miximus.py

This file was deleted.

42 changes: 0 additions & 42 deletions migrations/2_deploy_contracts.js

This file was deleted.

Loading

0 comments on commit 967308c

Please sign in to comment.