@tposavec recommended the following change and I agree:
I would like to propose separate types for header, payload, and message
I would like to add a version field to the header type
something like this...
#[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>,
}
@tposavec recommended the following change and I agree: