(forked from https://github.com/scipr-lab/libff)
libff is a C++ library for finite fields and elliptic curves. The library is developed by SCIPR Lab and contributors (see AUTHORS file) and is released under the MIT License (see LICENSE file).
The directory structure is as follows:
The libff library currently provides the following options:
-
edwards
: an instantiation based on an Edwards curve, providing 80 bits of security. -
bn128
: an instantiation based on a Barreto-Naehrig curve, providing 128 bits of security. The underlying curve implementation is [ate-pairing], which has incorporated our patch that changes the BN curve to one suitable for SNARK applications.-
This implementation uses dynamically-generated machine code for the curve arithmetic. Some modern systems disallow execution of code on the heap, and will thus block this implementation.
For example, on Fedora 20 at its default settings, you will get the error
zmInit ERR:can't protect
when running this code. To solve this, runsudo setsebool -P allow_execheap 1
to allow execution, or usemake CURVE=ALT_BN128
instead.
-
-
alt_bn128
: an alternative tobn128
, somewhat slower but avoids dynamic code generation. -
mnt
: An implementation of the MNT cycle (MNT4-MNT6) with small fields. -
bls12-377
: An implementation of the BLS12_377 curve as introduced in the Zexe paper. -
bw6_761
: An implementation of the BW6_761 curve as introduced in Optimized and secure pairing-friendly elliptic curves suitable for one layer proof composition
Note that bn128
requires an x86-64 CPU while the other curve choices
should be architecture-independent.
The library has the following dependencies:
Furthermore, Doxygen is used to generate the documentation.
The library has been tested on Linux, but it is compatible with Windows and Mac OS X.
On Ubuntu 20.04 LTS:
sudo apt update -y
sudo apt install \
build-essential \
git \
libboost-all-dev \
cmake \
libgmp3-dev \
libssl-dev \
libprocps-dev \
pkg-config
Note: To install Doxygen, run sudo apt install doxygen graphviz
.
Fetch dependencies from their GitHub repos:
git submodule init && git submodule update
To compile, starting at the project root directory, create the build directory and Makefile:
mkdir build && cd build && cmake ..
Optionally, you can specify the install location by providing the desired install path prefix:
cmake .. -DCMAKE_INSTALL_PREFIX=/install/path
Then, to compile and install the library, run this within the build directory:
make
make install
This will install libff.a
into /install/path/lib
; so your application should be linked using -L/install/path/lib -lff
. It also installs the requisite headers into /install/path/include
; so your application should be compiled using -I/install/path/include
.
To execute the tests for this library, run:
make check
To generate the documentation, run:
cd build
cmake .. -DGEN_DOC=ON && make docs
To compile the multi-exponentiation profiler in this library, run:
make profile
The resulting profiler is named multiexp_profile
and can be found in the libff
folder under the build directory.