poanetwork / hbbft

An implementation of the paper "Honey Badger of BFT Protocols" in Rust. This is a modular library of consensus.
Other
357 stars 96 forks source link

Add mock cryptography for tests. #205

Closed afck closed 6 years ago

afck commented 6 years ago

The tests spend most of their time doing cryptography. We should add (via a feature flag?) mock crypto primitives so that we can test more different message flows and scenarios in a reasonable amount of time.

mbr commented 6 years ago

Here's the current plan of attack: We want to replace the underlying groups (G1, G2) of the pairing based crypto with those that are cheaper to operate, only preserving "accidental collision resistance". Any attacker will be able to trivially break our new crypto-system, but we still expect no collisions or valid signatures when generating things randomly or performing trivial replay attacks.

Currently, the plan is to choose G_1 = G_2 = (F_p, +), with F_p being the finite field of order p, p being prime and e : (G_1, G_2) -> G_T defined as e(q, p) := q * p. This should vastly speed-up test-cases and allow focusing on attacks on the protocol instead of the underlying cryptography.

To implement this, we add type aliases for the types from pairing currently used, possibly using associated types again. A feature flag that disables cryptography/enables mocktography by changing the definition of the type alias should be added to threshold_crypto and hbbft. Optionally, it should add a prominent warning if it is enabled.

afck commented 6 years ago

As discussed, let's:

afck commented 6 years ago

This was merged in #268.