diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b60de5b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/target diff --git a/README.md b/README.md index 1262c1a..2745825 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/gen/rust/src/lib.rs b/gen/rust/src/lib.rs index 4e9d5c6..2267d4d 100644 --- a/gen/rust/src/lib.rs +++ b/gen/rust/src/lib.rs @@ -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"); } } diff --git a/gen/rust/src/logoschat/encryption/logoschat.encryption.rs b/gen/rust/src/logoschat/encryption/logoschat.encryption.rs index 1495f03..9182844 100644 --- a/gen/rust/src/logoschat/encryption/logoschat.encryption.rs +++ b/gen/rust/src/logoschat/encryption/logoschat.encryption.rs @@ -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, } /// 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) diff --git a/gen/rust/src/logoschat/inbox/logoschat.inbox.rs b/gen/rust/src/logoschat/inbox/logoschat.inbox.rs index a08b290..c80d6fe 100644 --- a/gen/rust/src/logoschat/inbox/logoschat.inbox.rs +++ b/gen/rust/src/logoschat/inbox/logoschat.inbox.rs @@ -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, } /// 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) diff --git a/gen/rust/src/logoschat/invite/logoschat.invite.rs b/gen/rust/src/logoschat/invite/logoschat.invite.rs index 013e528..2ae4e7a 100644 --- a/gen/rust/src/logoschat/invite/logoschat.invite.rs +++ b/gen/rust/src/logoschat/invite/logoschat.invite.rs @@ -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")] diff --git a/protos/encryption.proto b/protos/encryption.proto index a245369..58b7b43 100644 --- a/protos/encryption.proto +++ b/protos/encryption.proto @@ -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; +} diff --git a/protos/inbox.proto b/protos/inbox.proto index 1159eb7..5786fce 100644 --- a/protos/inbox.proto +++ b/protos/inbox.proto @@ -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; } } diff --git a/protos/invite.proto b/protos/invite.proto index 608f8d4..2121a9d 100644 --- a/protos/invite.proto +++ b/protos/invite.proto @@ -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; }