From d335b7a0330d3d1139c1292e67a0b50fdff6d058 Mon Sep 17 00:00:00 2001 From: Katherine Date: Tue, 29 Oct 2024 15:55:45 -0400 Subject: [PATCH] Align `KeyTransparencySearchResponse` with distinguished counterpart and update `DistinguishedResponse` field names --- .../KeyTransparencyController.java | 5 +---- ...yTransparencyDistinguishedKeyResponse.java | 2 +- .../KeyTransparencySearchResponse.java | 20 ++----------------- .../main/proto/KeyTransparencyService.proto | 4 ++-- .../KeyTransparencyControllerTest.java | 9 ++------- 5 files changed, 8 insertions(+), 32 deletions(-) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyController.java index a48f8ea8c..85a8d8003 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyController.java @@ -123,10 +123,7 @@ public class KeyTransparencyController { KEY_TRANSPARENCY_RPC_TIMEOUT) .thenApply(searchResponse -> new KeyTransparencySearchResponse( - searchResponse.getTreeHead().toByteArray(), - searchResponse.getAci().toByteArray(), - searchResponse.hasE164() ? Optional.of(searchResponse.getE164().toByteArray()) : Optional.empty(), - searchResponse.hasUsernameHash() ? Optional.of(searchResponse.getUsernameHash().toByteArray()) : Optional.empty()) + searchResponse.toByteArray()) ).join(); } catch (final CancellationException exception) { LOGGER.error("Unexpected cancellation from key transparency service", exception); diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencyDistinguishedKeyResponse.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencyDistinguishedKeyResponse.java index 370c25f6c..02dfec21a 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencyDistinguishedKeyResponse.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencyDistinguishedKeyResponse.java @@ -15,6 +15,6 @@ public record KeyTransparencyDistinguishedKeyResponse( @NotNull @JsonSerialize(using = ByteArrayAdapter.Serializing.class) @JsonDeserialize(using = ByteArrayAdapter.Deserializing.class) - @Schema(description = "The response for the distinguished tree head encoded in standard un-padded base64") + @Schema(description = "The serialized `DistinguishedResponse` encoded in standard un-padded base64") byte[] distinguishedKeyResponse ) {} diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencySearchResponse.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencySearchResponse.java index 468eb8eca..3b2068cb9 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencySearchResponse.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/KeyTransparencySearchResponse.java @@ -17,22 +17,6 @@ public record KeyTransparencySearchResponse( @NotNull @JsonSerialize(using = ByteArrayAdapter.Serializing.class) @JsonDeserialize(using = ByteArrayAdapter.Deserializing.class) - @Schema(description = "The `FullTreeHead` protobuf encoded in standard un-padded base64. This should be used across all identifiers.") - byte[] fullTreeHead, - - @NotNull - @JsonSerialize(using = ByteArrayAdapter.Serializing.class) - @JsonDeserialize(using = ByteArrayAdapter.Deserializing.class) - @Schema(description = "The `TreeSearchResponse` protobuf for the ACI identifier encoded in standard un-padded base64") - byte[] aciSearchResponse, - - @JsonSerialize(contentUsing = ByteArrayAdapter.Serializing.class) - @JsonDeserialize(contentUsing = ByteArrayAdapter.Deserializing.class) - @Schema(description = "The `TreeSearchResponse` protobuf for the E164 encoded in standard un-padded base64") - Optional e164SearchResponse, - - @JsonSerialize(contentUsing = ByteArrayAdapter.Serializing.class) - @JsonDeserialize(contentUsing = ByteArrayAdapter.Deserializing.class) - @Schema(description = "The `TreeSearchResponse` protobuf for the username hash encoded in standard un-padded base64") - Optional usernameHashSearchResponse + @Schema(description = "The serialized `SearchResponse` encoded in standard un-padded base64.") + byte[] serializedResponse ) {} diff --git a/service/src/main/proto/KeyTransparencyService.proto b/service/src/main/proto/KeyTransparencyService.proto index bad88a23d..2001d0282 100644 --- a/service/src/main/proto/KeyTransparencyService.proto +++ b/service/src/main/proto/KeyTransparencyService.proto @@ -152,11 +152,11 @@ message DistinguishedResponse { * A signed representation of the log tree's current state along with some * additional information necessary for validation such as a consistency proof and an auditor-signed tree head. */ - FullTreeHead full_tree_head = 1; + FullTreeHead tree_head = 1; /** * This search response is always provided. */ - TreeSearchResponse distinguished_response = 2; + TreeSearchResponse distinguished = 2; } message TreeSearchResponse { diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyControllerTest.java index 0df1a327b..8cd2b79fc 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/KeyTransparencyControllerTest.java @@ -172,13 +172,8 @@ public class KeyTransparencyControllerTest { final KeyTransparencySearchResponse keyTransparencySearchResponse = response.readEntity( KeyTransparencySearchResponse.class); - assertNotNull(keyTransparencySearchResponse.fullTreeHead()); - assertNotNull(keyTransparencySearchResponse.aciSearchResponse()); - - assertEquals(aciSearchResponse, TreeSearchResponse.parseFrom(keyTransparencySearchResponse.aciSearchResponse())); - - e164.ifPresent(ignored -> assertNotNull(keyTransparencySearchResponse.e164SearchResponse())); - usernameHash.ifPresent(ignored -> assertNotNull(keyTransparencySearchResponse.usernameHashSearchResponse())); + assertNotNull(keyTransparencySearchResponse.serializedResponse()); + assertEquals(aciSearchResponse, SearchResponse.parseFrom(keyTransparencySearchResponse.serializedResponse()).getAci()); ArgumentCaptor aciArgument = ArgumentCaptor.forClass(ByteString.class); ArgumentCaptor aciIdentityKeyArgument = ArgumentCaptor.forClass(ByteString.class);