boltlabs-inc / tss-ecdsa

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

Refactor `Message` type into Header and Payload #516

Open gatoWololo opened 6 months ago

gatoWololo commented 6 months ago

@tposavec recommended the following change and I agree:

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MpcMessage {
    pub header: MpcHeader,
    pub payload: MpcPayload,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MpcHeader {
    /// version for the message format, so we can handle future changes
    version: String,
    /// The type of the message
    pub(crate) message_type: MessageType,
    /// The globally unique session identifier that this message belongs to.
    session_id: SessionIdentifier,
    /// Which participant this message is coming from.
    from: ParticipantIdentifier,
    /// Which participant this message is addressed to.
    to: ParticipantIdentifier,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MpcPayload {
    /// The raw bytes for the message, which need to be verified.
    /// This should be a private member of the struct, so that
    /// we require consumers to call the verify() function in
    /// order to extract bytes
    pub(crate) unverified_bytes: Vec<u8>,
}