Commit Graph

50 Commits

Author SHA1 Message Date
c0gent 520083de2e Change license to MIT/Apache-2.0. 2018-10-04 23:32:14 -07:00
Marc Brinkmann 6f0b53436f
Fix test-case shrinking issues (#254)
* Use inverse of `is_bft` function for checking in `average_higher`.

* Inline in `NetworkDimension`.

* Check more invariants when averaging network sizes.

* Added test that finds shrinking regression of `NetworkDimension`.

* Use bijection for shrinking of network dimensions.

* Fix types on dimensions.

* Hide `size` and `faulty` behind accessor methods.

* Make limits dependant on input size.

* Fixed clippy lints.

* Simplify averaging.
2018-10-04 15:52:24 +02:00
Marc Brinkmann d2627272fe
Better proptest persistence through deterministic randomness. (#248)
* Add support for RNG instantiation in proptests.

* Use `proptest` module strategy to create the rng for `net_dynamic_honey_badger`.

* Use seed generation instead of RNG instantiation in tests.

* Remove fixed RNG in `generate_map`.

* `VirtualNet` now supports setting the random generator through the builder.

* Add missing `time_limit` field to `::std::fmt::Debug` trait implementation on `NetBuilder`.

* Pass an instantiated random number generator through `NewNodeInfo` as a convenience.

* Make the random number generator of `DynamicHoneyBadgerBuilder` configurable, at the cost of now requiring mutability to call `build_first_node()`.

* Ensure RNGs are derive from passed in seed in `net_dynamic_hb` tests.

* Correct inappropriate use of `random::Random` instead of `Rng::gen` to generate dependent values in `binary_agreement`.

The original implementation used `rand::random()`, which will always use the `thread_rng`, ignoring the fact that an RNG has actually been passed in.

* Do not use `OsRng` but passed in RNG instead.

* Use reference/non-reference passing of rngs more in line with the `rand` crates conventions.

* Document `rng` field on `DynamicHoneyBadger`.

* Make `SyncKeyGen` work with the extend (`encrypt_with_rng`) API of `threshold_crypto`.

* Use passed-in random number generator in `HoneyBadger`.

* Create `SubRng` crate in new `util` module to replace `create_rng()`.

* Use an RNG seeded from the configure RNG when reinitializing `DynamicHoneyBadger`.

* Use the correct branch of `threshold_crypto` with support for passing RNGs.
2018-10-02 16:24:51 +02:00
Andreas Fackler f743e4bc14 Update authors list. 2018-09-20 20:29:19 +02:00
Andreas Fackler 058044959f Remove itertools dependency. 2018-09-20 11:38:02 +02:00
Marc Brinkmann 23bc38bbeb Enable overflow-checks and fix a bug that slipped through during their absence. (#231)
* Fixed bug in `average_higher`, due to wrong assumptions about operator precendence.

* Enable overflow checks in `--release` tests.

This will hardly impact test performance, as the heavy lifting is done in the threshold crypto crate. Rough benchmarks showed significant differences only when `overflow-checks` was enable for `[profile.release]` (instead of `[profile.bench]`), causing it to be applied to `threshold_crypto` as well.
2018-09-13 12:03:12 +01:00
Marc Brinkmann 0266a4107c Network dimension strategy for property based tests. (#225)
* Added missing debug implementations for various test networking parts.

* Initial proptest parts added, including network dimensions.

* Use a test configuration for proptests.

* Tweaks and documentation.

* Improved documentation for `net_dynamic_hb` test.

* Added two missing `;`.

* Allow insane topology creation.

* Renamed `is_sane()` to `is_bft`, `halfway` to `average_higher` and improved comments per suggestions.

* Rename `NetworkTopology` -> `NetworkDimension`.

* Silence newly added clippy warning.

* Smoothed `README.md`.

* Remove workaround for beta/nightly again.

* Caved in to clippy and changed the bft condition.
2018-09-11 18:11:04 +01:00
DrPeterVanNostrand fb606332f6 Pinned threshold_crypto to version 0.1.0. 2018-08-30 10:52:16 -07:00
Andreas Fackler e4ddd6a079 Replace ring with tiny-keccak. 2018-08-10 09:23:27 +02:00
Andreas Fackler b90a7bf450 Replace merkle.rs with custom implementation. 2018-08-10 09:23:27 +02:00
Vladimir Komendantskiy 77ed1d50d4 separated crypto module into its own crate 2018-07-31 12:15:05 +01:00
Andreas Fackler 47c00016be Remove protobuf support. 2018-07-31 11:58:44 +02:00
c0gent 847a79793e
Replace `chain_error` with `failure`
Changes:

* Remove `error_chain` and convert errors to `failure` types.
* Add variants for each possible error generation point.
2018-07-30 15:14:19 -07:00
Andreas Fackler 9d0f1b3d15 Remove output and message queue from CommonSubset. 2018-07-24 13:12:06 +02:00
Peter van Nostrand 53a891380f Replaced clear-on-drop with 'std::ptr::write_volatile'. 2018-07-13 20:58:30 -04:00
Marc Brinkmann 5336fbe707 Added `RandomAdversary` and the necessary auxiliary functions.
Random adversaries are created for `broadcast` and `honey_badger`.  Random value generation was added for all type-dependencies of these algorithms, causing the `Rand` trait to be implement for a large portion of the codebase.

Additionally, `MessageWithSender` turned into an actual struct, making it much easier to handle. Tuple-like construction is still available through `MessageWithSender::new()`.
2018-07-13 13:27:49 +02:00
Andreas Fackler 64e5f49b8d Add more authors to Cargo.toml. 2018-07-09 16:11:13 +02:00
Andreas Fackler fe47291709 Add recommended metadata to Cargo.toml
The Rust API guidelines recommend a set of metadata values:
https://rust-lang-nursery.github.io/api-guidelines/documentation.html#c-metadata
2018-07-04 13:00:36 +02:00
Peter van Nostrand 05da712c20 Added clear-on-drop secret-keys to 'NetworkInfo'. 2018-06-21 12:08:48 -04:00
Andreas Fackler 83f8d61402 Support serde by default.
This removes the `serialization-serde` feature, since serde is already
used internally and therefore a dependency anyway.
2018-06-20 10:21:52 +02:00
Andreas Fackler 6cc2302e61 Implement polynomials for distributed key generation. 2018-06-11 16:45:08 +02:00
Andreas Fackler 015381c88c Print messages and total message size per node in simulation. 2018-05-31 17:22:30 +02:00
Andreas Fackler f970272d3e Add bandwidth and CPU to the simulation. 2018-05-31 14:28:10 +02:00
Andreas Fackler 56ab6a5037 Simplify hash_g2. 2018-05-29 21:59:21 +02:00
Andreas Fackler 527b1c8c17 Use SHA256 and byteorder in hash_g2. 2018-05-29 17:59:50 +02:00
Andreas Fackler d999792234 Implement threshold signatures. 2018-05-29 17:06:02 +02:00
Peter van Nostrand 465f17d9a5 Bumped reed-solomon-erasure crate version, fixed Protobuf error in example. 2018-05-20 19:39:47 -04:00
Peter van Nostrand 19b982284b Added error-chain error handling. 2018-05-20 07:51:33 -04:00
Andreas Fackler b8a2463d1c Extend tests and fix CommonSubset.
Verify termination and more outputs.

`CommonSubset` now instantiates `Agreement` with the correct ID.
2018-05-19 15:56:49 +02:00
Vladimir Komendantskiy fced73459e upgraded the protobuf dependency to fix a compile error 2018-05-18 22:45:18 +01:00
Andreas Fackler 50d007b954 Remove protoc dep, use new MerkleTree methods. 2018-05-17 16:50:47 +02:00
Andreas Fackler 500ec81b2f Add a network simulation example. 2018-05-17 12:52:07 +02:00
Andreas Fackler 4164af1702 Generalize TestNetwork and test HoneyBadger. 2018-05-16 16:21:30 +02:00
Andreas Fackler e2c66e9a0a Add optional serde support.
If the feature "serialization-serde" is specified, protocol messages
implement serde's `Serialize` and `Deserialize` traits.

Close #18
2018-05-14 18:32:59 +02:00
Andreas Fackler e8838f1491 Make protobuf support optional.
Protobuf support is now only built if the feature
"serialization-protobuf" is enabled.

Close #19
2018-05-14 17:29:04 +02:00
Andreas Fackler 0d005ebdc9 Fix build with protobuf 1.6.0.
Protobuf made backwards-incompatible changes but didn't increment the
major version, thus breaking the build.
2018-05-12 16:33:54 +02:00
Andreas Fackler 38cdd596a2 Start implementing the top-level Honey Badger algorithm.
This also contains a few fixes for the `common_subset` module:
* Rename `common_subset::Output` to `Message` to avoid confusing it
  with the value that the algorithm outputs as a result.
* Implement dispatch of messages to the right instance within
  `CommonSubset`, in a way that is transparent to the user.
2018-05-12 16:09:07 +02:00
Andreas Fackler 36183b1e27 Simplify the message types. 2018-05-10 17:52:12 +02:00
Vladimir Komendantskiy 49c33d2357 added a dev dependency on rand for CI 2018-05-10 12:10:42 +01:00
Vladimir Komendantskiy 51ef11b55c fixed the count of matching AUX messages 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy e0005a672b removed the separate field in Agreement and corrected computation of estimated values 2018-05-10 10:07:22 +01:00
Vladimir Komendantskiy 394462c88b changed code according to review comments 2018-05-10 10:07:22 +01:00
Andreas Fackler b98bbe9dcd Fix broadcast and example, enable more tests.
This fixes several issues with the broadcast algorithm and enables the
previously ignored tests that now pass:
* Don't decide on a root hash based on anyone's `Echo` message.
* Work around the `merkle` crate's inability to produce the proof of the
  `i`-th leaf for a given index `i`.
* Ignore messages from unknown nodes.
* Avoid decoding multiple times.
* Document the full algorithm.
* Don't count multiple `Echo` or `Ready` messages coming from the same
  node.
* Fix index computation for a given proof.
* Move `BroadcastMessage` into `broadcast` to make the module more
  self-contained.

The example now only executes a single broadcast instance, expecting the
first node (the one with the lexicographically lowest address) to
propose a value. A shell script is added that runs for example nodes.

Use env_logger instead of simple_logger, so the log level can be controlled
with an environment variable. You can e.g. log all output from the broadcast
test and the crate itself in debug mode with:
RUST_LOG=hbbft=debug,broadcast=debug

Some debugging messages are more concise now and use hexadecimal
notation instead of printing arrays of decimal values.

An indentation error in the Travis script is also fixed.
2018-05-08 17:04:38 +02:00
Vladimir Komendantskiy e9b0add188 removed redundant dependency on error_chain; corrected vector indices 2018-04-06 13:57:48 +01:00
Vladimir Komendantskiy 186a855d2f replaced lockable scoped channel variables with lock-free ones 2018-04-02 21:26:40 +01:00
Vladimir Komendantskiy 264b72011c added example of intended use of Node and a draft of value encryption 2018-03-27 21:59:38 +01:00
Vladimir Komendantskiy 1cdec3c39b broadcast algorithm drafted up to tree interpolation 2018-03-22 22:47:44 +00:00
Vladimir Komendantskiy fc475004f0 lifted the static requirement for messages by using scoped threads 2018-03-20 16:32:19 +00:00
Vladimir Komendantskiy c38aad2c0a Refactored the comms from the consensus node module
I reduced the socket IO tasks to mere message forwarders. The algorithm
complexity lies in stage modules. Example: broadcast/mod.rs. Communication is
set up and modules are run from the node module.

There is a problem with this commit. std:🧵:spawn imposes a static
lifetime guarantee on type T in Message<T>.
2018-03-19 17:12:20 +00:00
Vladimir Komendantskiy 5301123872 initial commit: elements of profobuf interface 2018-03-15 00:03:21 +00:00