From 767d454c8f84a28e0b76d81d56b4f62fb413f674 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 10 Dec 2025 13:24:51 +0100 Subject: [PATCH 1/4] Add `RoundInput::received_msg_from` method Signed-off-by: Denis Varlakov --- Cargo.lock | 2 +- round-based/src/rounds_router/simple_store.rs | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a86357a..f5f6c4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "round-based" -version = "0.4.0" +version = "0.4.1" dependencies = [ "anyhow", "futures", diff --git a/round-based/src/rounds_router/simple_store.rs b/round-based/src/rounds_router/simple_store.rs index 265dd80..5a0c14a 100644 --- a/round-based/src/rounds_router/simple_store.rs +++ b/round-based/src/rounds_router/simple_store.rs @@ -97,6 +97,38 @@ impl RoundInput { 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> { + /// 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 { + 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 } From 1ec54af1c3a631e9067e904c5f8650e35a3469fa Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 10 Dec 2025 13:30:58 +0100 Subject: [PATCH 2/4] Update CI so it gets triggered on legacy/v0.4 branch Signed-off-by: Denis Varlakov --- .github/workflows/audit.yml | 4 ++-- .github/workflows/readme.yml | 4 ++-- .github/workflows/rust.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 08418ea..e6c1ecd 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -1,7 +1,7 @@ name: Security audit on: pull_request: - branches: [ "*" ] + branches: [ "**" ] paths: - '**/Cargo.toml' - '**/Cargo.lock' @@ -12,4 +12,4 @@ jobs: - uses: actions/checkout@v3 - uses: rustsec/audit-check@v1.4.1 with: - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml index 4907af8..f7c07ef 100644 --- a/.github/workflows/readme.yml +++ b/.github/workflows/readme.yml @@ -2,7 +2,7 @@ name: Check README on: pull_request: - branches: [ "*" ] + branches: [ "**" ] env: CARGO_TERM_COLOR: always @@ -21,4 +21,4 @@ jobs: run: | cp README.md README-copy.md make readme - diff README.md README-copy.md \ No newline at end of file + diff README.md README-copy.md diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 66ed82f..f87894d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,7 +2,7 @@ name: Rust on: pull_request: - branches: [ "*" ] + branches: [ "**" ] env: CARGO_TERM_COLOR: always From 5d3fbbd896be8a72e3a96b0fcc3d072a52d73dc4 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 10 Dec 2025 13:35:37 +0100 Subject: [PATCH 3/4] Bump version & update changelog Signed-off-by: Denis Varlakov --- Cargo.lock | 2 +- round-based/CHANGELOG.md | 7 +++++++ round-based/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5f6c4e..84e8fc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -463,7 +463,7 @@ dependencies = [ [[package]] name = "round-based" -version = "0.4.1" +version = "0.4.2" dependencies = [ "anyhow", "futures", diff --git a/round-based/CHANGELOG.md b/round-based/CHANGELOG.md index 1d9cb1c..35643a0 100644 --- a/round-based/CHANGELOG.md +++ b/round-based/CHANGELOG.md @@ -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` diff --git a/round-based/Cargo.toml b/round-based/Cargo.toml index 3cea8fe..2055025 100644 --- a/round-based/Cargo.toml +++ b/round-based/Cargo.toml @@ -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" From 3c6aa32ac37326bd0595f78e923d04239c4e3012 Mon Sep 17 00:00:00 2001 From: Denis Varlakov Date: Wed, 10 Dec 2025 14:44:50 +0100 Subject: [PATCH 4/4] bug fix Signed-off-by: Denis Varlakov --- round-based/src/rounds_router/simple_store.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/round-based/src/rounds_router/simple_store.rs b/round-based/src/rounds_router/simple_store.rs index 5a0c14a..e88969d 100644 --- a/round-based/src/rounds_router/simple_store.rs +++ b/round-based/src/rounds_router/simple_store.rs @@ -123,6 +123,13 @@ impl RoundInput { /// # 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())