Include zkgroup 0.4.1

All behind feature flag, excluding .so files for space.
master
Alan Evans 2020-03-19 16:54:25 -03:00 committed by Greyson Parrelli
parent e3ea36c76f
commit 624837fcf1
23 changed files with 24 additions and 163 deletions

View File

@ -160,6 +160,7 @@ android {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/proguard/androidx-annotations.pro'
exclude 'lib/*/libzkgroup.so' // TODO: GV2 Remove line to include .so when used
}
buildTypes {
@ -287,6 +288,7 @@ dependencies {
implementation 'org.signal:aesgcmprovider:0.0.3'
implementation project(':libsignal-service')
implementation 'org.signal:zkgroup-android:0.4.1'
implementation 'org.signal:argon2:13.1@aar'

View File

@ -12,6 +12,7 @@ import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
import org.thoughtcrime.securesms.profiles.ProfileName;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.util.FeatureFlags;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.api.SignalServiceAccountManager;
@ -48,7 +49,7 @@ public final class ProfileUploadJob extends BaseJob {
try (StreamDetails avatar = AvatarHelper.getSelfProfileAvatarStream(context)) {
if (FeatureFlags.VERSIONED_PROFILES) {
accountManager.setVersionedProfile(profileKey, profileName.serialize(), avatar);
accountManager.setVersionedProfile(Recipient.self().getUuid().get(), profileKey, profileName.serialize(), avatar);
} else {
accountManager.setProfileName(profileKey, profileName.serialize());
accountManager.setProfileAvatar(profileKey, avatar);

View File

@ -18,6 +18,8 @@ import org.whispersystems.signalservice.api.SignalServiceAccountManager;
import org.whispersystems.signalservice.api.push.exceptions.PushNetworkException;
import org.whispersystems.signalservice.api.util.StreamDetails;
import java.util.UUID;
public class RotateProfileKeyJob extends BaseJob {
public static String KEY = "RotateProfileKeyJob";
@ -55,7 +57,8 @@ public class RotateProfileKeyJob extends BaseJob {
recipientDatabase.setProfileKey(self.getId(), profileKey);
try (StreamDetails avatarStream = AvatarHelper.getSelfProfileAvatarStream(context)) {
if (FeatureFlags.VERSIONED_PROFILES) {
accountManager.setVersionedProfile(profileKey,
accountManager.setVersionedProfile(self.getUuid().get(),
profileKey,
TextSecurePreferences.getProfileName(context).serialize(),
avatarStream);
} else {

View File

@ -357,6 +357,12 @@ dependencyVerification {
['org.signal:signal-metadata-java:0.1.0',
'f3faa23b7d9b5096d12979c35679d1e3b5e007522d8bef167a28e456f2a7c7d9'],
['org.signal:zkgroup-android:0.4.1',
'52049e207531ef50160873ad4a44682ce2bfb7706e5e4179035d9632eb9d5eac'],
['org.signal:zkgroup-java:0.4.1',
'12ea7e18c58aaefdbb8eccb748deff4f7c8fbd950eeb9c426dc894de50a83b77'],
['org.threeten:threetenbp:1.3.6',
'f4c23ffaaed717c3b99c003e0ee02d6d66377fd47d866fec7d971bd8644fc1a7'],

View File

@ -36,7 +36,7 @@ dependencies {
api 'com.squareup.okhttp3:okhttp:3.12.10'
implementation 'org.threeten:threetenbp:1.3.6'
api project(':zkgroups')
api 'org.signal:zkgroup-java:0.4.1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.assertj:assertj-core:1.7.1'

View File

@ -644,7 +644,7 @@ public class SignalServiceAccountManager {
this.pushServiceSocket.setProfileAvatar(profileAvatarData);
}
public void setVersionedProfile(ProfileKey profileKey, String name, StreamDetails avatar)
public void setVersionedProfile(UUID uuid, ProfileKey profileKey, String name, StreamDetails avatar)
throws IOException
{
if (!FeatureFlags.VERSIONED_PROFILES) {
@ -664,10 +664,10 @@ public class SignalServiceAccountManager {
new ProfileCipherOutputStreamFactory(profileKey));
}
this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion().serialize(),
this.pushServiceSocket.writeProfile(new SignalServiceProfileWrite(profileKey.getProfileKeyVersion(uuid).serialize(),
ciphertextName,
hasAvatar,
profileKey.getCommitment().serialize()),
profileKey.getCommitment(uuid).serialize()),
profileAvatarData);
}

View File

@ -187,8 +187,8 @@ public class SignalServiceMessagePipe {
.addAllHeaders(headers);
if (FeatureFlags.VERSIONED_PROFILES && requestType == SignalServiceProfile.RequestType.PROFILE_AND_CREDENTIAL && uuid.isPresent() && profileKey.isPresent()) {
ProfileKeyVersion profileKeyIdentifier = profileKey.get().getProfileKeyVersion();
UUID target = uuid.get();
ProfileKeyVersion profileKeyIdentifier = profileKey.get().getProfileKeyVersion(target);
requestContext = clientZkProfile.createProfileKeyCredentialRequestContext(random, target, profileKey.get());
ProfileKeyCredentialRequest request = requestContext.getRequest();

View File

@ -99,7 +99,7 @@ public class SignalServiceMessageReceiver {
this.signalAgent = signalAgent;
this.connectivityListener = listener;
this.sleepTimer = timer;
this.clientZkProfile = new ClientZkProfileOperations(new ServerPublicParams(urls.getZkGroupServerPublicParams()));
this.clientZkProfile = FeatureFlags.ZK_GROUPS ? new ClientZkProfileOperations(new ServerPublicParams(urls.getZkGroupServerPublicParams())) : null;
}
/**

View File

@ -567,7 +567,7 @@ public class PushServiceSocket {
}
try {
ProfileKeyVersion profileKeyIdentifier = profileKey.getProfileKeyVersion();
ProfileKeyVersion profileKeyIdentifier = profileKey.getProfileKeyVersion(target);
ProfileKeyCredentialRequestContext requestContext = clientZkOperations.getProfileOperations().createProfileKeyCredentialRequestContext(random, target, profileKey);
ProfileKeyCredentialRequest request = requestContext.getRequest();

View File

@ -27,6 +27,9 @@ dependencyVerification {
['org.signal:signal-metadata-java:0.1.0',
'f3faa23b7d9b5096d12979c35679d1e3b5e007522d8bef167a28e456f2a7c7d9'],
['org.signal:zkgroup-java:0.4.1',
'12ea7e18c58aaefdbb8eccb748deff4f7c8fbd950eeb9c426dc894de50a83b77'],
['org.threeten:threetenbp:1.3.6',
'f4c23ffaaed717c3b99c003e0ee02d6d66377fd47d866fec7d971bd8644fc1a7'],

View File

@ -1,3 +0,0 @@
apply plugin: 'java-library'
sourceCompatibility = 1.7

View File

@ -1,6 +0,0 @@
package org.signal.zkgroup;
public final class InvalidInputException extends Exception {
public InvalidInputException() {
}
}

View File

@ -1,6 +0,0 @@
package org.signal.zkgroup;
public final class ServerPublicParams {
public ServerPublicParams(byte[] zkGroupServerPublicParams) {
}
}

View File

@ -1,4 +0,0 @@
package org.signal.zkgroup;
public final class VerificationFailedException extends Exception {
}

View File

@ -1,20 +0,0 @@
package org.signal.zkgroup.profiles;
import org.signal.zkgroup.ServerPublicParams;
import org.signal.zkgroup.VerificationFailedException;
import java.security.SecureRandom;
import java.util.UUID;
public final class ClientZkProfileOperations {
public ClientZkProfileOperations(ServerPublicParams serverPublicParams) {
}
public ProfileKeyCredentialRequestContext createProfileKeyCredentialRequestContext(SecureRandom random, UUID target, ProfileKey profileKey) {
throw new AssertionError();
}
public ProfileKeyCredential receiveProfileKeyCredential(ProfileKeyCredentialRequestContext requestContext, ProfileKeyCredentialResponse profileKeyCredentialResponse) throws VerificationFailedException {
throw new AssertionError();
}
}

View File

@ -1,50 +0,0 @@
package org.signal.zkgroup.profiles;
import org.signal.zkgroup.InvalidInputException;
import java.util.Arrays;
/**
* Unlike the rest of this place-holder library, this does function as a wrapper around the
* traditional byte array used for profile keys.
*/
public final class ProfileKey {
public static final int SIZE = 32;
private final byte[] profileKey;
public ProfileKey(byte[] profileKey) throws InvalidInputException {
if (profileKey == null || profileKey.length != SIZE) {
throw new InvalidInputException();
}
this.profileKey = profileKey.clone();
}
public ProfileKeyVersion getProfileKeyVersion() {
throw new AssertionError();
}
public ProfileKeyCommitment getCommitment() {
throw new AssertionError();
}
public byte[] serialize() {
return this.profileKey.clone();
}
@Override
public boolean equals(Object o) {
if(o == null || o.getClass() != getClass()) return false;
ProfileKey other = (ProfileKey) o;
return Arrays.equals(profileKey, other.profileKey);
}
@Override
public int hashCode() {
return Arrays.hashCode(profileKey);
}
}

View File

@ -1,10 +0,0 @@
package org.signal.zkgroup.profiles;
public final class ProfileKeyCommitment {
private ProfileKeyCommitment() {
}
public byte[] serialize() {
throw new AssertionError();
}
}

View File

@ -1,13 +0,0 @@
package org.signal.zkgroup.profiles;
import org.signal.zkgroup.InvalidInputException;
public final class ProfileKeyCredential {
public ProfileKeyCredential(byte[] bytes) throws InvalidInputException {
throw new AssertionError();
}
public byte[] serialize() {
throw new AssertionError();
}
}

View File

@ -1,10 +0,0 @@
package org.signal.zkgroup.profiles;
public final class ProfileKeyCredentialRequest {
private ProfileKeyCredentialRequest() {
}
public byte[] serialize() {
throw new AssertionError();
}
}

View File

@ -1,10 +0,0 @@
package org.signal.zkgroup.profiles;
public final class ProfileKeyCredentialRequestContext {
private ProfileKeyCredentialRequestContext() {
}
public ProfileKeyCredentialRequest getRequest() {
throw new AssertionError();
}
}

View File

@ -1,9 +0,0 @@
package org.signal.zkgroup.profiles;
import org.signal.zkgroup.InvalidInputException;
public final class ProfileKeyCredentialResponse {
public ProfileKeyCredentialResponse(byte[] bytes) throws InvalidInputException {
throw new AssertionError();
}
}

View File

@ -1,10 +0,0 @@
package org.signal.zkgroup.profiles;
public final class ProfileKeyVersion {
private ProfileKeyVersion() {
}
public String serialize() {
throw new AssertionError();
}
}

View File

@ -7,6 +7,3 @@ project(':libsignal-service').projectDir = file('libsignal/service')
project(':').buildFileName = 'main.gradle'
rootProject.name='Signal'
include ':zkgroups'
project(':zkgroups').projectDir = file('libsignal/zkgroups-api')