boltlabs-inc / tss-ecdsa

An implementation of a threshold ECDSA signature scheme
Other
11 stars 5 forks source link

Broadcast Duplicates Messages Internally to the Library #526

Open gatoWololo opened 4 months ago

gatoWololo commented 4 months ago

Background

This library exposes a simple API with the main function process_message. This function takes a message (from another participant) as input and outputs either:

This makes it easy for the calling application to write a loop that loops over process_message until the sub-protocol completes. The caller can iterate over the Vec<Messages> routing them to the correct participant.

The library has support for messages that need to be broadcasted. This broadcast is implemented as follows: The library calls the message_for_other_participants method which generates n - 1 Messages, where n is the number of participants. These messages are returned from the library as part of the Vec<Messages> mentioned above. While this works, the message duplication is not always desirable.

Proposal

We could image a system that wants to handle broadcast in a different manner:

[ ] Change all uses of broadcast with message_for_other_participants to return a single message.

Appendix

Our current implementation of message duplication is simple:

/// Returns a Result[`Vec<Message>`] which are intended for the other
    /// participants.
    fn message_for_other_participants<T: Serialize>(
        &self,
        message_type: MessageType,
        data: T,
    ) -> Result<Vec<Message>> {
        self.other_ids()
            .iter()
            .map(|&other_participant_id| {
                Message::new(
                    message_type,
                    self.sid(),
                    self.id(),
                    other_participant_id,
                    &data,
                )
            })
            .collect()
    }