Search in sources :

Example 71 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.

the class GroupChangeUtil_resolveConflict_Test method field_3_to_9__add_of_pending_member_converted_to_a_promote.

@Test
public void field_3_to_9__add_of_pending_member_converted_to_a_promote() {
    UUID member1 = UUID.randomUUID();
    ProfileKey profileKey1 = randomProfileKey();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addPendingMembers(pendingMember(member1)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addNewMembers(member(member1)).build();
    GroupChange.Actions change = GroupChange.Actions.newBuilder().addAddMembers(GroupChange.Actions.AddMemberAction.newBuilder().setAdded(encryptedMember(member1, profileKey1))).build();
    GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
    GroupChange.Actions expected = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member1, profileKey1))).build();
    assertEquals(expected, resolvedActions);
}
Also used : DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) GroupChange(org.signal.storageservice.protos.groups.GroupChange) DecryptedGroupChange(org.signal.storageservice.protos.groups.local.DecryptedGroupChange) UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 72 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.

the class GroupsV2Operations_decrypt_change_Test method can_decrypt_promote_pending_member_field9.

@Test
public void can_decrypt_promote_pending_member_field9() {
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = newProfileKey();
    GroupCandidate groupCandidate = groupCandidate(newMember, profileKey);
    assertDecryption(groupOperations.createAcceptInviteChange(groupCandidate.getProfileKeyCredential().get()), DecryptedGroupChange.newBuilder().addPromotePendingMembers(DecryptedMember.newBuilder().setUuid(UuidUtil.toByteString(newMember)).setRole(Member.Role.DEFAULT).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setJoinedAtRevision(-1)));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 73 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.

the class GroupsV2Operations_decrypt_group_Test method decrypt_full_members_field_7.

@Test
public void decrypt_full_members_field_7() throws VerificationFailedException, InvalidGroupStateException {
    UUID admin1 = UUID.randomUUID();
    UUID member1 = UUID.randomUUID();
    ProfileKey adminProfileKey = newProfileKey();
    ProfileKey memberProfileKey = newProfileKey();
    Group group = Group.newBuilder().addMembers(Member.newBuilder().setRole(Member.Role.ADMINISTRATOR).setUserId(groupOperations.encryptUuid(admin1)).setJoinedAtRevision(4).setProfileKey(encryptProfileKey(admin1, adminProfileKey))).addMembers(Member.newBuilder().setRole(Member.Role.DEFAULT).setUserId(groupOperations.encryptUuid(member1)).setJoinedAtRevision(7).setProfileKey(encryptProfileKey(member1, memberProfileKey))).build();
    DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
    assertEquals(DecryptedGroup.newBuilder().addMembers(DecryptedMember.newBuilder().setJoinedAtRevision(4).setUuid(UuidUtil.toByteString(admin1)).setRole(Member.Role.ADMINISTRATOR).setProfileKey(ByteString.copyFrom(adminProfileKey.serialize()))).addMembers(DecryptedMember.newBuilder().setJoinedAtRevision(7).setRole(Member.Role.DEFAULT).setUuid(UuidUtil.toByteString(member1)).setProfileKey(ByteString.copyFrom(memberProfileKey.serialize()))).build().getMembersList(), decryptedGroup.getMembersList());
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 74 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.

the class GroupsV2Operations_decrypt_group_Test method decrypt_requesting_members_field_9.

@Test
public void decrypt_requesting_members_field_9() throws VerificationFailedException, InvalidGroupStateException {
    UUID admin1 = UUID.randomUUID();
    UUID member1 = UUID.randomUUID();
    ProfileKey adminProfileKey = newProfileKey();
    ProfileKey memberProfileKey = newProfileKey();
    Group group = Group.newBuilder().addRequestingMembers(RequestingMember.newBuilder().setUserId(groupOperations.encryptUuid(admin1)).setProfileKey(encryptProfileKey(admin1, adminProfileKey)).setTimestamp(5000)).addRequestingMembers(RequestingMember.newBuilder().setUserId(groupOperations.encryptUuid(member1)).setProfileKey(encryptProfileKey(member1, memberProfileKey)).setTimestamp(15000)).build();
    DecryptedGroup decryptedGroup = groupOperations.decryptGroup(group);
    assertEquals(DecryptedGroup.newBuilder().addRequestingMembers(DecryptedRequestingMember.newBuilder().setUuid(UuidUtil.toByteString(admin1)).setProfileKey(ByteString.copyFrom(adminProfileKey.serialize())).setTimestamp(5000)).addRequestingMembers(DecryptedRequestingMember.newBuilder().setUuid(UuidUtil.toByteString(member1)).setProfileKey(ByteString.copyFrom(memberProfileKey.serialize())).setTimestamp(15000)).build().getRequestingMembersList(), decryptedGroup.getRequestingMembersList());
}
Also used : Group(org.signal.storageservice.protos.groups.Group) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) Test(org.junit.Test)

Example 75 with ProfileKey

use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.

the class GroupsV2Operations_decrypt_change_Test method can_decrypt_member_additions_direct_to_admin_field3.

@Test
public void can_decrypt_member_additions_direct_to_admin_field3() {
    UUID self = UUID.randomUUID();
    UUID newMember = UUID.randomUUID();
    ProfileKey profileKey = newProfileKey();
    GroupCandidate groupCandidate = groupCandidate(newMember, profileKey);
    assertDecryption(groupOperations.createModifyGroupMembershipChange(Collections.singleton(groupCandidate), self).setRevision(10), DecryptedGroupChange.newBuilder().setRevision(10).addNewMembers(DecryptedMember.newBuilder().setRole(Member.Role.DEFAULT).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setJoinedAtRevision(10).setUuid(UuidUtil.toByteString(newMember))));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Aggregations

ProfileKey (org.signal.zkgroup.profiles.ProfileKey)150 Test (org.junit.Test)102 UUID (java.util.UUID)90 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)50 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)50 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)34 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)28 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)28 IOException (java.io.IOException)24 GroupChange (org.signal.storageservice.protos.groups.GroupChange)14 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)14 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)12 InvalidInputException (org.signal.zkgroup.InvalidInputException)8 ProfileKeyCredential (org.signal.zkgroup.profiles.ProfileKeyCredential)8 Recipient (org.thoughtcrime.securesms.recipients.Recipient)8 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)8 NonNull (androidx.annotation.NonNull)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)6 IdentityKey (org.whispersystems.libsignal.IdentityKey)6