2018-09-24 18:07:34 +00:00
|
|
|
syntax = "proto3";
|
|
|
|
|
2022-02-14 11:08:18 +00:00
|
|
|
option go_package = "./;encryption";
|
2019-07-17 22:25:42 +00:00
|
|
|
package encryption;
|
2018-09-24 18:07:34 +00:00
|
|
|
|
|
|
|
message SignedPreKey {
|
|
|
|
bytes signed_pre_key = 1;
|
|
|
|
uint32 version = 2;
|
2019-05-23 07:54:28 +00:00
|
|
|
uint32 protocol_version = 3;
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// X3DH prekey bundle
|
|
|
|
message Bundle {
|
|
|
|
// Identity key
|
|
|
|
bytes identity = 1;
|
|
|
|
// Installation id
|
|
|
|
map<string,SignedPreKey> signed_pre_keys = 2;
|
|
|
|
// Prekey signature
|
|
|
|
bytes signature = 4;
|
2018-11-06 08:05:32 +00:00
|
|
|
|
|
|
|
// When the bundle was created locally
|
|
|
|
int64 timestamp = 5;
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message BundleContainer {
|
2018-11-06 08:05:32 +00:00
|
|
|
reserved 3;
|
2018-09-24 18:07:34 +00:00
|
|
|
// X3DH prekey bundle
|
|
|
|
Bundle bundle = 1;
|
|
|
|
// Private signed prekey
|
|
|
|
bytes private_signed_pre_key = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DRHeader {
|
|
|
|
// Current ratchet public key
|
|
|
|
bytes key = 1;
|
|
|
|
// Number of the message in the sending chain
|
|
|
|
uint32 n = 2;
|
|
|
|
// Length of the previous sending chain
|
|
|
|
uint32 pn = 3;
|
|
|
|
// Bundle ID
|
|
|
|
bytes id = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
message DHHeader {
|
|
|
|
// Compressed ephemeral public key
|
|
|
|
bytes key = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
message X3DHHeader {
|
2018-11-06 08:05:32 +00:00
|
|
|
reserved 3;
|
2018-09-24 18:07:34 +00:00
|
|
|
// Ephemeral key used
|
|
|
|
bytes key = 1;
|
|
|
|
// Used bundle's signed prekey
|
|
|
|
bytes id = 4;
|
|
|
|
}
|
|
|
|
|
2021-09-21 15:47:04 +00:00
|
|
|
// Hash Ratchet Header
|
|
|
|
message HRHeader {
|
2023-10-12 15:45:23 +00:00
|
|
|
// deprecated group key ID
|
|
|
|
uint32 deprecated_key_id = 1;
|
|
|
|
// group message number for this key_id
|
2021-09-21 15:47:04 +00:00
|
|
|
uint32 seq_no = 2;
|
2023-10-12 15:45:23 +00:00
|
|
|
// group ID
|
2022-05-27 09:14:40 +00:00
|
|
|
bytes group_id = 3;
|
2023-10-12 15:45:23 +00:00
|
|
|
// group key ID
|
|
|
|
bytes key_id = 4;
|
2024-01-23 16:56:51 +00:00
|
|
|
HRKeys keys = 5;
|
2023-10-12 15:45:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message RekeyGroup {
|
|
|
|
uint64 timestamp = 2;
|
|
|
|
|
|
|
|
map<uint32, bytes> keys = 4;
|
2021-09-21 15:47:04 +00:00
|
|
|
}
|
|
|
|
|
2022-09-21 16:05:29 +00:00
|
|
|
message HRKeys {
|
|
|
|
repeated HRKey keys = 1;
|
2023-10-12 15:45:23 +00:00
|
|
|
RekeyGroup rekey_group = 2;
|
2022-09-21 16:05:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message HRKey {
|
2023-10-12 15:45:23 +00:00
|
|
|
uint32 deprecated_key_id = 1;
|
2022-09-21 16:05:29 +00:00
|
|
|
bytes key = 2;
|
2023-10-12 15:45:23 +00:00
|
|
|
uint64 timestamp = 3;
|
2022-09-21 16:05:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-24 18:07:34 +00:00
|
|
|
// Direct message value
|
2021-09-21 15:47:04 +00:00
|
|
|
message EncryptedMessageProtocol {
|
2018-09-24 18:07:34 +00:00
|
|
|
X3DHHeader X3DH_header = 1;
|
2023-10-12 15:45:23 +00:00
|
|
|
DRHeader DR_header = 2;
|
2018-09-24 18:07:34 +00:00
|
|
|
DHHeader DH_header = 101;
|
2021-09-21 15:47:04 +00:00
|
|
|
HRHeader HR_header = 102;
|
2018-09-24 18:07:34 +00:00
|
|
|
// Encrypted payload
|
|
|
|
bytes payload = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Top-level protocol message
|
|
|
|
message ProtocolMessage {
|
2018-10-16 10:31:05 +00:00
|
|
|
// The device id of the sender
|
|
|
|
string installation_id = 2;
|
|
|
|
|
2018-12-21 10:07:25 +00:00
|
|
|
// List of bundles
|
|
|
|
repeated Bundle bundles = 3;
|
|
|
|
|
2018-09-24 18:07:34 +00:00
|
|
|
// One to one message, encrypted, indexed by installation_id
|
2021-09-21 15:47:04 +00:00
|
|
|
// TODO map here is redundant in case of community messages
|
|
|
|
map<string,EncryptedMessageProtocol> encrypted_message = 101;
|
2018-09-24 18:07:34 +00:00
|
|
|
|
|
|
|
// Public chats, not encrypted
|
|
|
|
bytes public_message = 102;
|
|
|
|
}
|