use of org.signal.zkgroup.groups.UuidCiphertext in project Signal-Android by WhisperSystems.
the class PendingMemberInvitesViewModel method revokeInviteFor.
void revokeInviteFor(@NonNull GroupMemberEntry.PendingMember pendingMember) {
UuidCiphertext inviteeCipherText = pendingMember.getInviteeCipherText();
InviteRevokeConfirmationDialog.showOwnInviteRevokeConfirmationDialog(context, pendingMember.getInvitee(), () -> SimpleTask.run(() -> {
pendingMember.setBusy(true);
try {
return pendingMemberRepository.revokeInvites(Collections.singleton(inviteeCipherText));
} finally {
pendingMember.setBusy(false);
}
}, result -> {
if (result) {
ArrayList<GroupMemberEntry.PendingMember> newList = new ArrayList<>(whoYouInvited.getValue());
Iterator<GroupMemberEntry.PendingMember> iterator = newList.iterator();
while (iterator.hasNext()) {
if (iterator.next().getInviteeCipherText().equals(inviteeCipherText)) {
iterator.remove();
}
}
whoYouInvited.setValue(newList);
} else {
toastErrorCanceling(1);
}
}));
}
use of org.signal.zkgroup.groups.UuidCiphertext in project Signal-Android by WhisperSystems.
the class GroupManagerV2 method getUuidCipherTexts.
@WorkerThread
@NonNull
Map<UUID, UuidCiphertext> getUuidCipherTexts(@NonNull GroupId.V2 groupId) {
GroupDatabase.GroupRecord groupRecord = SignalDatabase.groups().requireGroup(groupId);
GroupDatabase.V2GroupProperties v2GroupProperties = groupRecord.requireV2GroupProperties();
GroupMasterKey groupMasterKey = v2GroupProperties.getGroupMasterKey();
ClientZkGroupCipher clientZkGroupCipher = new ClientZkGroupCipher(GroupSecretParams.deriveFromMasterKey(groupMasterKey));
List<Recipient> recipients = v2GroupProperties.getMemberRecipients(GroupDatabase.MemberSet.FULL_MEMBERS_INCLUDING_SELF);
Map<UUID, UuidCiphertext> uuidCipherTexts = new HashMap<>();
for (Recipient recipient : recipients) {
uuidCipherTexts.put(recipient.requireServiceId().uuid(), clientZkGroupCipher.encryptUuid(recipient.requireServiceId().uuid()));
}
return uuidCipherTexts;
}
use of org.signal.zkgroup.groups.UuidCiphertext in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_change_Test method can_decrypt_pending_member_removals_field8.
@Test
public void can_decrypt_pending_member_removals_field8() throws InvalidInputException {
UUID oldMember = UUID.randomUUID();
UuidCiphertext uuidCiphertext = new UuidCiphertext(groupOperations.encryptUuid(oldMember).toByteArray());
assertDecryption(groupOperations.createRemoveInvitationChange(Collections.singleton(uuidCiphertext)), DecryptedGroupChange.newBuilder().addDeletePendingMembers(DecryptedPendingMemberRemoval.newBuilder().setUuid(UuidUtil.toByteString(oldMember)).setUuidCipherText(ByteString.copyFrom(uuidCiphertext.serialize()))));
}
use of org.signal.zkgroup.groups.UuidCiphertext in project Signal-Android by WhisperSystems.
the class PendingMemberInvitesRepository method getInvitees.
public void getInvitees(@NonNull Consumer<InviteeResult> onInviteesLoaded) {
executor.execute(() -> {
GroupDatabase groupDatabase = SignalDatabase.groups();
GroupDatabase.V2GroupProperties v2GroupProperties = groupDatabase.getGroup(groupId).get().requireV2GroupProperties();
DecryptedGroup decryptedGroup = v2GroupProperties.getDecryptedGroup();
List<DecryptedPendingMember> pendingMembersList = decryptedGroup.getPendingMembersList();
List<SinglePendingMemberInvitedByYou> byMe = new ArrayList<>(pendingMembersList.size());
List<MultiplePendingMembersInvitedByAnother> byOthers = new ArrayList<>(pendingMembersList.size());
ByteString self = Recipient.self().requireServiceId().toByteString();
boolean selfIsAdmin = v2GroupProperties.isAdmin(Recipient.self());
Stream.of(pendingMembersList).groupBy(DecryptedPendingMember::getAddedByUuid).forEach(g -> {
ByteString inviterUuid = g.getKey();
List<DecryptedPendingMember> invitedMembers = g.getValue();
if (self.equals(inviterUuid)) {
for (DecryptedPendingMember pendingMember : invitedMembers) {
try {
Recipient invitee = GroupProtoUtil.pendingMemberToRecipient(context, pendingMember);
UuidCiphertext uuidCipherText = new UuidCiphertext(pendingMember.getUuidCipherText().toByteArray());
byMe.add(new SinglePendingMemberInvitedByYou(invitee, uuidCipherText));
} catch (InvalidInputException e) {
Log.w(TAG, e);
}
}
} else {
Recipient inviter = GroupProtoUtil.uuidByteStringToRecipient(context, inviterUuid);
ArrayList<UuidCiphertext> uuidCipherTexts = new ArrayList<>(invitedMembers.size());
for (DecryptedPendingMember pendingMember : invitedMembers) {
try {
uuidCipherTexts.add(new UuidCiphertext(pendingMember.getUuidCipherText().toByteArray()));
} catch (InvalidInputException e) {
Log.w(TAG, e);
}
}
byOthers.add(new MultiplePendingMembersInvitedByAnother(inviter, uuidCipherTexts));
}
});
onInviteesLoaded.accept(new InviteeResult(byMe, byOthers, selfIsAdmin));
});
}
Aggregations