Update Inbox types (#4)

* Add Xk0

* update rust impl

* clean up

* Update tests

* Update .gitignore
This commit is contained in:
Jazz Turner-Baggs 2026-01-15 23:46:18 +07:00 committed by GitHub
parent 7995313ca1
commit 615f856588
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 31 additions and 54 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
**/target

View File

@ -1,4 +1,4 @@
# Chat Protobuf Definitionss
# Chat Protobuf Definitions
This repository contains the canonical **protobuf definitions** for the logoschat (Logos Chat Protocol) used by LibChat and related components.

View File

@ -33,7 +33,6 @@ pub mod logoschat {
mod tests {
use super::logoschat::{
encryption::{encrypted_payload::Encryption, EncryptedPayload, Plaintext},
inbox::{inbox_v1_frame::FrameType, InboxV1Frame, Note},
invite::InvitePrivateV1,
};
use bytes::Bytes;
@ -62,37 +61,9 @@ mod tests {
}
}
#[test]
fn test_inbox_frame_roundtrip() {
let note = Note {
text: "This is a test note".to_string(),
};
let frame = InboxV1Frame {
recipient: "alice".to_string(),
frame_type: Some(FrameType::Note(note.clone())),
};
let mut buf = Vec::new();
frame.encode(&mut buf).expect("Encoding failed");
let decoded = InboxV1Frame::decode(&buf[..]).expect("Decoding failed");
match decoded.frame_type {
Some(FrameType::Note(n)) => {
assert_eq!(n.text, note.text);
}
_ => panic!("Expected Note variant"),
}
}
#[test]
fn test_invite_private_roundtrip() {
let invite = InvitePrivateV1 {
initiator: Bytes::from_static(b"initiator"),
initiator_ephemeral: Bytes::from_static(b"ephemeral"),
participant: Bytes::from_static(b"participant"),
participant_ephemeral_id: 42,
discriminator: "test_discriminator".to_string(),
initial_message: None, // skipping encrypted payload for simplicity
};
@ -102,8 +73,6 @@ mod tests {
let decoded = InvitePrivateV1::decode(&buf[..]).expect("Decoding failed");
assert_eq!(decoded.initiator, Bytes::from_static(b"initiator"));
assert_eq!(decoded.participant_ephemeral_id, 42);
assert_eq!(decoded.discriminator, "test_discriminator");
}
}

View File

@ -4,7 +4,7 @@
/// Alternatives: ???
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct EncryptedPayload {
#[prost(oneof="encrypted_payload::Encryption", tags="1, 2")]
#[prost(oneof="encrypted_payload::Encryption", tags="1, 2, 3")]
pub encryption: ::core::option::Option<encrypted_payload::Encryption>,
}
/// Nested message and enum types in `EncryptedPayload`.
@ -15,6 +15,8 @@ pub mod encrypted_payload {
Plaintext(super::Plaintext),
#[prost(message, tag="2")]
Doubleratchet(super::Doubleratchet),
#[prost(message, tag="3")]
Xk0(super::Xk0),
}
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
@ -36,4 +38,18 @@ pub struct Doubleratchet {
#[prost(string, tag="5")]
pub aux: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Xk0 {
#[prost(bytes="bytes", tag="1")]
pub initiator_static: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="2")]
pub initiator_ephemeral: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="3")]
pub responder_static: ::prost::bytes::Bytes,
/// Replace with RKI to save bytes
#[prost(bytes="bytes", tag="4")]
pub responder_ephemeral: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="5")]
pub payload: ::prost::bytes::Bytes,
}
// @@protoc_insertion_point(module)

View File

@ -7,19 +7,15 @@ pub struct Note {
}
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct InboxV1Frame {
#[prost(string, tag="1")]
pub recipient: ::prost::alloc::string::String,
#[prost(oneof="inbox_v1_frame::FrameType", tags="10, 11")]
#[prost(oneof="inbox_v1_frame::FrameType", tags="1")]
pub frame_type: ::core::option::Option<inbox_v1_frame::FrameType>,
}
/// Nested message and enum types in `InboxV1Frame`.
pub mod inbox_v1_frame {
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum FrameType {
#[prost(message, tag="10")]
#[prost(message, tag="1")]
InvitePrivateV1(super::super::invite::InvitePrivateV1),
#[prost(message, tag="11")]
Note(super::Note),
}
}
// @@protoc_insertion_point(module)

View File

@ -2,14 +2,6 @@
// This file is @generated by prost-build.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct InvitePrivateV1 {
#[prost(bytes="bytes", tag="1")]
pub initiator: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="2")]
pub initiator_ephemeral: ::prost::bytes::Bytes,
#[prost(bytes="bytes", tag="3")]
pub participant: ::prost::bytes::Bytes,
#[prost(int32, tag="4")]
pub participant_ephemeral_id: i32,
#[prost(string, tag="5")]
pub discriminator: ::prost::alloc::string::String,
#[prost(message, optional, tag="6")]

View File

@ -10,6 +10,7 @@ message EncryptedPayload {
oneof encryption {
encryption.Plaintext plaintext = 1;
encryption.Doubleratchet doubleratchet = 2;
encryption.XK0 xk0 = 3;
}
}
@ -24,3 +25,11 @@ message Doubleratchet {
bytes ciphertext = 4;
string aux = 5;
}
message XK0 {
bytes initiator_static = 1;
bytes initiator_ephemeral = 2;
bytes responder_static = 3;
bytes responder_ephemeral = 4; // Replace with RKI to save bytes
bytes payload = 5;
}

View File

@ -9,9 +9,7 @@ message Note{
}
message InboxV1Frame {
string recipient = 1;
oneof frame_type {
invite.InvitePrivateV1 invite_private_v1 = 10;
Note note = 11;
invite.InvitePrivateV1 invite_private_v1 = 1;
}
}

View File

@ -5,10 +5,6 @@ package logoschat.invite;
import "encryption.proto";
message InvitePrivateV1 {
bytes initiator = 1;
bytes initiator_ephemeral = 2;
bytes participant = 3;
int32 participant_ephemeral_id= 4;
string discriminator = 5;
encryption.EncryptedPayload initial_message = 6;
}