Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Security audit
on:
pull_request:
branches: [ "*" ]
branches: [ "**" ]
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
Expand All @@ -12,4 +12,4 @@ jobs:
- uses: actions/checkout@v3
- uses: rustsec/audit-check@v1.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Check README

on:
pull_request:
branches: [ "*" ]
branches: [ "**" ]

env:
CARGO_TERM_COLOR: always
Expand All @@ -21,4 +21,4 @@ jobs:
run: |
cp README.md README-copy.md
make readme
diff README.md README-copy.md
diff README.md README-copy.md
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Rust

on:
pull_request:
branches: [ "*" ]
branches: [ "**" ]

env:
CARGO_TERM_COLOR: always
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions round-based/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
## v0.4.2
* Add `RoundInput::received_msg_from` method [#19]

[#19]: https://github.com/LFDT-Lockness/round-based/pull/19

## v0.4.1
* Add methods to MpcParty to change its components [#15]

[#15]: https://github.com/LFDT-Lockness/round-based/pull/15

## v0.4.0
* BREAKING: Improve ergonomics of protocol simulation, which is used for writing tests [#14]
* Remove `dev` feature, it's replaced with `sim` and `sim-async`
Expand Down
2 changes: 1 addition & 1 deletion round-based/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "round-based"
version = "0.4.1"
version = "0.4.2"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Driver for MPC protocols"
Expand Down
39 changes: 39 additions & 0 deletions round-based/src/rounds_router/simple_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,45 @@ impl<M> RoundInput<M> {
Self::new(i, n, MessageType::P2P)
}

/// Checks if message from party `j` has already been received
///
/// Returns `true` if the store has previously obtained a message from party `j` through
/// [`RoundInput::add_message`] call. Returns `false` if `j` corresponds to index of local party
/// `i` (provided in constructor like [`RoundInput::new`]), if `j ≥ n` (`n` is amount of parties
/// provided in constructor like [`RoundInput::new`]), or if message from party `j` is not yet
/// received.
///
/// ## Example
/// ```rust
/// # use round_based::rounds_router::{MessagesStore, simple_store::RoundInput};
/// # use round_based::{Incoming, MessageType};
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut input = RoundInput::<&'static str>::broadcast(1, 3);
/// assert!(!input.received_msg_from(0));
/// input.add_message(Incoming{
/// id: 0,
/// sender: 0,
/// msg_type: MessageType::Broadcast,
/// msg: "first party message",
/// })?;
/// assert!(input.received_msg_from(0));
/// #
/// # Ok(()) }
/// ```
pub fn received_msg_from(&self, j: PartyIndex) -> bool {
let j = if j < self.i {
j
} else if j == self.i {
return false;
} else {
j - 1
};
self.messages
.get(usize::from(j))
.map(|slot| slot.is_some())
.unwrap_or(false)
}

fn is_expected_type_of_msg(&self, msg_type: MessageType) -> bool {
self.expected_msg_type == msg_type
}
Expand Down
Loading