Search in sources :

Example 96 with ProfileKey

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

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)

Example 97 with ProfileKey

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

the class GroupsV2Operations_decrypt_change_Test method can_decrypt_member_requests_field16.

@Test
public void can_decrypt_member_requests_field16() {
    UUID newRequestingMember = UUID.randomUUID();
    ProfileKey profileKey = newProfileKey();
    GroupCandidate groupCandidate = groupCandidate(newRequestingMember, profileKey);
    assertDecryption(groupOperations.createGroupJoinRequest(groupCandidate.getProfileKeyCredential().get()).setRevision(10), DecryptedGroupChange.newBuilder().setRevision(10).addNewRequestingMembers(DecryptedRequestingMember.newBuilder().setUuid(UuidUtil.toByteString(newRequestingMember)).setProfileKey(ByteString.copyFrom(profileKey.serialize()))));
}
Also used : UUID(java.util.UUID) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) Test(org.junit.Test)

Example 98 with ProfileKey

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

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 99 with ProfileKey

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

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 100 with ProfileKey

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

the class DecryptedGroupUtil_apply_Test method apply_modify_member_profile_keys.

@Test
public void apply_modify_member_profile_keys() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey1 = randomProfileKey();
    ProfileKey profileKey2a = randomProfileKey();
    ProfileKey profileKey2b = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID(), profileKey1);
    DecryptedMember member2a = member(UUID.randomUUID(), profileKey2a);
    DecryptedMember member2b = withProfileKey(member2a, profileKey2b);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addMembers(member1).addMembers(member2a).build(), DecryptedGroupChange.newBuilder().setRevision(14).addModifiedProfileKeys(member2b).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member1).addMembers(member2b).build(), newGroup);
}
Also used : ProtoTestUtils.withProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey) ProfileKey(org.signal.zkgroup.profiles.ProfileKey) ProtoTestUtils.randomProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey) ProtoTestUtils.newProfileKey(org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey) DecryptedGroup(org.signal.storageservice.protos.groups.local.DecryptedGroup) DecryptedMember(org.signal.storageservice.protos.groups.local.DecryptedMember) 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