Remove dependency on presentations being present in AddMemberAction.

This commit is contained in:
Jordan Rose 2023-10-20 17:28:29 -07:00 committed by Cody Henthorne
parent 4f754ae309
commit 87bdebb21c
3 changed files with 12 additions and 9 deletions

View file

@ -724,7 +724,7 @@ final class GroupManagerV2 {
List<GroupCandidate> groupCandidates = groupCandidateHelper.recipientIdsToCandidatesList(ids);
return groupOperations.replaceAddMembers(change, groupCandidates);
} catch (InvalidInputException | VerificationFailedException | IOException e) {
} catch (InvalidGroupStateException | InvalidInputException | VerificationFailedException | IOException e) {
Log.w(TAG, "Unable to refetch credentials for added members, failing change", e);
}

View file

@ -577,7 +577,7 @@ public final class GroupsV2Operations {
ACI aci;
ProfileKey profileKey;
if (modifyMemberProfileKeyAction.user_id.size() == 0 || modifyMemberProfileKeyAction.presentation.size() == 0) {
if (modifyMemberProfileKeyAction.user_id.size() == 0 || modifyMemberProfileKeyAction.profile_key.size() == 0) {
ProfileKeyCredentialPresentation presentation = new ProfileKeyCredentialPresentation(modifyMemberProfileKeyAction.presentation.toByteArray());
aci = decryptAci(ByteString.of(presentation.getUuidCiphertext().serialize()));
profileKey = decryptProfileKey(ByteString.of(presentation.getProfileKeyCiphertext().serialize()), aci);
@ -1034,13 +1034,16 @@ public final class GroupsV2Operations {
));
}
public List<ServiceId> decryptAddMembers(List<GroupChange.Actions.AddMemberAction> addMembers) throws InvalidInputException, VerificationFailedException {
public List<ServiceId> decryptAddMembers(List<GroupChange.Actions.AddMemberAction> addMembers) throws InvalidGroupStateException, InvalidInputException, VerificationFailedException {
List<ServiceId> ids = new ArrayList<>(addMembers.size());
for (int i = 0; i < addMembers.size(); i++) {
GroupChange.Actions.AddMemberAction addMember = addMembers.get(i);
ProfileKeyCredentialPresentation profileKeyCredentialPresentation = new ProfileKeyCredentialPresentation(addMember.added.presentation.toByteArray());
for (GroupChange.Actions.AddMemberAction addMember : addMembers) {
if (addMember.added.presentation.size() == 0) {
ids.add(decryptAci(addMember.added.userId));
} else {
ProfileKeyCredentialPresentation profileKeyCredentialPresentation = new ProfileKeyCredentialPresentation(addMember.added.presentation.toByteArray());
ids.add(ServiceId.fromLibSignal(clientZkGroupCipher.decrypt(profileKeyCredentialPresentation.getUuidCiphertext())));
ids.add(ServiceId.fromLibSignal(clientZkGroupCipher.decrypt(profileKeyCredentialPresentation.getUuidCiphertext())));
}
}
return ids;
}

View file

@ -28,7 +28,7 @@ message Member {
bytes userId = 1;
Role role = 2;
bytes profileKey = 3;
bytes presentation = 4;
bytes presentation = 4; // Only set when sending to server
uint32 joinedAtRevision = 5;
}
@ -41,7 +41,7 @@ message PendingMember {
message RequestingMember {
bytes userId = 1;
bytes profileKey = 2;
bytes presentation = 3;
bytes presentation = 3; // Only set when sending to server
uint64 timestamp = 4;
}