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

feat(decode): support decoding mls messages #865

Merged
merged 2 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions decode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ license = "GPL-3.0-only"
clap = { version = "4.5.26", features = ["derive"] }
proteus-wasm = { workspace = true, features = ["serde"]}
base64 = { workspace = true }
openmls = { workspace = true }
46 changes: 46 additions & 0 deletions decode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,49 @@ ProteusPreKeyBundle {
signature: None,
}
```

### Decode MLS message

```
decode mls-message AAEAATQAAQAA0T+Dx7aERkqm8jl1oWIAQgpjb25mZXJlbmNlAAAAAHN0YWdpbmcuemluZnJhLmlvAAAAAAAAAEMCAAAAAAACAAMAAAAHQEgwRgIhAOrk4aL0X6mJwCJWyNzKHIr5qXt05gx5FyP4rmcgviyYAiEAmUwSh7zTqTJAifMn/UnAVNjZKR19DukHS6iVkIP64Oo=
```
Output:
```
MlsMessageIn {
version: Mls10,
body: PublicMessage(
PublicMessageIn {
content: FramedContentIn {
group_id: GroupId {
value: VLBytes { 0x00010000d13f83c7b684464aa6f23975a16200420a636f6e666572656e63650000000073746167696e672e7a696e6672612e696f },
},
epoch: GroupEpoch(
67,
),
sender: External(
SenderExtensionIndex(
0,
),
),
authenticated_data: VLBytes { b"" },
body: Proposal(
Remove(
RemoveProposal {
removed: LeafNodeIndex(
7,
),
},
),
),
},
auth: FramedContentAuthData {
signature: Signature {
value: VLBytes { 0x3046022100eae4e1a2f45fa989c02256c8dcca1c8af9a97b74e60c791723f8ae6720be2c98022100994c1287bcd3a9324089f327fd49c054d8d9291d7d0ee9074ba8959083fae0ea },
},
confirmation_tag: None,
},
membership_tag: None,
},
),
}
```
9 changes: 9 additions & 0 deletions decode/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use base64::Engine;
use clap::{Parser, Subcommand};
use openmls::prelude::{MlsMessageIn, TlsDeserializeTrait};
use proteus_wasm::internal::message::SessionTag;
use proteus_wasm::internal::util::fmt_hex;
use proteus_wasm::keys::{PreKeyBundle, Signature};
Expand Down Expand Up @@ -121,6 +122,8 @@ enum Command {
/// Base64 encoded proteus message
message: String,
},
/// Decode a MLS message
MlsMessage { message: String },
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand All @@ -138,5 +141,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("{:#?}", ProteusEnvelope::from(message));
Ok(())
}
Command::MlsMessage { message } => {
let bytes = base64::prelude::BASE64_STANDARD.decode(message)?;
let message = MlsMessageIn::tls_deserialize(&mut bytes.as_slice())?;
println!("{message:#?}");
Ok(())
}
}
}
Loading