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));
}
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);
}
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);
}
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);
}
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);
}
Aggregations