awslabs / mls-rs

An implementation of Messaging Layer Security (RFC 9420)
Apache License 2.0
105 stars 19 forks source link

[1.x] Parse message function #216

Open mulmarta opened 2 weeks ago

mulmarta commented 2 weeks ago

Background

Part of #211

Parse Message

We will have a function that parses an MLSMessage and outputs information needed to fetch the right data from storage.

pub enum MlsMessageDescription<'a> {
    Welcome {
        key_package_refs: &'a [KeyPackageRef],
        cipher_suite: CipherSuite,
    },
    ProtocolMessage {
        group_id: &'a [u8],
        epoch_id: u64,
        content_type: ContentType, // commit, proposal, or application
    },
    // Processing GroupInfo and KeyPackage does not require any storage
    GroupInfo,
    KeyPackage,
}

impl<'a> From<&'a MlsMessage> for MlsMessageDescription<'a> {
    ...
}

impl MlsMessage {
    fn description(&self) -> MlsMessageDescription  {
        ....
    }
}
CaioSym commented 1 week ago

Seems odd that we would need an object to own the conversion function. Would this have any major problems?

impl From<&MlsMessage> for ParsedMessage {
...
}
mulmarta commented 1 week ago

Yes that's much better.