use of org.signal.zkgroup.groups.GroupSecretParams in project Signal-Android by WhisperSystems.
the class AvatarGroupsV2DownloadJob method downloadGroupAvatarBytes.
@Nullable
public static byte[] downloadGroupAvatarBytes(@NonNull Context context, @NonNull GroupMasterKey groupMasterKey, @NonNull String cdnKey) throws IOException {
if (cdnKey.length() == 0) {
return null;
}
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
File attachment = File.createTempFile("avatar", "gv2", context.getCacheDir());
attachment.deleteOnExit();
SignalServiceMessageReceiver receiver = ApplicationDependencies.getSignalServiceMessageReceiver();
byte[] encryptedData;
try (FileInputStream inputStream = receiver.retrieveGroupsV2ProfileAvatar(cdnKey, attachment, AVATAR_DOWNLOAD_FAIL_SAFE_MAX_SIZE)) {
encryptedData = new byte[(int) attachment.length()];
StreamUtil.readFully(inputStream, encryptedData);
GroupsV2Operations operations = ApplicationDependencies.getGroupsV2Operations();
GroupsV2Operations.GroupOperations groupOperations = operations.forGroup(groupSecretParams);
return groupOperations.decryptAvatar(encryptedData);
} finally {
if (attachment.exists())
if (!attachment.delete()) {
Log.w(TAG, "Unable to delete temp avatar file");
}
}
}
use of org.signal.zkgroup.groups.GroupSecretParams in project Signal-Android by WhisperSystems.
the class GroupsV2Operations_decrypt_groupJoinInfo_Test method setup.
@Before
public void setup() throws InvalidInputException {
LibSignalLibraryUtil.assumeLibSignalSupportedOnOS();
TestZkGroupServer server = new TestZkGroupServer();
ClientZkOperations clientZkOperations = new ClientZkOperations(server.getServerPublicParams());
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(new GroupMasterKey(Util.getSecretBytes(32)));
groupOperations = new GroupsV2Operations(clientZkOperations).forGroup(groupSecretParams);
}
use of org.signal.zkgroup.groups.GroupSecretParams in project Signal-Android by WhisperSystems.
the class GroupManagerV2 method migrateGroupOnToServer.
@WorkerThread
void migrateGroupOnToServer(@NonNull GroupId.V1 groupIdV1, @NonNull Collection<Recipient> members) throws IOException, MembershipNotSuitableForV2Exception, GroupAlreadyExistsException, GroupChangeFailedException {
GroupMasterKey groupMasterKey = groupIdV1.deriveV2MigrationMasterKey();
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
GroupDatabase.GroupRecord groupRecord = groupDatabase.requireGroup(groupIdV1);
String name = Util.emptyIfNull(groupRecord.getTitle());
byte[] avatar = groupRecord.hasAvatar() ? AvatarHelper.getAvatarBytes(context, groupRecord.getRecipientId()) : null;
int messageTimer = Recipient.resolved(groupRecord.getRecipientId()).getExpiresInSeconds();
Set<RecipientId> memberIds = Stream.of(members).map(Recipient::getId).filterNot(m -> m.equals(Recipient.self().getId())).collect(Collectors.toSet());
createGroupOnServer(groupSecretParams, name, avatar, memberIds, Member.Role.ADMINISTRATOR, messageTimer);
}
use of org.signal.zkgroup.groups.GroupSecretParams in project Signal-Android by WhisperSystems.
the class GroupManagerV2 method getGroupExternalCredential.
@WorkerThread
@NonNull
GroupExternalCredential getGroupExternalCredential(@NonNull GroupId.V2 groupId) throws IOException, VerificationFailedException {
GroupMasterKey groupMasterKey = SignalDatabase.groups().requireGroup(groupId).requireV2GroupProperties().getGroupMasterKey();
GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
return groupsV2Api.getGroupExternalCredential(authorization.getAuthorizationForToday(selfAci, groupSecretParams));
}
Aggregations