Skip to content

Commit 83708be

Browse files
committed
Initial release of bace
0 parents  commit 83708be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2732
-0
lines changed

AUTHORS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SCIPR Lab:
2+
Alessandro Chiesa
3+
Howard Wu
4+
5+
External contributors:

CMakeLists.txt

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(bace)
4+
5+
option(
6+
MULTICORE
7+
"Enable parallelized execution, using OpenMP"
8+
OFF
9+
)
10+
11+
option(
12+
WITH_PROCPS
13+
"Use procps for memory profiling"
14+
ON
15+
)
16+
17+
set(
18+
OPT_FLAGS
19+
""
20+
CACHE
21+
STRING
22+
"Override C++ compiler optimization flags"
23+
)
24+
25+
option(
26+
VERBOSE
27+
"Print internal messages"
28+
OFF
29+
)
30+
31+
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
32+
# Common compilation flags and warning configuration
33+
set(
34+
CMAKE_CXX_FLAGS
35+
36+
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wfatal-errors -pthread"
37+
)
38+
39+
if("${MULTICORE}")
40+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
41+
endif()
42+
43+
# Default optimizations flags (to override, use -DOPT_FLAGS=...)
44+
if("${OPT_FLAGS}" STREQUAL "")
45+
set(
46+
OPT_FLAGS
47+
"-ggdb3 -O2 -march=native -mtune=native"
48+
)
49+
endif()
50+
endif()
51+
52+
if("${VERBOSE}")
53+
add_definitions(-DVERBOSE=1)
54+
endif()
55+
56+
if("${MULTICORE}")
57+
add_definitions(-DMULTICORE=1)
58+
endif()
59+
60+
set(
61+
CMAKE_CXX_FLAGS
62+
"${CMAKE_CXX_FLAGS} ${OPT_FLAGS}"
63+
)
64+
65+
include(FindPkgConfig)
66+
if("${WITH_PROCPS}")
67+
pkg_check_modules(
68+
PROCPS
69+
REQUIRED
70+
71+
libprocps
72+
)
73+
else()
74+
add_definitions(
75+
-DNO_PROCPS
76+
)
77+
endif()
78+
79+
# GMP
80+
find_path(GMP_INCLUDE_DIR NAMES gmp.h)
81+
find_library(GMP_LIBRARIES NAMES gmp libgmp)
82+
find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx)
83+
84+
# libfqfft
85+
find_path(LIBFQFFT_INCLUDE_DIR NAMES libfqfft)
86+
set(LIBFQFFT_DIRECTORY ${LIBFQFFT_INCLUDE_DIR}/libfqfft)
87+
include_directories(${LIBFQFFT_DIRECTORY})
88+
89+
# libff
90+
find_path(LIBFF_INCLUDE_DIR NAMES libff)
91+
include_directories(${LIBFF_INCLUDE_DIR}/libff)
92+
find_library(LIBFF_LIBRARIES NAMES ff libff)
93+
94+
enable_testing()
95+
96+
# Add a `make check` target that builds and tests
97+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
98+
99+
include_directories(.)
100+
add_subdirectory(src)

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
The bace library is developed by SCIPR Lab (http://scipr-lab.org)
2+
and contributors.
3+
4+
Copyright (c) 2016 SCIPR Lab and contributors (see AUTHORS file).
5+
6+
All files, with the exceptions below, are released under the MIT License:
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in
16+
all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
THE SOFTWARE.

README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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)

src/CMakeLists.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
include_directories(.)
2+
3+
# Profiling
4+
add_executable(
5+
profile
6+
7+
profiling/profile.cpp
8+
)
9+
target_link_libraries(
10+
profile
11+
12+
${LIBFF_LIBRARIES}
13+
${GMP_LIBRARIES}
14+
${GMPXX_LIBRARIES}
15+
${PROCPS_LIBRARIES}
16+
)
17+
set_target_properties(
18+
profile
19+
20+
PROPERTIES
21+
COMPILE_FLAGS "-fopenmp"
22+
LINK_FLAGS "-fopenmp"
23+
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}
24+
)
25+
target_compile_definitions(
26+
profile
27+
28+
PUBLIC
29+
-DMULTICORE
30+
)
31+
32+
# Tests
33+
add_executable(
34+
test_circuit
35+
EXCLUDE_FROM_ALL
36+
37+
test/test_circuit.cpp
38+
)
39+
target_link_libraries(
40+
test_circuit
41+
42+
${LIBFF_LIBRARIES}
43+
${GMP_LIBRARIES}
44+
${GMPXX_LIBRARIES}
45+
${PROCPS_LIBRARIES}
46+
)
47+
48+
add_executable(
49+
test_verifier
50+
EXCLUDE_FROM_ALL
51+
52+
test/test_verifier.cpp
53+
)
54+
target_link_libraries(
55+
test_verifier
56+
57+
${LIBFF_LIBRARIES}
58+
${GMP_LIBRARIES}
59+
${GMPXX_LIBRARIES}
60+
${PROCPS_LIBRARIES}
61+
)
62+
63+
include(CTest)
64+
add_test(
65+
NAME test_circuit
66+
COMMAND test_circuit
67+
)
68+
add_test(
69+
NAME test_verifier
70+
COMMAND test_verifier
71+
)
72+
73+
add_dependencies(check test_circuit)
74+
add_dependencies(check test_verifier)

0 commit comments

Comments
 (0)