use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class SubscriptionReceiptRequestResponseJob method generateRequestContext.
private static ReceiptCredentialRequestContext generateRequestContext() {
Log.d(TAG, "Generating request credentials context for token redemption...", true);
SecureRandom secureRandom = new SecureRandom();
byte[] randomBytes = Util.getSecretBytes(ReceiptSerial.SIZE);
try {
ReceiptSerial receiptSerial = new ReceiptSerial(randomBytes);
ClientZkReceiptOperations operations = ApplicationDependencies.getClientZkReceiptOperations();
return operations.createReceiptCredentialRequestContext(secureRandom, receiptSerial);
} catch (InvalidInputException | VerificationFailedException e) {
Log.e(TAG, "Failed to create credential.", e);
throw new AssertionError(e);
}
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class GroupManagerV2 method createGroupOnServer.
@WorkerThread
@NonNull
private DecryptedGroup createGroupOnServer(@NonNull GroupSecretParams groupSecretParams, @Nullable String name, @Nullable byte[] avatar, @NonNull Collection<RecipientId> members, @NonNull Member.Role memberRole, int disappearingMessageTimerSeconds) throws GroupChangeFailedException, IOException, MembershipNotSuitableForV2Exception, GroupAlreadyExistsException {
if (!GroupsV2CapabilityChecker.allAndSelfHaveUuidAndSupportGroupsV2(members)) {
throw new MembershipNotSuitableForV2Exception("At least one potential new member does not support GV2 capability or we don't have their UUID");
}
GroupCandidate self = groupCandidateHelper.recipientIdToCandidate(Recipient.self().getId());
Set<GroupCandidate> candidates = new HashSet<>(groupCandidateHelper.recipientIdsToCandidates(members));
if (SignalStore.internalValues().gv2ForceInvites()) {
Log.w(TAG, "Forcing GV2 invites due to internal setting");
candidates = GroupCandidate.withoutProfileKeyCredentials(candidates);
}
if (!self.hasProfileKeyCredential()) {
Log.w(TAG, "Cannot create a V2 group as self does not have a versioned profile");
throw new MembershipNotSuitableForV2Exception("Cannot create a V2 group as self does not have a versioned profile");
}
GroupsV2Operations.NewGroup newGroup = groupsV2Operations.createNewGroup(groupSecretParams, name, Optional.fromNullable(avatar), self, candidates, memberRole, disappearingMessageTimerSeconds);
try {
groupsV2Api.putNewGroup(newGroup, authorization.getAuthorizationForToday(selfAci, groupSecretParams));
DecryptedGroup decryptedGroup = groupsV2Api.getGroup(groupSecretParams, ApplicationDependencies.getGroupsV2Authorization().getAuthorizationForToday(selfAci, groupSecretParams));
if (decryptedGroup == null) {
throw new GroupChangeFailedException();
}
return decryptedGroup;
} catch (VerificationFailedException | InvalidGroupStateException e) {
throw new GroupChangeFailedException(e);
} catch (GroupExistsException e) {
throw new GroupAlreadyExistsException(e);
}
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class SignalCallManager method peekGroupCall.
public void peekGroupCall(@NonNull RecipientId id) {
if (callManager == null) {
Log.i(TAG, "Unable to peekGroupCall, call manager is null");
return;
}
networkExecutor.execute(() -> {
try {
Recipient group = Recipient.resolved(id);
GroupId.V2 groupId = group.requireGroupId().requireV2();
GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, groupId);
List<GroupCall.GroupMemberInfo> members = Stream.of(GroupManager.getUuidCipherTexts(context, groupId)).map(entry -> new GroupCall.GroupMemberInfo(entry.getKey(), entry.getValue().serialize())).toList();
callManager.peekGroupCall(SignalStore.internalValues().groupCallingServer(), credential.getTokenBytes().toByteArray(), members, peekInfo -> {
Long threadId = SignalDatabase.threads().getThreadIdFor(group.getId());
if (threadId != null) {
SignalDatabase.sms().updatePreviousGroupCall(threadId, peekInfo.getEraId(), peekInfo.getJoinedMembers(), WebRtcUtil.isCallFull(peekInfo));
ApplicationDependencies.getMessageNotifier().updateNotification(context, threadId, true, 0, BubbleUtil.BubbleState.HIDDEN);
EventBus.getDefault().postSticky(new GroupCallPeekEvent(id, peekInfo.getEraId(), peekInfo.getDeviceCount(), peekInfo.getMaxDevices()));
}
});
} catch (IOException | VerificationFailedException | CallException e) {
Log.e(TAG, "error peeking from active conversation", e);
}
});
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class SignalCallManager method requestMembershipProof.
@Override
public void requestMembershipProof(@NonNull final GroupCall groupCall) {
Log.i(TAG, "requestMembershipProof():");
Recipient recipient = serviceState.getCallInfoState().getCallRecipient();
if (!recipient.isPushV2Group()) {
Log.i(TAG, "Request membership proof for non-group");
return;
}
GroupCall currentGroupCall = serviceState.getCallInfoState().getGroupCall();
if (currentGroupCall == null || currentGroupCall.hashCode() != groupCall.hashCode()) {
Log.i(TAG, "Skipping group membership proof request, requested group call does not match current group call");
return;
}
networkExecutor.execute(() -> {
try {
GroupExternalCredential credential = GroupManager.getGroupExternalCredential(context, recipient.getGroupId().get().requireV2());
process((s, p) -> p.handleGroupRequestMembershipProof(s, groupCall.hashCode(), credential.getTokenBytes().toByteArray()));
} catch (IOException e) {
Log.w(TAG, "Unable to get group membership proof from service", e);
onEnded(groupCall, GroupCall.GroupCallEndReason.SFU_CLIENT_FAILED_TO_JOIN);
} catch (VerificationFailedException e) {
Log.w(TAG, "Unable to verify group membership proof", e);
onEnded(groupCall, GroupCall.GroupCallEndReason.DEVICE_EXPLICITLY_DISCONNECTED);
}
});
}
use of org.signal.zkgroup.VerificationFailedException in project Signal-Android by WhisperSystems.
the class GroupsV2Api method uploadAvatar.
public String uploadAvatar(byte[] avatar, GroupSecretParams groupSecretParams, GroupsV2AuthorizationString authorization) throws IOException {
AvatarUploadAttributes form = socket.getGroupsV2AvatarUploadForm(authorization.toString());
byte[] cipherText;
try {
cipherText = new ClientZkGroupCipher(groupSecretParams).encryptBlob(GroupAttributeBlob.newBuilder().setAvatar(ByteString.copyFrom(avatar)).build().toByteArray());
} catch (VerificationFailedException e) {
throw new AssertionError(e);
}
socket.uploadGroupV2Avatar(cipherText, form);
return form.getKey();
}
Aggregations