Commit Graph

211 Commits

Author SHA1 Message Date
Logan Collins e3a168a96c
Merge branch 'master' into optional_threshold_encryption_209 2018-10-27 18:11:19 -05:00
Logan Collins a91e38e3c5 fmt change + don't skip InProgress for NodeChange 2018-10-27 17:44:08 -05:00
Vladimir Komendantskiy 45ce045922 allow the observer on a TestNetwork to send messages 2018-10-27 10:42:49 +02:00
Logan Collins 00985edc46
Merge branch 'master' into optional_threshold_encryption_209 2018-10-25 13:41:56 -05:00
Andreas Fackler f27af31ac7 Improve SyncKeyGen error handling. 2018-10-25 17:22:16 +02: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 877903aeac apparently nightly and stable cargo fmt have different opinions 2018-10-24 00:23:09 -05:00
Logan Collins 212d9b57b8 run cargo fmt 2018-10-24 00:18:18 -05:00
Logan Collins 40e611c824 merge from upstream 2018-10-23 23:54:54 -05:00
Logan Collins 85910d8d43 refactor change and make it possible for encryption to be optional 2018-10-23 23:21:59 -05:00
Andreas Fackler 6bcd6bc499 Replace Coin with ThresholdSign. (#280)
* Avoid redundant hashing in Coin.

* Return the full signature from Coin.

* Rename Coin to ThresholdSign.
2018-10-23 10:49:19 +01:00
Andreas Fackler 36583de455 Add fault checks to the tests.
The `network` test module now verifies that correct nodes are never
reported as faulty.

The `DuplicateAck` fault is removed for now, because the same ack is
usually handled multiple times in DHB.
2018-10-22 17:23:03 +02:00
Marc Brinkmann ba2390191f Changed the defaults for tracing to `false`. (#277)
* Changed the defaults for tracing to `false`.

* Cleanup envvar handling.

* Update `README.md`.
2018-10-18 16:13:02 +02:00
Vladimir Komendantskiy 59444fcf7b Support a global RNG in transaction queue (#257)
* adds an RNG argument to the transaction queue

* minimal support of transaction queue RNG in tests

* added the TransactionQueue trait object

* review comments and streamlining of trait bounds

* removed the RNG from the transaction Q and placed it into QueueingHoneyBadger

* formatting fix
2018-10-11 15:33:03 +02:00
Andreas Fackler 8d1361e6ae Split up messaging module. 2018-10-10 17:29:59 +02:00
Andreas Fackler 4cc35587c7 Add `NetworkInfo` to `Batch`.
Instead of just the public key, the batches returned from
`DynamicHoneyBadger` and `QueueingHoneyBadger` now contain the full
`NetworkInfo`, so the user can use the validators' keys for signing and
encryption.
2018-10-10 16:38:41 +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
Andreas Fackler 7002dad54c Remove unused pairing import.
Also use the new `Iterator::flatten`.
2018-10-09 11:53:20 +02: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
Demi Marie Obenour 679f5784b9 Output Subset messages as received (#233)
* Outputing subset messages as received

This outputs subset messages as they are received.  All tests pass.

* Fix test suite, while still outputing results early

This fixes the test suite, while still outputting results early.

* Actually do the optimization

There is a testsuite failure in the `dynamic_honey_badger` tests.  Is
this a testsuite bug?

* Respond to code review

* Document the meaning of `None` in Subset::broadcast_results

* Fix adding Contributions and fault check

* Fix clippy

* Keep track of nodes that have sent us valid messages

Otherwise, we reject all nodes as faulty.

* Remove excessive debug logging

There is no need to log a quadratic amount of data.

* Re-add check that the observer’s values match

the rest of the nodes.  Also `panic!` if `Done` is ever not the last
value in a series of `SubsetOutput`s.

* Respond to review

* Rename field
2018-09-20 14:34:40 +02:00
Marc Brinkmann f38b24de2d Change the time limit to five minutes for now, until the CI situation is resolved. 2018-09-17 20:09:16 +02:00
Marc Brinkmann 900ba76e90 Disable beta, use `stable` channel. (#235)
* Disable beta, use `stable` channel.

* Pin to Rust 1.29 stable.

* Streamline clippy operation.

* Fix or disable remaining failing clippy lints.

* Use `$TRAVIS_RUST_VERSION` instead of `stable` to name toolchain.
2018-09-17 14:19:20 +01:00
Marc Brinkmann 422d8ef55b Add a test time limit. (#232)
* Added a default time limit to `NetBuilder`.

* Added environment-variable override via `HBBFT_NO_TIME_LIMIT`.

* Check for time limit exceeded when cranking.

* Fix typos and factual errors in API docs.

* Document time limit setting in tests `README.md`.
2018-09-13 15:19:22 +01: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
Marc Brinkmann 3b6dfcbfc1
Adversary traits (#223)
Added a new adversary API, which changes how adversaries in tests can affect the network and nodes, restricting them to the capabilities listed in the HBBFT paper.
2018-09-04 14:50:15 +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
Marc Brinkmann fc3d578eea
Advance to Rust beta (#221)
Update Rust version to `beta` in CI, paving the way for 1.29 stable.
2018-08-31 15:57:10 +02:00
Andreas Fackler 383d96fdee Rename Agreement to BinaryAgreement. 2018-08-30 11:19:52 +02: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
Marc Brinkmann 85550fcf82
New test network implementation (#216)
Added new virtual network implementation for tests.

Added `net::VirtualNet` as an upcoming replacement for the current networking implementation in the test, along with auxiliary functions. The new system allows easier manipulation through implemented adversaries, better reporting and should offer a more friendly API.

Documentation for the functionality can be found in `tests/README.md`.
2018-08-29 10:09:35 +02:00
Andreas Fackler 51315a56c3 Update docs: missing algorithms, private merkle, whitespace.
* Make the `merkle` module private.
* Make sure the algorithm names are consistent.
* Add the Threshold Decryption and Synchronous Key Generation algorithms
  to the list in the main crate documentation.
* Remove some trailing whitespace from the README.
* Remove checkboxes: all algorithms are implemented.
* Link to the algorithm implementations, not the modules.
* Use relative links in the README.
2018-08-27 17:07:33 +02:00
Andreas Fackler d93ea7b561 Rename CommonSubset to Subset. 2018-08-22 16:20:09 -07:00
Andreas Fackler 6bcf365cf8 Rename CommonCoin to Coin. 2018-08-22 16:20:09 -07:00
Andreas Fackler f7d4860a94 Fix DHB test: wait for lagging nodes.
The Dynamic Honey Badger tests would currently fail _without_ faulty
nodes, because with "first" delivery, all but the first _N - f_ nodes
are lagging indefinitely.

This change makes sure we give lagging nodes a chance to finish the first
phase of the test and arrive at the batch containing the completed
`Remove` event.
2018-08-14 12:08:34 +02:00
DrPeterVanNostrand 8ab58d35d4 Added error handling for mlock errors in threshold_crypto crate. 2018-08-09 15:44:36 -04:00
Andreas Fackler 5cc7b54c06 Split up the broadcast module.
Also, rename broadcast and agreement messages to just `Message`.
2018-08-08 15:46:43 +02:00
Andreas Fackler 46a8728792 Split out Threshold Decryption from Honey Badger. 2018-08-06 10:50:30 -07:00
Nick Sanders c5977d1ab8
Revert "Reorganize `dynamic_honey_badger` and `agreement` modules slightly." 2018-08-02 12:24:25 -07:00
c0gent 7824b7a0ea
Reorganize `dynamic_honey_badger` and `agreement` modules slightly.
* Move `CoinState` and `Agreement` definitions from `agreement/mod.rs`
  to `.../agreement.rs`.
* Move `DynamicHoneyBadger` definition from `dynamic_honey_badger/mod.rs`
  to `.../dynamic_honey_badger.rs`.
2018-08-02 11:24:15 -07:00
Andreas Fackler eeb519862f Simplify Honey Badger tests and example. 2018-08-01 18:52:32 +02:00
Vladimir Komendantskiy 77ed1d50d4 separated crypto module into its own crate 2018-07-31 12:15:05 +01:00
Andreas Fackler 984bb49fdc Accept more types in threshold crypto API.
This removes some unnecessary allocation and conversion by accepting
more primitive types and references as the index in threshold decryption
and signing, and as the argument to a polynomial.
2018-07-23 15:56:45 +02:00
Andreas Fackler 432c865d4b Handle initial QHB messages, fix DHB. 2018-07-21 11:30:43 +02:00
Vladimir Komendantskiy 65b3097238 message queue refactoring WIP 2018-07-20 12:43:15 +01:00
Andreas Fackler d787173dd8 Rename DKG messages to Part and Ack. 2018-07-19 12:28:15 +02:00
Andreas Fackler 9159b42150 Add SyncKeyGen::into_network_info. 2018-07-19 12:18:01 +02:00
Andreas Fackler 52a684eb7f Add example code for `SyncKeyGen` to the docs. 2018-07-18 17:59:28 +02:00
Andreas Fackler 15cc6ffddd Separate keys and key shares. 2018-07-18 14:44:35 +02:00
Vladimir Komendantskiy f704b481ad Merge branch 'master' into vk-api-refactor66 2018-07-16 15:38:25 +01:00
Andreas Fackler 1f8373ef93 Add a `JoinPlan` to facilitate joining a running DHB network.
With that, a node can join a running network as an observer in any epoch
where key generation starts.
2018-07-16 16:03:36 +02:00
Vladimir Komendantskiy 9979e790aa added must_use to tests and removed Clone from FaultLog 2018-07-16 14:31:21 +01:00
Vladimir Komendantskiy 22195c4b93 Merge branch 'master' into vk-api-refactor66 2018-07-16 14:20:50 +01:00
Vladimir Komendantskiy c6a0090859 removed cloning of FaultLog 2018-07-16 12:33:00 +01:00
Andreas Fackler 55ad2eae44 Fix DHB test with 1 validator; purge key gen msgs.
This adds a bit of special handling to make sure messages don't stay in
the queue forever in the `dynamic_honey_badger` tests, even if there is
only one validator: the problem was that the single validator is always
ready for input, so it never processed incoming messages. However, to
add the new validator, it needs to process the joining node's key
generation messages.

`DynamicHoneyBadger` now also removes committed key generation messages
from the queue, to avoid committing duplicates.
2018-07-15 12:12:27 +02:00
Vladimir Komendantskiy 72f7b1c06d
Merge branch 'master' into afck-dhb-votes 2018-07-14 08:20:02 +01:00
Vladimir Komendantskiy d7a2808774
Merge branch 'master' into vk-api-refactor66 2018-07-13 13:53:21 +01:00
Marc Brinkmann 591b546402 Removed unnecessary `Hash` where clause. 2018-07-13 13:27:49 +02: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
Marc Brinkmann 510c4478d4 Ensure the adversary is playing fair and give a more helpful error message if they are not. 2018-07-13 13:27:49 +02:00
Marc Brinkmann a0da8b7385 Added extended example for broadcast api and other docstrings. 2018-07-13 13:27:49 +02:00
Vladimir Komendantskiy 7fb1017bb1 changed Step::output to Vec but that didn't fix the dynamic HB test 2018-07-12 21:23:52 +01:00
Andreas Fackler 3f3ac7be13 Minor fixes and simplifications.
* Clear outdated key gen messages from the buffer.
* Process output after proposing, to make `HoneyBadger` work with a
  single validator.
* Print an error if threshold decryption fails.
* Verify decryption shares with the correct ciphertext.
* Insert all ciphertexts from an epoch at once; otherwise contributions
  can be omitted from a batch.
* Remove `BoolWithFaultLog`: It's easier to return a tuple, and it's
  used only in one place now.
* Avoid redundant signature verification in `VoteCounter`.
* Fix the tests for `QueueingHoneyBadger`.
* Use fewer network sizes to speed up tests a bit.
2018-07-12 17:54:27 +02:00
Vladimir Komendantskiy 1254d40147 fixed a starvation issue in Agreement when num_faulty=0 2018-07-12 15:12:06 +01:00
Vladimir Komendantskiy 0ba06fdb76 added step output in DistAlgorithm 2018-07-12 14:54:05 +01:00
c0gent f0ed2e6e12 Make `*HoneyBadger` types thread safe.
Replaces `Rc` with `Arc`. This allows usage from different threads
which will be necessary for use with Parity.
2018-07-11 16:28:41 -07:00
Andreas Fackler ca2dd2327e Add back InvalidNodeTransactionSignature fault.
This was accidentally removed due to a merge conflict.
2018-07-10 17:29:58 +02:00
Andreas Fackler c1b4381753 Separate queue from Honey Badger.
This makes Honey Badger a bit more complicated but a lot more flexible:
It is now unaware of transactions and basically just runs one Subset
instance per epoch.

That way, users can use any kind of external queue, control throttling
and prioritization.
2018-07-10 17:29:58 +02:00
Peter van Nostrand 6783ece9b0 Added faulty node logging to algorithms. 2018-07-09 13:45:11 -04:00
Andreas Fackler 6248e4079f Fix Subset for a single validator. 2018-07-09 11:38:56 +02:00
Andreas Fackler 6f7245f123 Prefer HB::builder over HBBuilder::new. 2018-07-05 11:47:19 +02:00
Andreas Fackler 1a3016d94d Add Honey Badger builder. 2018-07-05 11:47:19 +02:00
Andreas Fackler 0f92010fe4 Add a max_future_epochs option to Honey Badger.
This delays handling of messages from epochs that are too far ahead.
2018-07-05 11:47:19 +02:00
Marc Brinkmann 60450d2c90 Reformatted using nightly rustfmt instead of stable rustfmt. 2018-07-05 10:12:57 +02:00
Marc Brinkmann 5e8b26cfc3 Implemented `Rand` for `SecretKey`. 2018-07-04 16:43:17 +02:00
Andreas Fackler 34385746c6 Add start_epoch option and DHB builder. 2018-07-02 14:14:19 +02:00
Andreas Fackler 11149c5e66 Communicate change state in Dynamic HB, add module docs. 2018-07-02 14:14:19 +02:00
Andreas Fackler 7a0b397233 Add node transaction messages to Dynamic HB. 2018-07-02 14:14:19 +02:00
Andreas Fackler 7a335c9771 Remove vote_counts field from dynamic HB. 2018-06-27 11:51:56 +02:00
Andreas Fackler 74fab61dd8 Fix Dynamic HB test. 2018-06-27 11:37:05 +02:00
Andreas Fackler fd8e7a5900 Add DynamicHoneyBadger. 2018-06-26 15:13:04 +02:00
Andreas Fackler 78fdf63540
Merge pull request #83 from poanetwork/afck-observer
Allow observer nodes in all algorithms.
2018-06-26 15:12:46 +02:00
Vladimir Komendantskiy 6ce6899ca9 added output sequence verification in HoneyBadger test 2018-06-26 12:15:30 +01:00
Andreas Fackler 2a5f9f1bfe Allow observer nodes in all algorithms.
This allows nodes to join the network without sending any messages
themselves. They can't give any input and just observe the outcome.

Closes #81
2018-06-26 09:17:12 +02:00
Andreas Fackler b3b3994ec1
Merge pull request #82 from poanetwork/vk-test-decryption-shares
An adversary sending faulty decryption shares
2018-06-26 09:06:33 +02:00
Vladimir Komendantskiy 1c9ca201d5 corrected a comment and removed a redundant mut 2018-06-25 21:18:25 +01:00
Vladimir Komendantskiy 11ec39879b created an adversary to test against faulty decryption shares 2018-06-25 19:22:08 +01:00
Andreas Fackler 062b35ab3a Make SyncKeyGen NodeUid-aware.
This allows the caller to address nodes by ID instead of by index.

Also contains a few other minor changes that will be needed for
`DynamicHoneyBadger`.
2018-06-25 13:07:31 +02:00
Vladimir Komendantskiy af03158e00 tries to decrypt and output a batch on epoch update from already received messages 2018-06-22 10:12:38 +01:00
Andreas Fackler e11f183db2 Remove generic E: Engine from crypto. 2018-06-22 10:08:23 +02:00
Andreas Fackler 7eb487f329 Implement SyncKeyGen.
This is a _synchronous_ key generation algorithm. We will use it in
`DynamicHoneyBadger`, on top of `HoneyBadger` to satisfy the synchrony
requirements.

It can also be used independently e.g. on top of a blockchain.
2018-06-22 10:06:29 +02:00
Andreas Fackler 3f707a8e12 Return proposer info from HoneyBadger.
Also, consistently name generic arguments, and remove some unused trait
bounds.
2018-06-18 16:19:54 +02:00
Vladimir Komendantskiy f2a03f8f04 corrected the agreement test proposer ID 2018-06-14 13:45:58 +01:00
Vladimir Komendantskiy 82b4250f0d added the broadcast proposer ID in the common coin nonce 2018-06-14 13:36:48 +01:00
Vladimir Komendantskiy 3393052b4b review comment coverage 2018-06-14 12:28:38 +01:00
Vladimir Komendantskiy b82ac64148 note in the broadcast example about the use of keys 2018-06-13 18:24:35 +01:00
Vladimir Komendantskiy 4dbef3968d fixed early update of Agreement epoch 2018-06-13 15:18:27 +01:00
Vladimir Komendantskiy d5794cb5fe extended the common coin nonce with a global UID and the top-level epoch 2018-06-13 15:18:27 +01:00