Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/anthdm/hbbft

Practical implementation of the Honey Badger Byzantine Fault Tolerance consensus algorithm written in Go.
https://github.com/anthdm/hbbft

blockchain consensus-algorithm hbbft

Last synced: 2 months ago
JSON representation

Practical implementation of the Honey Badger Byzantine Fault Tolerance consensus algorithm written in Go.

Awesome Lists containing this project

README

        

# hbbft [![Releases](https://img.shields.io/github/tag/anthdm/hbbft.svg?style=flat)](https://github.com/anthdm/hbbft/releases) [![Build Status](https://circleci.com/gh/anthdm/hbbft/tree/master.svg?style=shield)](https://circleci.com/gh/anthdm/hbbft/tree/master) [![Report Card](https://goreportcard.com/badge/github.com/anthdm/hbbft)](https://goreportcard.com/report/github.com/anthdm/hbbft)

Practical implementation of the Honey Badger Byzantine Fault Tolerance consensus algorithm written in Go.

## Summary

This package includes the building blocks for implementing a practical version of the hbbft protocol. The exposed engine can be plugged easily into existing applications. Users can choose to use the transport layer or roll their own. For implementation details take a look at the simulations which implements hbbft into a realistic scenario. The building blocks of hbbft exist out of the following sub-protocols:

### Reliable broadcast (RBC)

Uses reedsolomon erasure encoding to disseminate an ecrypted set of transactions.

### Binary Byzantine Agreement (BBA)

Uses a common coin to agree that a majority of the participants have a consensus that RBC has completed.

### Asynchronous Common Subset (ACS)

Combines RBC and BBA to agree on a set of encrypted transactions.

### HoneyBadger

Top level HoneyBadger protocol that implements all the above sub(protocols) into a complete --production grade-- practical consensus engine.

## Usage

Install dependencies

```shell
make deps
```

Run tests

```shell
make test
```

### How to plug hbbft in to your existing setup

Create a new instance of HoneyBadger.

```golang
// Create a Config struct with your prefered settings.
cfg := hbbft.Config{
// The number of nodes in the network.
N: 4,
// Identifier of this node.
ID: 101,
// Identifiers of the participating nodes.
Nodes: uint64{67, 1, 99, 101},
// The prefered batch size. If BatchSize is empty, an ideal batch size will
// be choosen for you.
BatchSize: 100,
}

// Create a new instance of the HoneyBadger engine and pass in the config.
hb := hbbft.NewHoneyBadger(cfg)
```

Filling the engine with transactions. Hbbft uses an interface to make it compatible with all types of transactions, the only contract a transaction have to fullfill is the `Hash() []byte` method.

```golang
// Transaction is an interface that abstract the underlying data of the actual
// transaction. This allows package hbbft to be easily adopted by other
// applications.
type Transaction interface {
Hash() []byte
}

Adding new transactions can be done be calling the following method on the hb instance.
hb.AddTransaction(tx) // can be called in routines without any problem.
```

Starting the engine.

```golang
hb.Start() // will start proposing batches of transactions in the network.
```

Applications build on top of hbbft can decide when they access commited transactions. Once consumed the output will be reset.

```golang
hb.Outputs() // returns a map of commited transactions per epoch.

for epoch, tx := range hb.Outputs() {
fmt.Printf("batch for epoch %d: %v\n", epoch, tx)
}
```

>A working implementation can be found in the [bench folder](https://github.com/anthdm/hbbft/tree/master/bench), where hbbft is implemented over local transport.

## Current project state

- [x] Reliable Broadcast Algorithm
- [x] Binary Byzantine Agreement
- [x] Asynchronous Common Subset
- [x] HoneyBadger top level protocol

## TODO

- [ ] Threshold encryption
- [ ] Configurable serialization for transactions

## References

- [The Honey Badger BFT protocols](https://eprint.iacr.org/2016/199.pdf)
- [Practical Byzantine Fault Tolerance](http://pmg.csail.mit.edu/papers/osdi99.pdf)
- [Threshold encryption](https://en.wikipedia.org/wiki/Threshold_cryptosystem)
- [Shared secret](https://en.wikipedia.org/wiki/Shared_secret)

## Other language implementations

- [Rust](https://github.com/poanetwork/hbbft)
- [Erlang](https://github.com/helium/erlang-hbbft)