|
| 1 | +<h1 align="center">Batch Arithmetic Circuit Evaluation (BACE)</h1> |
| 2 | + |
| 3 | +__BACE__ is a C++ library for evaluating arithmetic circuits on batches of inputs. |
| 4 | + |
| 5 | +The protocol is an efficient implementation of the Merlin-Arthur proof system presented in the paper "_Strong ETH Breaks With Merlin and Arthur: Short Non-Interactive Proofs of Batch Evaluation_" (Williams, CCC 2016). The paper can be found [here](https://arxiv.org/pdf/1601.04743v1) and slides can be found [here](http://computationalcomplexity.org/Archive/2016/slides/williams-ccc2016.pdf). The proof system consists of a single message from the (deterministic) prover to the (probabilistic) verifier; the statement being proved is about the correctness of evaluating an arithmetic circuit on a batch of inputs. |
| 6 | + |
| 7 | +The library is developed by [SCIPR Lab] and contributors (see [AUTHORS] file) and is released under the MIT License (see [LICENSE] file). Check out the [__Performance__](#performance) section for runtime data. |
| 8 | + |
| 9 | +## Table of contents |
| 10 | + |
| 11 | +- [Directory Structure](#directory-structure) |
| 12 | +- [Build guide](#build-guide) |
| 13 | +- [Testing](#testing) |
| 14 | +- [Profiling](#profiling) |
| 15 | +- [Performance](#performance) |
| 16 | + |
| 17 | +## Directory structure |
| 18 | + |
| 19 | +The directory structure is as follows: |
| 20 | + |
| 21 | +* [__src__](src): C++ source code, containing the following modules: |
| 22 | + * [__arithmetic\_circuit__](src/arithmetic_circuit): interface for arithmetic circuit |
| 23 | + * [__proof\_system__](src/proof_system): prover, verifier, and naive evaluation |
| 24 | + * [__profiling__](src/profiling): profile and plot runtimes |
| 25 | + * [__tests__](src/tests): collection of tests |
| 26 | + |
| 27 | +## Build guide |
| 28 | + |
| 29 | +The library has the following dependencies: |
| 30 | + |
| 31 | +* [CMake](http://cmake.org/) |
| 32 | +* [GMP](http://gmplib.org/) |
| 33 | +* [gnuplot](http://www.gnuplot.info/) |
| 34 | +* [libprocps](http://packages.ubuntu.com/trusty/libprocps3-dev) |
| 35 | +* [libff](https://github.com/scipr-lab/libff) |
| 36 | +* [libfqfft](https://github.com/scipr-lab/libfqfft) |
| 37 | + |
| 38 | +The library has been tested on Linux, but it is compatible with Windows and Mac OS X. |
| 39 | + |
| 40 | +### Installation |
| 41 | + |
| 42 | +On Ubuntu 14.04 LTS: |
| 43 | + |
| 44 | +``` |
| 45 | +sudo apt-get install build-essential git cmake gnuplot-x11 libgmp3-dev libprocps3-dev |
| 46 | +``` |
| 47 | + |
| 48 | +Then follow the build guide for [libff](https://github.com/scipr-lab/libff) and [libfqfft](https://github.com/scipr-lab/libfqfft). |
| 49 | + |
| 50 | +### Compilation |
| 51 | + |
| 52 | +To compile, starting at the project root directory and setup the `build` directory: |
| 53 | + |
| 54 | +``` |
| 55 | +mkdir build && cd build && cmake .. |
| 56 | +``` |
| 57 | + |
| 58 | +Then, to compile the library and profiler, run: |
| 59 | + |
| 60 | +``` |
| 61 | +make |
| 62 | +``` |
| 63 | + |
| 64 | +The above makes the `build` folder and compiles the profiler to the project root directory. To remove all executables, from the build folder, run `make clean`. |
| 65 | + |
| 66 | +#### Options |
| 67 | + |
| 68 | +The following flags change the behavior of the compiled code: |
| 69 | + |
| 70 | +* `cmake .. -DMULTICORE=ON` |
| 71 | +Enables parallelized execution using OpenMP. This will utilize all cores on the CPU for heavyweight parallelizable operations such as FFT. |
| 72 | + |
| 73 | +* `cmake .. -DOPT_FLAGS={ FLAGS }` |
| 74 | +Passes specified optimizations flags to compiler. |
| 75 | + |
| 76 | +* `cmake .. -PROF_DOUBLE=ON` |
| 77 | +Enables profiling with Double (default: ON). If the flag is turned off, profiling will use `Fr<alt_bn128_pp>`. |
| 78 | + |
| 79 | +## Testing |
| 80 | + |
| 81 | +This library includes unit tests that cover arithmetic circuit, prover, and verifier evaluation. The test suite is easily extensible to support a wide range of fields and domain sizes. To run the tests for this library, after [Compilation](#compilation), run: |
| 82 | + |
| 83 | +``` |
| 84 | +make check |
| 85 | +``` |
| 86 | + |
| 87 | +## Profiling |
| 88 | + |
| 89 | +The library profiles runtimes with multi-threading support, and plots the resulting data using [gnuplot](http://www.gnuplot.info/). All profiling and plotting activity is logged under `src/profiling/logs`; logs are sorted into a directory hierarchy by timestamp. |
| 90 | + |
| 91 | +After [Compilation](#compilation), start the profiler by running ```./profile``` from the project root directory. The profiler logs runtimes for the naive evaluation, prover, and verifier, across varying batch and input sizes. Then, it plots graphs comparing naive evaluation with the verifier, naive evaluation with the prover, and runtimes across threads for the naive evaluation, prover, and verifier. Profiling results and plots are saved under ```src/profiling/logs/{datetime}```. |
| 92 | + |
| 93 | +## Performance |
| 94 | + |
| 95 | +__Machine Specification:__ The following benchmark data was obtained on a 64-bit Intel i7 Quad-Core machine with 16GB RAM (2x8GB) running Ubuntu 14.04 LTS. The code is compiled using g++ 4.8.4. |
| 96 | + |
| 97 | +``` |
| 98 | +Architecture: x86_64 |
| 99 | +CPU op-mode(s): 32-bit, 64-bit |
| 100 | +Byte Order: Little Endian |
| 101 | +CPU(s): 8 |
| 102 | +On-line CPU(s) list: 0-7 |
| 103 | +Thread(s) per core: 1 |
| 104 | +Core(s) per socket: 2 |
| 105 | +Socket(s): 4 |
| 106 | +NUMA node(s): 1 |
| 107 | +Vendor ID: GenuineIntel |
| 108 | +CPU family: 6 |
| 109 | +Model: 94 |
| 110 | +Stepping: 3 |
| 111 | +CPU MHz: 4008.007 |
| 112 | +BogoMIPS: 8016.01 |
| 113 | +Virtualization: VT-x |
| 114 | +L1d cache: 32K |
| 115 | +L1i cache: 32K |
| 116 | +L2 cache: 256K |
| 117 | +L3 cache: 8192K |
| 118 | +NUMA node0 CPU(s): 0-7 |
| 119 | +``` |
| 120 | + |
| 121 | +### Runtime |
| 122 | + |
| 123 | +These runtime benchmarks are determined by constructing an arithmetic circuit of degree 3 using quadratic inner product gates. For every batch size, the input size is varied by powers of two to determine the threshold values for which the verifier's evaluation becomes more cost effective than performing the naive evaluation. |
| 124 | + |
| 125 | +<p align="center"><img src="https://cloud.githubusercontent.com/assets/9260812/17748214/24e61f30-646d-11e6-8c41-5dff1a858e04.png" width="50%"><img src="https://cloud.githubusercontent.com/assets/9260812/17748213/24c6bcbc-646d-11e6-8e52-3da658dda4ad.png" width="50%"></p> |
| 126 | + |
| 127 | +The left graph compares the runtime cost of naive evaluation with the prover's cost of constructing a proof for the verifier. The right graph compares runtime cost of naive evaluation with the verifier's cost of performing a probabilistic check and evaluation from the proof. |
| 128 | + |
| 129 | +[SCIPR Lab]: http://www.scipr-lab.org/ (Succinct Computational Integrity and Privacy Research Lab) |
| 130 | + |
| 131 | +[LICENSE]: LICENSE (LICENSE file in top directory of bace distribution) |
| 132 | + |
| 133 | +[AUTHORS]: AUTHORS (AUTHORS file in top directory of bace distribution) |
0 commit comments