Skip to content

Commit

Permalink
Merge pull request #76 from fjarri/evidence-session-id
Browse files Browse the repository at this point in the history
Pass more info for evidence verification
  • Loading branch information
fjarri authored Dec 25, 2024
2 parents b3276cb + 4cffcb2 commit 95450bf
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 257 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Removed `protocol::digest` re-export ([#75]).
- `digest` and `signature` are now re-exported from the top level instead of `session` ([#75]).
- `ProtocolError::verify_messages_constitute_error()` takes a new `shared_randomness` argument. ([#76])
- `Protocol` and `ProtocolError` are now generic over `Id`. ([#76])
- `ProtocolError::verify_messages_constitute_error()` takes a new `guilty_party` argument. ([#76])
- `Combinator`/`CombinatorEntryPoint` removed in favor of a single `ChainedMarker` trait. ([#76])
- The `combined_echos` argument to `ProtocolError::verify_messages_constitute_error()` now has a mapping of id to echo instead of just a vector of echos. ([#76])
- `ProtocolError::verify_messages_constitute_error()` now takes messages and mapping of messages by value. ([#76])


[#75]: https://github.com/entropyxyz/manul/pull/75
[#76]: https://github.com/entropyxyz/manul/pull/76


## [0.1.0] - 2024-11-19
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ We try to find the balance between supporting the majority of protocols and keep
- A protocol consists of several rounds.
- A round generates messages to send out without any additional external input, then waits for messages from other parties. When it receives enough messages, it can be finalized.
- On finalization, a round can return the result, halt with an error, or continue to another round.
- Each round declares a set of parties it sends messages to. Then it can optionally send a direct message to each party in the set, set a regular broadcast to all parties in the set, or send an echo-broadcast to all parties in the set (that is, a broadcast where it is ensured that all parties received the same thing). Any number of these options can be picked.
- Each round declares a set of parties it sends messages to. Then it can optionally send a direct message to each party in the set, send a regular broadcast to all parties in the set, or send an echo-broadcast to all parties in the set (that is, a broadcast where it is ensured that all parties received the same thing). Any number of these options can be picked.


[crate-image]: https://img.shields.io/crates/v/manul.svg
Expand Down
22 changes: 12 additions & 10 deletions examples/src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum SimpleProtocolError {
Round2InvalidPosition,
}

impl ProtocolError for SimpleProtocolError {
impl<Id> ProtocolError<Id> for SimpleProtocolError {
fn description(&self) -> String {
format!("{:?}", self)
}
Expand Down Expand Up @@ -53,13 +53,15 @@ impl ProtocolError for SimpleProtocolError {
fn verify_messages_constitute_error(
&self,
deserializer: &Deserializer,
_echo_broadcast: &EchoBroadcast,
_normal_broadcast: &NormalBroadcast,
direct_message: &DirectMessage,
_echo_broadcasts: &BTreeMap<RoundId, EchoBroadcast>,
_normal_broadcasts: &BTreeMap<RoundId, NormalBroadcast>,
_direct_messages: &BTreeMap<RoundId, DirectMessage>,
combined_echos: &BTreeMap<RoundId, Vec<EchoBroadcast>>,
_guilty_party: &Id,
_shared_randomness: &[u8],
_echo_broadcast: EchoBroadcast,
_normal_broadcast: NormalBroadcast,
direct_message: DirectMessage,
_echo_broadcasts: BTreeMap<RoundId, EchoBroadcast>,
_normal_broadcasts: BTreeMap<RoundId, NormalBroadcast>,
_direct_messages: BTreeMap<RoundId, DirectMessage>,
combined_echos: BTreeMap<RoundId, BTreeMap<Id, EchoBroadcast>>,
) -> Result<(), ProtocolValidationError> {
match self {
SimpleProtocolError::Round1InvalidPosition => {
Expand All @@ -76,7 +78,7 @@ impl ProtocolError for SimpleProtocolError {
// Deserialize the echos
let _r1_echos = r1_echos_serialized
.iter()
.map(|echo| echo.deserialize::<Round1Echo>(deserializer))
.map(|(_id, echo)| echo.deserialize::<Round1Echo>(deserializer))
.collect::<Result<Vec<_>, _>>()?;

// Message contents would be checked here
Expand All @@ -86,7 +88,7 @@ impl ProtocolError for SimpleProtocolError {
}
}

impl Protocol for SimpleProtocol {
impl<Id> Protocol<Id> for SimpleProtocol {
type Result = u8;
type ProtocolError = SimpleProtocolError;

Expand Down
17 changes: 7 additions & 10 deletions examples/src/simple_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use alloc::collections::BTreeSet;
use core::fmt::Debug;

use manul::{
combinators::{
chain::{Chain, ChainedJoin, ChainedProtocol, ChainedSplit},
CombinatorEntryPoint,
},
combinators::chain::{ChainedJoin, ChainedMarker, ChainedProtocol, ChainedSplit},
protocol::{PartyId, Protocol},
};

Expand All @@ -16,7 +13,9 @@ use super::simple::{SimpleProtocol, SimpleProtocolEntryPoint};
#[derive(Debug)]
pub struct DoubleSimpleProtocol;

impl ChainedProtocol for DoubleSimpleProtocol {
impl ChainedMarker for DoubleSimpleProtocol {}

impl<Id> ChainedProtocol<Id> for DoubleSimpleProtocol {
type Protocol1 = SimpleProtocol;
type Protocol2 = SimpleProtocol;
}
Expand All @@ -25,16 +24,14 @@ pub struct DoubleSimpleEntryPoint<Id> {
all_ids: BTreeSet<Id>,
}

impl<Id> ChainedMarker for DoubleSimpleEntryPoint<Id> {}

impl<Id: PartyId> DoubleSimpleEntryPoint<Id> {
pub fn new(all_ids: BTreeSet<Id>) -> Self {
Self { all_ids }
}
}

impl<Id> CombinatorEntryPoint for DoubleSimpleEntryPoint<Id> {
type Combinator = Chain;
}

impl<Id> ChainedSplit<Id> for DoubleSimpleEntryPoint<Id>
where
Id: PartyId,
Expand All @@ -60,7 +57,7 @@ where
{
type Protocol = DoubleSimpleProtocol;
type EntryPoint = SimpleProtocolEntryPoint<Id>;
fn make_entry_point2(self, _result: <SimpleProtocol as Protocol>::Result) -> Self::EntryPoint {
fn make_entry_point2(self, _result: <SimpleProtocol as Protocol<Id>>::Result) -> Self::EntryPoint {
SimpleProtocolEntryPoint::new(self.all_ids)
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/tests/async_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn run_session<P, SP>(
session: Session<P, SP>,
) -> Result<SessionReport<P, SP>, LocalError>
where
P: Protocol,
P: Protocol<SP::Verifier>,
SP: SessionParameters,
{
let rng = &mut OsRng;
Expand Down Expand Up @@ -194,7 +194,7 @@ async fn message_dispatcher<SP>(

async fn run_nodes<P, SP>(sessions: Vec<Session<P, SP>>) -> Vec<SessionReport<P, SP>>
where
P: Protocol + Send,
P: Protocol<SP::Verifier> + Send,
SP: SessionParameters,
P::Result: Send,
SP::Signer: Send,
Expand Down
2 changes: 1 addition & 1 deletion manul/benches/empty_rounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct EmptyProtocol;

impl Protocol for EmptyProtocol {
impl<Id> Protocol<Id> for EmptyProtocol {
type Result = ();
type ProtocolError = ();
}
Expand Down
3 changes: 0 additions & 3 deletions manul/src/combinators.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
//! Combinators operating on protocols.
pub mod chain;
mod markers;
pub mod misbehave;

pub use markers::{Combinator, CombinatorEntryPoint};
Loading

0 comments on commit 95450bf

Please sign in to comment.