use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupsV2Operations_decrypt_change_Test method can_decrypt_member_direct_join_field3.
@Test
public void can_decrypt_member_direct_join_field3() {
UUID newMember = UUID.randomUUID();
ProfileKey profileKey = newProfileKey();
GroupCandidate groupCandidate = groupCandidate(newMember, profileKey);
assertDecryption(groupOperations.createGroupJoinDirect(groupCandidate.getProfileKeyCredential().get()).setRevision(10), DecryptedGroupChange.newBuilder().setRevision(10).addNewMembers(DecryptedMember.newBuilder().setRole(Member.Role.DEFAULT).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setJoinedAtRevision(10).setUuid(UuidUtil.toByteString(newMember))));
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class ProfileUtil method getProfileKey.
private static ProfileKey getProfileKey(@NonNull Recipient recipient) throws IOException {
byte[] profileKeyBytes = recipient.getProfileKey();
if (profileKeyBytes == null) {
Log.w(TAG, "Profile key unknown for " + recipient.getId());
throw new IOException("No profile key");
}
ProfileKey profileKey;
try {
profileKey = new ProfileKey(profileKeyBytes);
} catch (InvalidInputException e) {
Log.w(TAG, "Profile key invalid for " + recipient.getId());
throw new IOException("Invalid profile key");
}
return profileKey;
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class TextSecurePreferences method clearLocalCredentials.
private static void clearLocalCredentials(Context context) {
ProfileKey newProfileKey = ProfileKeyUtil.createNew();
Recipient self = Recipient.self();
SignalDatabase.recipients().setProfileKey(self.getId(), newProfileKey);
ApplicationDependencies.getGroupsV2Authorization().clear();
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class GroupChangeUtil_resolveConflict_decryptedOnly_Test method field_6__profile_key_changes.
@Test
public void field_6__profile_key_changes() {
UUID member1 = UUID.randomUUID();
UUID member2 = UUID.randomUUID();
UUID member3 = UUID.randomUUID();
UUID memberNotInGroup = UUID.randomUUID();
ProfileKey profileKey1 = randomProfileKey();
ProfileKey profileKey2 = randomProfileKey();
ProfileKey profileKey3 = randomProfileKey();
ProfileKey profileKey4 = randomProfileKey();
ProfileKey profileKey2b = randomProfileKey();
DecryptedGroup groupState = DecryptedGroup.newBuilder().addMembers(member(member1, profileKey1)).addMembers(member(member2, profileKey2)).addMembers(member(member3, profileKey3)).build();
DecryptedGroupChange decryptedChange = DecryptedGroupChange.newBuilder().addModifiedProfileKeys(member(member1, profileKey1)).addModifiedProfileKeys(member(member2, profileKey2b)).addModifiedProfileKeys(member(member3, profileKey3)).addModifiedProfileKeys(member(memberNotInGroup, profileKey4)).build();
DecryptedGroupChange resolvedChanges = GroupChangeUtil.resolveConflict(groupState, decryptedChange).build();
DecryptedGroupChange expected = DecryptedGroupChange.newBuilder().addModifiedProfileKeys(member(member2, profileKey2b)).build();
assertEquals(expected, resolvedChanges);
}
use of org.signal.zkgroup.profiles.ProfileKey in project Signal-Android by signalapp.
the class ProfileCipherTest method testEncryptDecrypt.
@Test
public void testEncryptDecrypt() throws InvalidCiphertextException, InvalidInputException {
ProfileKey key = new ProfileKey(Util.getSecretBytes(32));
ProfileCipher cipher = new ProfileCipher(key);
byte[] name = cipher.encrypt("Clement\0Duval".getBytes(), 53);
String plaintext = cipher.decryptString(name);
assertEquals(plaintext, "Clement\0Duval");
}
Aggregations