Group Manager V2 operations.

This commit is contained in:
Alan Evans
2020-05-05 12:13:53 -03:00
committed by Alex Hart
parent 48a693793f
commit 86f0456e8c
36 changed files with 1133 additions and 298 deletions

View File

@@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
import org.signal.zkgroup.InvalidInputException;
import org.signal.zkgroup.profiles.ProfileKey;
import org.signal.zkgroup.profiles.ProfileKeyCredential;
import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.Util;
@@ -53,6 +54,18 @@ public final class ProfileKeyUtil {
return null;
}
public static @Nullable ProfileKeyCredential profileKeyCredentialOrNull(@Nullable byte[] profileKeyCredential) {
if (profileKeyCredential != null) {
try {
return new ProfileKeyCredential(profileKeyCredential);
} catch (InvalidInputException e) {
Log.w(TAG, String.format(Locale.US, "Seen non-null profile key credential of wrong length %d", profileKeyCredential.length), e);
}
}
return null;
}
public static @NonNull ProfileKey profileKeyOrThrow(@NonNull byte[] profileKey) {
try {
return new ProfileKey(profileKey);
@@ -69,6 +82,10 @@ public final class ProfileKeyUtil {
return Optional.of(profileKeyOrThrow(profileKey));
}
public static @NonNull Optional<ProfileKeyCredential> profileKeyCredentialOptional(@Nullable byte[] profileKey) {
return Optional.fromNullable(profileKeyCredentialOrNull(profileKey));
}
public static @NonNull ProfileKey createNew() {
try {
return new ProfileKey(Util.getSecretBytes(32));