From e8ff7403669466a24de40132188a75380741572b Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Mon, 4 Nov 2024 15:02:29 -0800 Subject: [PATCH] Add serialization to the bounds of PartyId, ProtocolError, and CorrectnessProof --- CHANGELOG.md | 1 + manul/src/protocol/round.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0916b9..dbd6402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Renamed `FirstRound` trait to `EntryPoint`. ([#60]) - Added `Protocol` type to `EntryPoint`. ([#60]) - `EntryPoint` and `FinalizeOutcome::AnotherRound` now use a new `BoxedRound` wrapper type. ([#60]) +- `PartyId` and `ProtocolError` are now bound on `Serialize`/`Deserialize`. ([#60]) ### Added diff --git a/manul/src/protocol/round.rs b/manul/src/protocol/round.rs index c4cc544..1f8c556 100644 --- a/manul/src/protocol/round.rs +++ b/manul/src/protocol/round.rs @@ -84,12 +84,12 @@ pub trait Protocol: 'static { type Result: Debug; /// An object of this type will be returned when a provable error happens during [`Round::receive_message`]. - type ProtocolError: ProtocolError + Serialize + for<'de> Deserialize<'de>; + type ProtocolError: ProtocolError; /// An object of this type will be returned when an unattributable error happens during [`Round::finalize`]. /// /// It proves that the node did its job correctly, to be adjudicated by a third party. - type CorrectnessProof: CorrectnessProof + Serialize + for<'de> Deserialize<'de>; + type CorrectnessProof: CorrectnessProof; /// Returns `Ok(())` if the given direct message cannot be deserialized /// assuming it is a direct message from the round `round_id`. @@ -138,7 +138,7 @@ pub trait Protocol: 'static { /// /// Provable here means that we can create an evidence object entirely of messages signed by some party, /// which, in combination, prove the party's malicious actions. -pub trait ProtocolError: Debug + Clone + Send { +pub trait ProtocolError: Debug + Clone + Send + Serialize + for<'de> Deserialize<'de> { /// A description of the error that will be included in the generated evidence. /// /// Make it short and informative. @@ -229,7 +229,7 @@ impl ProtocolError for () { /// each node must generate a correctness proof proving that they performed their duties correctly, /// and the collection of proofs is verified by a third party. /// One of the proofs will necessarily be missing or invalid. -pub trait CorrectnessProof: Debug + Clone + Send {} +pub trait CorrectnessProof: Debug + Clone + Send + Serialize + for<'de> Deserialize<'de> {} // A convenience implementation for protocols that don't define any errors. // Have to do it for `()`, since `!` is unstable. @@ -312,9 +312,9 @@ pub trait EntryPoint { } /// A trait alias for the combination of traits needed for a party identifier. -pub trait PartyId: 'static + Debug + Clone + Ord + Send + Sync {} +pub trait PartyId: 'static + Debug + Clone + Ord + Send + Sync + Serialize + for<'de> Deserialize<'de> {} -impl PartyId for T where T: 'static + Debug + Clone + Ord + Send + Sync {} +impl PartyId for T where T: 'static + Debug + Clone + Ord + Send + Sync + Serialize + for<'de> Deserialize<'de> {} /** A type representing a single round of a protocol.