Trait Round

Source
pub trait Round<Id: PartyId>:
    'static
    + Debug
    + Send
    + Sync
    + DynTypeId {
    type Protocol: Protocol<Id>;

    // Required methods
    fn transition_info(&self) -> TransitionInfo;
    fn communication_info(&self) -> CommunicationInfo<Id>;
    fn receive_message(
        &self,
        format: &BoxedFormat,
        from: &Id,
        message: ProtocolMessage,
    ) -> Result<Payload, ReceiveError<Id, Self::Protocol>>;
    fn finalize(
        self: Box<Self>,
        rng: &mut dyn CryptoRngCore,
        payloads: BTreeMap<Id, Payload>,
        artifacts: BTreeMap<Id, Artifact>,
    ) -> Result<FinalizeOutcome<Id, Self::Protocol>, LocalError>;

    // Provided methods
    fn make_direct_message(
        &self,
        rng: &mut dyn CryptoRngCore,
        format: &BoxedFormat,
        destination: &Id,
    ) -> Result<(DirectMessage, Option<Artifact>), LocalError> { ... }
    fn make_echo_broadcast(
        &self,
        rng: &mut dyn CryptoRngCore,
        format: &BoxedFormat,
    ) -> Result<EchoBroadcast, LocalError> { ... }
    fn make_normal_broadcast(
        &self,
        rng: &mut dyn CryptoRngCore,
        format: &BoxedFormat,
    ) -> Result<NormalBroadcast, LocalError> { ... }
}
Expand description

A type representing a single round of a protocol.

The way a round will be used by an external caller:

Required Associated Types§

Source

type Protocol: Protocol<Id>

The protocol this round is a part of.

Required Methods§

Source

fn transition_info(&self) -> TransitionInfo

Returns the information about the position of this round in the state transition graph.

See TransitionInfo documentation for more details.

Source

fn communication_info(&self) -> CommunicationInfo<Id>

Returns the information about the communication this rounds engages in with other nodes.

See CommunicationInfo documentation for more details.

Source

fn receive_message( &self, format: &BoxedFormat, from: &Id, message: ProtocolMessage, ) -> Result<Payload, ReceiveError<Id, Self::Protocol>>

Processes the received message and generates the payload that will be used in finalize.

Note that there is no need to authenticate the message at this point; it has already been done by the execution layer.

Source

fn finalize( self: Box<Self>, rng: &mut dyn CryptoRngCore, payloads: BTreeMap<Id, Payload>, artifacts: BTreeMap<Id, Artifact>, ) -> Result<FinalizeOutcome<Id, Self::Protocol>, LocalError>

Attempts to finalize the round, producing the next round or the result.

payloads here are the ones previously generated by receive_message, and artifacts are the ones previously generated by make_direct_message.

Provided Methods§

Source

fn make_direct_message( &self, rng: &mut dyn CryptoRngCore, format: &BoxedFormat, destination: &Id, ) -> Result<(DirectMessage, Option<Artifact>), LocalError>

Returns the direct message to the given destination and (maybe) an accompanying artifact.

Return DirectMessage::none if this round does not send direct messages.

In some protocols, when a message to another node is created, there is some associated information that needs to be retained for later (randomness, proofs of knowledge, and so on). These should be put in an Artifact and will be available at the time of finalize.

Source

fn make_echo_broadcast( &self, rng: &mut dyn CryptoRngCore, format: &BoxedFormat, ) -> Result<EchoBroadcast, LocalError>

Returns the echo broadcast for this round.

Return EchoBroadcast::none if this round does not send echo-broadcast messages. This is also the blanket implementation.

The execution layer will guarantee that all the destinations are sure they all received the same broadcast. This also means that a message with the broadcasts from all nodes signed by each node is available if an evidence of malicious behavior has to be constructed.

Source

fn make_normal_broadcast( &self, rng: &mut dyn CryptoRngCore, format: &BoxedFormat, ) -> Result<NormalBroadcast, LocalError>

Returns the normal broadcast for this round.

Return NormalBroadcast::none if this round does not send normal broadcast messages. This is also the blanket implementation.

Unlike the echo broadcasts, these will be just sent to every node defined in Self::communication_info without any confirmation required.

Implementors§