Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Message type into Header and Payload #516

Open
gatoWololo opened this issue Feb 13, 2024 · 0 comments
Open

Refactor Message type into Header and Payload #516

gatoWololo opened this issue Feb 13, 2024 · 0 comments
Labels
tech-debt Something works but could be better

Comments

@gatoWololo
Copy link

@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>,
}
@gatoWololo gatoWololo added the tech-debt Something works but could be better label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Something works but could be better
Projects
None yet
Development

No branches or pull requests

1 participant