Search in sources :

Example 1 with ProfileKey

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

the class UnidentifiedAccessTest method testKeyDerivation.

public void testKeyDerivation() throws InvalidInputException {
    byte[] key = new byte[32];
    Arrays.fill(key, (byte) 0x02);
    byte[] result = UnidentifiedAccess.deriveAccessKeyFrom(new ProfileKey(key));
    assertTrue(Arrays.equals(result, EXPECTED_RESULT));
}
Also used : ProfileKey(org.signal.zkgroup.profiles.ProfileKey)

Example 2 with ProfileKey

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

the class DecryptedGroupUtil_apply_Test method skip_promote_requesting_member_by_direct_add.

@Test
public void skip_promote_requesting_member_by_direct_add() throws NotAbleToApplyGroupV2ChangeException {
    ProfileKey profileKey2 = randomProfileKey();
    ProfileKey profileKey3 = randomProfileKey();
    DecryptedMember member1 = member(UUID.randomUUID());
    UUID requesting2Uuid = UUID.randomUUID();
    UUID requesting3Uuid = UUID.randomUUID();
    UUID requesting4Uuid = UUID.randomUUID();
    DecryptedRequestingMember requesting2 = requestingMember(requesting2Uuid);
    DecryptedRequestingMember requesting3 = requestingMember(requesting3Uuid);
    DecryptedRequestingMember requesting4 = requestingMember(requesting4Uuid);
    DecryptedMember member2 = member(requesting2Uuid, profileKey2);
    DecryptedMember member3 = member(requesting3Uuid, profileKey3);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(10).addMembers(member1).addRequestingMembers(requesting2).addRequestingMembers(requesting3).addRequestingMembers(requesting4).build(), DecryptedGroupChange.newBuilder().setRevision(11).addNewMembers(member2).addNewMembers(member3).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(11).addMembers(member1).addMembers(member2).addMembers(member3).addRequestingMembers(requesting4).build(), newGroup);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) UUID(java.util.UUID) 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)

Example 3 with ProfileKey

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

the class DecryptedGroupUtil_apply_Test method promote_requesting_member.

@Test
public void promote_requesting_member() throws NotAbleToApplyGroupV2ChangeException {
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    UUID uuid3 = UUID.randomUUID();
    ProfileKey profileKey1 = newProfileKey();
    ProfileKey profileKey2 = newProfileKey();
    ProfileKey profileKey3 = newProfileKey();
    DecryptedRequestingMember member1 = requestingMember(uuid1, profileKey1);
    DecryptedRequestingMember member2 = requestingMember(uuid2, profileKey2);
    DecryptedRequestingMember member3 = requestingMember(uuid3, profileKey3);
    DecryptedGroup newGroup = DecryptedGroupUtil.apply(DecryptedGroup.newBuilder().setRevision(13).addRequestingMembers(member1).addRequestingMembers(member2).addRequestingMembers(member3).build(), DecryptedGroupChange.newBuilder().setRevision(14).addPromoteRequestingMembers(DecryptedApproveMember.newBuilder().setRole(Member.Role.DEFAULT).setUuid(member1.getUuid())).addPromoteRequestingMembers(DecryptedApproveMember.newBuilder().setRole(Member.Role.ADMINISTRATOR).setUuid(member2.getUuid())).build());
    assertEquals(DecryptedGroup.newBuilder().setRevision(14).addMembers(member(uuid1, profileKey1)).addMembers(admin(uuid2, profileKey2)).addRequestingMembers(member3).build(), newGroup);
}
Also used : DecryptedRequestingMember(org.signal.storageservice.protos.groups.local.DecryptedRequestingMember) UUID(java.util.UUID) 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) Test(org.junit.Test)

Example 4 with ProfileKey

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

the class GroupChangeUtil_resolveConflict_Test method field_9__promote_pending_members.

@Test
public void field_9__promote_pending_members() {
    UUID member1 = UUID.randomUUID();
    UUID member2 = UUID.randomUUID();
    UUID member3 = UUID.randomUUID();
    ProfileKey profileKey2 = randomProfileKey();
    DecryptedGroup groupState = DecryptedGroup.newBuilder().addMembers(member(member1)).addPendingMembers(pendingMember(member2)).build();
    DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addPromotePendingMembers(member(member1)).addPromotePendingMembers(member(member2)).addPromotePendingMembers(member(member3)).build();
    GroupChange.Actions change = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member1, randomProfileKey()))).addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member2, profileKey2))).addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member3, randomProfileKey()))).build();
    GroupChange.Actions resolvedActions = GroupChangeUtil.resolveConflict(groupState, decryptedChange, change).build();
    GroupChange.Actions expected = GroupChange.Actions.newBuilder().addPromotePendingMembers(GroupChange.Actions.PromotePendingMemberAction.newBuilder().setPresentation(presentation(member2, profileKey2))).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 5 with ProfileKey

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

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)

Aggregations

ProfileKey (org.signal.zkgroup.profiles.ProfileKey)75 Test (org.junit.Test)51 UUID (java.util.UUID)45 DecryptedGroup (org.signal.storageservice.protos.groups.local.DecryptedGroup)25 ProtoTestUtils.randomProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.randomProfileKey)25 DecryptedGroupChange (org.signal.storageservice.protos.groups.local.DecryptedGroupChange)17 ProtoTestUtils.newProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.newProfileKey)14 ProtoTestUtils.withProfileKey (org.whispersystems.signalservice.api.groupsv2.ProtoTestUtils.withProfileKey)14 IOException (java.io.IOException)12 GroupChange (org.signal.storageservice.protos.groups.GroupChange)7 DecryptedMember (org.signal.storageservice.protos.groups.local.DecryptedMember)7 InvalidCiphertextException (org.whispersystems.signalservice.api.crypto.InvalidCiphertextException)6 ProfileKeyCredential (org.signal.zkgroup.profiles.ProfileKeyCredential)4 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)4 NonNull (androidx.annotation.NonNull)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InvalidInputException (org.signal.zkgroup.InvalidInputException)3 RecipientDatabase (org.thoughtcrime.securesms.database.RecipientDatabase)3 Recipient (org.thoughtcrime.securesms.recipients.Recipient)3 SignalServiceProfile (org.whispersystems.signalservice.api.profiles.SignalServiceProfile)3