Search in sources :

Example 1 with ClientZkGroupCipher

use of org.signal.zkgroup.groups.ClientZkGroupCipher 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;
}
Also used : HashMap(java.util.HashMap) UuidCiphertext(org.signal.zkgroup.groups.UuidCiphertext) GroupDatabase(org.thoughtcrime.securesms.database.GroupDatabase) GroupMasterKey(org.signal.zkgroup.groups.GroupMasterKey) Recipient(org.thoughtcrime.securesms.recipients.Recipient) ClientZkGroupCipher(org.signal.zkgroup.groups.ClientZkGroupCipher) UUID(java.util.UUID) WorkerThread(androidx.annotation.WorkerThread) NonNull(androidx.annotation.NonNull)

Example 2 with ClientZkGroupCipher

use of org.signal.zkgroup.groups.ClientZkGroupCipher 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();
}
Also used : AvatarUploadAttributes(org.signal.storageservice.protos.groups.AvatarUploadAttributes) ClientZkGroupCipher(org.signal.zkgroup.groups.ClientZkGroupCipher) VerificationFailedException(org.signal.zkgroup.VerificationFailedException)

Aggregations

ClientZkGroupCipher (org.signal.zkgroup.groups.ClientZkGroupCipher)2 NonNull (androidx.annotation.NonNull)1 WorkerThread (androidx.annotation.WorkerThread)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1 AvatarUploadAttributes (org.signal.storageservice.protos.groups.AvatarUploadAttributes)1 VerificationFailedException (org.signal.zkgroup.VerificationFailedException)1 GroupMasterKey (org.signal.zkgroup.groups.GroupMasterKey)1 UuidCiphertext (org.signal.zkgroup.groups.UuidCiphertext)1 GroupDatabase (org.thoughtcrime.securesms.database.GroupDatabase)1 Recipient (org.thoughtcrime.securesms.recipients.Recipient)1