skalenetwork / libBLS

Solidity-compatible BLS signatures, threshold encryption, distributed key generation library in modern C++. Actively maintained and used by SKALE for consensus, distributed random number gen, inter-chain communication and protection of transactions. BLS threshold signatures can be verified in Solidity, and used as random beacon (common coin)

Home Page:https://skale.space

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

libBLS: a C++ library for BLS Threshold Signatures

Build and test libBLS codecov CII Best Practices Discord

A mathematical library written in C++ that supports BLS threshold signatures, Distributed Key Generation (DKG) and Threshold Encryption (TE).

This libBLS library is developed by SKALE Labs and uses SCIPR-LAB's libff (see Libraries below).

An important note about production readiness

This libBLS library is still in active development and therefore should be regarded as alpha software. The development is still subject to security hardening, further testing, and breaking changes. This library has not yet been reviewed or audited for security. Please see SECURITY.md for reporting policies.

Overview

libBLS is a C++ library for BLS signatures and DKG that supports both threshold signatures and multi-signatures. Also it supports Threshold Encryption.

The signature process proceeds in 4 steps:

  1. Key generation
  2. Hashing
  3. Signing
  4. Verification

libBLS uses the alt_bn128 (Barreto-Naehrig curve) elliptic curve to be compatible with Ethereum's cryptography and provides 128 bits of security. Also, it provides opportunity to generate secret keys with DKG algorithm that supports the same curve.

libBLS for the most part corresponds to BLS signature standard. This work is still in progress and is going to be improved in the next couple of months.

Encryption process is running as follows:

  1. Key generation
  2. Encryption
  3. Decryption
  4. Verifying and combining shares

libBls uses the same alt_bn128 curve for threshold encryption as for BLS signatures.

Performance Specifications

libBLS allows to sign about 3000 messages per second on a single thread (Intel® Core™ i3-4160 CPU @ 3.60GHz). However, for our solution we have implemented constant time signing (0.01 sec for sign) to avoid timing attacks.

Installation Requirements

libBLS has been built and tested on Ubuntu and Mac.

GitHub is used to maintain this source code. Clone this repository by:

git clone https://github.com/skalenetwork/libBLS.git
cd libBLS

Building Dependencies

Ensure that required packages listed below are installed.

Build libBLS's dependencies by:

cd deps
bash ./build.sh
cd ..

Building from source on Mac

brew install flex bison libtool automake cmake pkg-config yasm
# Configure the project and create a build directory.
cmake -H. -Bbuild

# Build all default targets using all cores.
cmake --build build -- -j$(sysctl -n hw.ncpu)

Building from source on Ubuntu

Ensure that the required packages are installed by executing:

sudo apt-get update
sudo apt-get install -y automake cmake build-essential libprocps-dev libtool\
                        pkg-config yasm texinfo autoconf flex bison clang-format-6.0

Configure the project build with the following commands.

# Configure the project and create a build directory.
cmake -H. -Bbuild

# Build all default targets using all cores.
cmake --build build -- -j$(nproc)

Include the library

#include <libBLS.h>

Documentation

See docs for libBLS documentation.

Libraries

Contributing

If you have any questions please ask the development community on Discord.

Discord

Otherwise see our CONTRIBUTING.md for more information.

License

License

Copyright (C) 2018-present SKALE Labs

About

Solidity-compatible BLS signatures, threshold encryption, distributed key generation library in modern C++. Actively maintained and used by SKALE for consensus, distributed random number gen, inter-chain communication and protection of transactions. BLS threshold signatures can be verified in Solidity, and used as random beacon (common coin)

https://skale.space

License:GNU Affero General Public License v3.0


Languages

Language:C++ 90.5%Language:CMake 5.2%Language:Python 1.9%Language:Shell 1.1%Language:Sage 1.1%Language:C 0.3%