Commit Graph

57 Commits

Author SHA1 Message Date
Andreas Fackler 0e50c2f473 Remove non-threshold keys from NetworkInfo. 2019-08-27 20:51:24 +02:00
Andreas Fackler 8122a10179 Add HoneyBadger::skip_to_epoch. 2019-07-23 13:30:02 +02:00
Vladimir Komendantskiy 10dbf705e4 using serde derive feature 2019-04-02 12:42:51 +02:00
Andreas Fackler 87b1d45d97 Rename DistAlgorithm to ConsensusProtocol. 2019-01-08 14:14:34 +01:00
phahulin 5bfcd6c692 Split FaultKind. (#371) 2019-01-02 13:55:50 +03:00
Andreas Fackler 108ac574bb Migrate to rand 0.6. (#368)
* Migrate to rand 0.6.

* Prefer SliceRandom where it makes sense.
2018-12-27 10:34:34 +01:00
Andreas Fackler 7677f6343c Remove unwrap and expect calls from production code. 2018-12-17 15:38:18 +01:00
Marc Brinkmann eafa77d5fc OsRng / external RNG Refactoring (#357)
* Use `OsRng` in place of `thread_rng`.

This changes the defaults of any builder by instantiating an `OsRng` instead of
a `thread_rng`, the former being much more secure than the latter.

Additionally, all the unit tests that still instantiate RNGs manually used `OsRng`s
as well; while there is no actual need for this level of security in tests, the performance overhead is very small and random number generation complexity has such a small impact on these tests that the convenience of being able to ban `thread_rng` from the codebase altogether, setting a good example and avoid issues when refactoring later greatly outweigh the negatives.

* Instead of storing random number generators in the various consensus algorithm instances, pass them in from the outside whenever they are needed.

This changes a large amount of interfaces (and in this commit is only partially done, since `DistAlgorithm` needs to be fundamentally altered as well.

It also obsoletes parts of the `util` module.

* Added an `R: Rng` type parameter to both methods of `DistAlgorithm`, forcing callers to pass in their own Rngs.

* Fixed documentation grammar and spelling in some of the altered interfaces due to RNG refactoring.

* Move `rng` argument to the end of the argument for most functions.

Also includes a reformatting due to Rust 1.30.

* Updated tests, accomodate `rng`-API changes.

* Fixed remaining compilation issues with new RNG code.

* Fix illegal `self` import outside curly braces.

* Cleaned up comments and fixed broken definition of `broadcast_input`.

* Updated existing test cases to properly work with static dispatch randomness.

* Do not use boxed `Rng`s for key generation in test networks.

* Use the passed-in `Rng` in `ReorderingAdversary`, instead of storing a boxed one.

* Fixed clippy lints after refactoring.

* Removed some no-longer necessary manual `fmt::Debug` implementations in test framework.

* Use `OsRng` even in tests in `binary_agreement_mitm`.

* Use a proper deterministic RNG in tests `binary_agreement_mitm`.

* Refactor `examples/simulation.rs` by not using `ThreadRng`, passing generic `Rng` parameters throughout and using a type alias instead of a newtype as the `Transaction`.

* Remove `thread_rng` use from `examples/node.rs`.

* Explicitly construct `InternalContrib` in `DynamicHoneyBadger::propose`.

* Fixed typo in description of `DistAlgorithm` trait.
2018-12-14 12:51:09 +00:00
Demi Marie Obenour 7fb172cda2 Switch to 2018 edition idioms (#359)
* Switch to 2018 edition idioms

* Fix build with Rust 2018.

* Remove unnecessary cloning, make `max_faulty` const.

* Remove unneeded `extern crate` statements.
2018-12-11 14:44:36 +01:00
Andreas Fackler ceb416a6e1 Make received_proposals public.
We are going to need this if we use `HoneyBadger` directly, to replace
`DynamicHoneyBadger::should_propose`.
2018-12-03 17:51:49 +01:00
Andreas Fackler b2071fe2be Extend the documentation, simplify errors.
This changes and adds several doc comments, adds the `missing_docs` lint
and simplifies some of the error types.
2018-11-27 12:25:50 +01:00
Andreas Fackler ae37879239 Remove the random_value option. 2018-11-22 13:07:58 +01:00
Andreas Fackler c2a76add5d Include the full Params in JoinPlan.
This ensures that a new node runs with exactly the same parameters as
the rest of the network.
2018-11-21 10:28:56 +01:00
Andreas Fackler 9049dd1793 Add a `Params` struct with HB parameters.
This removes some duplication between DHB, HB and their builders.
2018-11-19 14:01:46 +01:00
Andreas Fackler c94e3ff16f Add epoch getters to JoinPlan, HB, DHB and QHB. 2018-11-18 10:48:38 +01:00
Andreas Fackler 30cce9bed8 Add a random_value option to HB and DHB.
This includes a threshold signature in each batch that can be used as a
pseudorandom value.

Also moves `EncryptionSchedule` from `threshold_decrypt` to
`honey_badger`.
2018-11-12 14:16:21 +01:00
Andreas Fackler d0b96f2dc8 Simplify the sender queue.
Remove the distinction between linearized and regular epochs.
Avoid iterating through the whole outgoing queue on epoch change.
2018-11-08 13:14:43 +01:00
Andreas Fackler 7f784e7852 Make Step independent of DistAlgorithm. 2018-11-08 08:51:17 +01:00
Andrew Lyjak 9a8836cf15 Rename `ThresholdDecryption` to `ThresholdDecrypt` 2018-11-07 11:13:10 -05:00
Vladimir Komendantskiy f02bbbb9da Updated documentation and removed a debug print 2018-11-05 14:25:59 +00:00
Vladimir Komendantskiy 3deb5f1bce refactored an error! by adding linearizable epochs and wrote a comment on eras 2018-11-05 11:11:00 +00:00
Vladimir Komendantskiy ee46dd4b81 sender queue implementation 2018-11-05 11:11:00 +00:00
Logan Collins dcbc065388 clippy and fmt 2018-10-31 01:27:28 -05:00
Logan Collins ad5f725b2e
Merge branch 'master' into optional_threshold_encryption_209 2018-10-31 01:09:35 -05:00
Andreas Fackler df36258715 Instead of macro_use, use use. 2018-10-30 08:11:03 +01:00
Andreas Fackler c011ef49c5 Make the BA session ID generic. 2018-10-29 09:28:09 +01:00
Logan Collins 3ffb1ba48a merge changed step mutability requirements 2018-10-25 14:11:44 -05:00
Logan Collins 00985edc46
Merge branch 'master' into optional_threshold_encryption_209 2018-10-25 13:41:56 -05:00
Logan Collins 6b101ca3be skip InProgress state for non-KG changes, revert change to comment, push serialization inside epoch_state, skip threshold_decryption Step, use getter instead of pub(crate) for honey_badger.encryption_schedule 2018-10-25 13:38:16 -05:00
Andreas Fackler dda2f54a06
Minor improvements to the Step API. (#292)
* Minor improvements to the Step API.

* Make use of DistAlgorithm::our_id.

* Rename Step::and to join.
2018-10-25 14:44:28 +02:00
Logan Collins 92a32d827d merge from upstream 2018-10-24 15:55:44 -05:00
Logan Collins 982619327b formatting, address pr review concerns, move encryption into epoch_state, turn off borrowed box lint 2018-10-24 15:46:44 -05:00
Andreas Fackler 3981b37fa3 Minor API and documentation improvements. 2018-10-24 17:38:41 +02:00
Andreas Fackler 493b946a4a Use DeserializeOwned where applicable. 2018-10-24 15:03:56 +02:00
Andreas Fackler 6375decbc0 Use derivative for configurable Debug impls. (#283) 2018-10-24 13:01:52 +02:00
Logan Collins 85910d8d43 refactor change and make it possible for encryption to be optional 2018-10-23 23:21:59 -05:00
Logan Collins fabd725851 semi sure of these changes, also a bit WIP 2018-10-21 15:47:44 -05:00
Logan Collins 813a76bb5f add configuration options for optional/periodic encryption scheduling 2018-10-17 12:27:00 -05:00
Andreas Fackler 8d1361e6ae Split up messaging module. 2018-10-10 17:29:59 +02:00
Vladimir Komendantskiy 326616e3b8 Fixed a condition for accepting HB messages in future epochs (#261)
* fixed a condition for accepting HB messages

* corrected the condition
2018-10-10 12:43:23 +02:00
Vladimir Komendantskiy af05c44659 Revert "Spam protection part 1: remote epoch tracking in HoneyBadger (#219)"
This reverts commit b649dc6268.
2018-10-10 11:31:50 +02:00
c0gent 9d3e264b4f Add `Sync` req. on boxed rngs. 2018-10-04 11:42:00 -07:00
Marc Brinkmann 4b00bda555 Make `DistAlgorithm` require `Send`.
Using `hbbft` in other software that is based on frameworks like [tokio](https://tokio.rs), being `Send` is often a requirement on shared data structures.
2018-10-04 17:52:57 +02:00
Erich Gubler 13162a2e64 Fix #243: Make Subset optimization optional. 2018-10-03 09:07:20 -06: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
Vladimir Komendantskiy b649dc6268
Spam protection part 1: remote epoch tracking in HoneyBadger (#219)
* spam protection part 1: remote epoch tracking in HoneyBadger

* moved handling of EpochStarted out of EpochState

* allowed EpochStarted from observers

* removed an unnecessary function call

* updated formatting to beta

* removed an unnecessary variable
2018-09-03 11:29:03 +01:00
Andreas Fackler 7276621397 Rename uid to id. 2018-08-29 19:35:52 +02:00
Andreas Fackler f27eed4eef Rename input to handle_input.
Also update `.gitignore` to avoid checking in test logs.
2018-08-29 19:35:52 +02:00
Andreas Fackler d93ea7b561 Rename CommonSubset to Subset. 2018-08-22 16:20:09 -07:00
Andreas Fackler e9b960d020 Fix and clean up the HoneyBadger impl.
* Remove unnecessary recursive method calls.
* Add `handle_message` (without the trait).
* Fix a bug where `handle_message_content` would create an `EpochState`
  with the wrong number.
2018-08-09 16:04:09 +02:00