Merge pull request #423 from hjubb/multi_device_sync_proto

Multi device sync proto definitions and compiled code with compile fixes
This commit is contained in:
Niels Andriesse 2021-02-05 10:36:37 +11:00 committed by GitHub
commit e4a1de24f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3174 additions and 838 deletions

View File

@ -174,7 +174,7 @@ class ClosedGroupUpdateMessageSendJobV2 private constructor(parameters: Paramete
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NEW closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NEW
closedGroupUpdate.publicKey = ByteString.copyFrom(kind.publicKey) closedGroupUpdate.publicKey = ByteString.copyFrom(kind.publicKey)
closedGroupUpdate.name = kind.name closedGroupUpdate.name = kind.name
val encryptionKeyPair = SignalServiceProtos.ClosedGroupUpdateV2.KeyPair.newBuilder() val encryptionKeyPair = SignalServiceProtos.KeyPair.newBuilder()
encryptionKeyPair.publicKey = ByteString.copyFrom(kind.encryptionKeyPair.publicKey.serialize().removing05PrefixIfNeeded()) encryptionKeyPair.publicKey = ByteString.copyFrom(kind.encryptionKeyPair.publicKey.serialize().removing05PrefixIfNeeded())
encryptionKeyPair.privateKey = ByteString.copyFrom(kind.encryptionKeyPair.privateKey.serialize()) encryptionKeyPair.privateKey = ByteString.copyFrom(kind.encryptionKeyPair.privateKey.serialize())
closedGroupUpdate.encryptionKeyPair = encryptionKeyPair.build() closedGroupUpdate.encryptionKeyPair = encryptionKeyPair.build()

View File

@ -360,7 +360,7 @@ object ClosedGroupsProtocolV2 {
// Generate the new encryption key pair // Generate the new encryption key pair
val newKeyPair = Curve.generateKeyPair() val newKeyPair = Curve.generateKeyPair()
// Distribute it // Distribute it
val proto = SignalServiceProtos.ClosedGroupUpdateV2.KeyPair.newBuilder() val proto = SignalServiceProtos.KeyPair.newBuilder()
proto.publicKey = ByteString.copyFrom(newKeyPair.publicKey.serialize().removing05PrefixIfNeeded()) proto.publicKey = ByteString.copyFrom(newKeyPair.publicKey.serialize().removing05PrefixIfNeeded())
proto.privateKey = ByteString.copyFrom(newKeyPair.privateKey.serialize()) proto.privateKey = ByteString.copyFrom(newKeyPair.privateKey.serialize())
val plaintext = proto.build().toByteArray() val plaintext = proto.build().toByteArray()
@ -677,7 +677,7 @@ object ClosedGroupsProtocolV2 {
val encryptedKeyPair = wrapper.encryptedKeyPair.toByteArray() val encryptedKeyPair = wrapper.encryptedKeyPair.toByteArray()
val plaintext = SessionProtocolImpl(context).decrypt(encryptedKeyPair, userKeyPair).first val plaintext = SessionProtocolImpl(context).decrypt(encryptedKeyPair, userKeyPair).first
// Parse it // Parse it
val proto = SignalServiceProtos.ClosedGroupUpdateV2.KeyPair.parseFrom(plaintext) val proto = SignalServiceProtos.KeyPair.parseFrom(plaintext)
val keyPair = ECKeyPair(DjbECPublicKey(proto.publicKey.toByteArray().removing05PrefixIfNeeded()), DjbECPrivateKey(proto.privateKey.toByteArray())) val keyPair = ECKeyPair(DjbECPublicKey(proto.publicKey.toByteArray().removing05PrefixIfNeeded()), DjbECPrivateKey(proto.privateKey.toByteArray()))
// Store it // Store it
apiDB.addClosedGroupEncryptionKeyPair(keyPair, groupPublicKey) apiDB.addClosedGroupEncryptionKeyPair(keyPair, groupPublicKey)

View File

@ -118,7 +118,7 @@ class ClosedGroupControlMessage() : ControlMessage() {
closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NEW closedGroupUpdate.type = SignalServiceProtos.ClosedGroupUpdateV2.Type.NEW
closedGroupUpdate.publicKey = kind.publicKey closedGroupUpdate.publicKey = kind.publicKey
closedGroupUpdate.name = kind.name closedGroupUpdate.name = kind.name
val encryptionKeyPairAsProto = SignalServiceProtos.ClosedGroupUpdateV2.KeyPair.newBuilder() val encryptionKeyPairAsProto = SignalServiceProtos.KeyPair.newBuilder()
encryptionKeyPairAsProto.publicKey = ByteString.copyFrom(kind.encryptionKeyPair.publicKey.serialize()) encryptionKeyPairAsProto.publicKey = ByteString.copyFrom(kind.encryptionKeyPair.publicKey.serialize())
encryptionKeyPairAsProto.privateKey = ByteString.copyFrom(kind.encryptionKeyPair.privateKey.serialize()) encryptionKeyPairAsProto.privateKey = ByteString.copyFrom(kind.encryptionKeyPair.privateKey.serialize())

View File

@ -36,11 +36,12 @@ message Envelope {
message Content { message Content {
optional DataMessage dataMessage = 1; optional DataMessage dataMessage = 1;
optional SyncMessage syncMessage = 2; optional SyncMessage syncMessage = 2 [deprecated=true];
optional CallMessage callMessage = 3; optional CallMessage callMessage = 3;
optional NullMessage nullMessage = 4; optional NullMessage nullMessage = 4;
optional ReceiptMessage receiptMessage = 5; optional ReceiptMessage receiptMessage = 5;
optional TypingMessage typingMessage = 6; optional TypingMessage typingMessage = 6;
optional ConfigurationMessage configurationMessage = 7;
optional PreKeyBundleMessage preKeyBundleMessage = 101; // Loki optional PreKeyBundleMessage preKeyBundleMessage = 101; // Loki
optional DeviceLinkMessage deviceLinkMessage = 103; // Loki optional DeviceLinkMessage deviceLinkMessage = 103; // Loki
} }
@ -217,6 +218,7 @@ message DataMessage {
optional LokiUserProfile profile = 101; // Loki - The profile of the current user optional LokiUserProfile profile = 101; // Loki - The profile of the current user
optional ClosedGroupUpdate closedGroupUpdate = 103; // Loki optional ClosedGroupUpdate closedGroupUpdate = 103; // Loki
optional ClosedGroupUpdateV2 closedGroupUpdateV2 = 104; optional ClosedGroupUpdateV2 closedGroupUpdateV2 = 104;
optional string syncTarget = 105;
} }
message LokiUserProfile { message LokiUserProfile {
@ -236,13 +238,6 @@ message ClosedGroupUpdateV2 {
MEMBER_LEFT = 7; MEMBER_LEFT = 7;
} }
message KeyPair {
// @required
required bytes publicKey = 1;
// @required
required bytes privateKey = 2;
}
message KeyPairWrapper { message KeyPairWrapper {
// @required // @required
required bytes publicKey = 1; // The public key of the user the key pair is meant for required bytes publicKey = 1; // The public key of the user the key pair is meant for
@ -260,6 +255,13 @@ message ClosedGroupUpdateV2 {
repeated KeyPairWrapper wrappers = 7; repeated KeyPairWrapper wrappers = 7;
} }
message KeyPair {
// @required
required bytes publicKey = 1;
// @required
required bytes privateKey = 2;
}
message ClosedGroupUpdate { message ClosedGroupUpdate {
enum Type { enum Type {
@ -314,6 +316,20 @@ message TypingMessage {
optional bytes groupId = 3; optional bytes groupId = 3;
} }
message ConfigurationMessage {
message ClosedGroup {
optional bytes publicKey = 1;
optional string name = 2;
optional KeyPair encryptionKeyPair = 3;
repeated bytes members = 4;
repeated bytes admins = 5;
}
repeated ClosedGroup closedGroups = 1;
repeated string openGroups = 2;
}
message Verified { message Verified {
enum State { enum State {
DEFAULT = 0; DEFAULT = 0;