Class KeyTransparencyClient
-
- All Implemented Interfaces:
public class KeyTransparencyClientTyped API to access the key transparency subsystem using an existing unauthenticated chat connection.
Unlike ChatConnection, key transparency client does not export "raw" send/receive APIs, and instead uses them internally to implement high-level operations.
Note:
StoreAPIs may be invoked concurrently. Here are possible strategies to make sure there are no thread safety violations:- Types implementing
Storecan be made thread safe - KeyTransparencyClient operations-completed asynchronous calls-can be serialized.
Example usage:
var net = new Network(Network.Environment.STAGING, "key-transparency-example"); var chat = net.connectUnauthChat(new Listener()).get(); chat.start(); KeyTransparencyClient client = chat.keyTransparencyClient(); client.search(aci, identityKey, null, null, null, KT_DATA_STORE).get();
-
-
Method Summary
Modifier and Type Method Description CompletableFuture<Void>search(ServiceId.Aci aci, IdentityKey aciIdentityKey, String e164, Array<byte> unidentifiedAccessKey, Array<byte> usernameHash, Store store)Search for account information in the key transparency tree. CompletableFuture<Void>updateDistinguished(Store store)Request the latest distinguished tree head from the server and update it in the local store. CompletableFuture<Void>monitor(ServiceId.Aci aci, IdentityKey aciIdentityKey, String e164, Array<byte> unidentifiedAccessKey, Array<byte> usernameHash, Store store)Issue a monitor request to the key transparency service. -
-
Method Detail
-
search
CompletableFuture<Void> search(ServiceId.Aci aci, IdentityKey aciIdentityKey, String e164, Array<byte> unidentifiedAccessKey, Array<byte> usernameHash, Store store)
Search for account information in the key transparency tree.
Only ACI and ACI identity key are required to identify the account.
If the latest distinguished tree head is not present in the store, it will be requested from the server prior to performing the search via updateDistinguished.
This is an asynchronous operation; all the exceptions occurring during communication with the server will be wrapped in java.util.concurrent.ExecutionException.
Possible exceptions include:
- ChatServiceException for errors related to communication with the server. Depending on the severity, the search can be retried.
- org.signal.libsignal.keytrans.KeyTransparencyException for errors related to key transparency logic, which includes missing required fields in the serialized data. Retrying the search without changing any of the arguments (including the state of the store) is unlikely to yield a different result.
- org.signal.libsignal.keytrans.VerificationFailedException indicates a failure to verify the data in key transparency server response, such as an incorrect proof or a wrong signature.
- Parameters:
aci- the ACI of the account to be searched for.aciIdentityKey- IdentityKey associated with the ACI.e164- string representation of an E.164 number associated with the account.unidentifiedAccessKey- unidentified access key for the account.usernameHash- hash of the username associated with the account.store- local persistent storage for key transparency-related data, such as the latest tree heads and account monitoring data.- Returns:
an instance of CompletableFuture successful completion of which will indicate that the search request has succeeded and store has been updated with the latest account data.
-
updateDistinguished
CompletableFuture<Void> updateDistinguished(Store store)
Request the latest distinguished tree head from the server and update it in the local store.
This is an asynchronous operation; all the exceptions occurring during communication with the server will be wrapped in java.util.concurrent.ExecutionException.
Possible exceptions include:
- ChatServiceException for errors related to communication with the server. Depending on the severity, the request can be retried.
- org.signal.libsignal.keytrans.KeyTransparencyException for errors related to key transparency logic. Retrying the search without changing any of the arguments (including the state of the store) is unlikely to yield a different result.
- Parameters:
store- local persistent storage for key transparency related data, such as the latest tree heads and account monitoring data.- Returns:
An instance of CompletableFuture representing the asynchronous operation, which does not produce any value. Successful completion of the operation results in an updated state of the store.
-
monitor
CompletableFuture<Void> monitor(ServiceId.Aci aci, IdentityKey aciIdentityKey, String e164, Array<byte> unidentifiedAccessKey, Array<byte> usernameHash, Store store)
Issue a monitor request to the key transparency service.
Store must contain data associated with the account being requested prior to making this call. Another way of putting this is: monitor cannot be called before search.
If any of the monitored fields in the server response contain a version that is higher than the one currently in the store, a search request will be performed automatically and, if it succeeds, the updated account data will be stored. Otherwise, if the monitor does not detect any new versions, a search request will not be triggered.
If the latest distinguished tree head is not present in the store, it will be requested from the server prior to performing the search via updateDistinguished.
This is an asynchronous operation; all the exceptions occurring during communication with the server will be wrapped in java.util.concurrent.ExecutionException.
Possible exceptions include:
- ChatServiceException for errors related to communication with the server. Depending on the severity, the search can be retried.
- org.signal.libsignal.keytrans.KeyTransparencyException for errors related to key transparency logic, which includes missing required fields in the serialized data. Retrying the search without changing any of the arguments (including the state of the store) is unlikely to yield a different result.
- org.signal.libsignal.keytrans.VerificationFailedException indicates a failure to verify the data in key transparency server response, such as an incorrect proof or a wrong signature.
- Parameters:
aci- the ACI of the account to be searched for.aciIdentityKey- IdentityKey associated with the ACI.e164- string representation of an E.164 number associated with the account.unidentifiedAccessKey- unidentified access key for the account.usernameHash- hash of the username associated with the account.store- local persistent storage for key transparency-related data, such as the latest tree heads and account monitoring data.- Returns:
an instance of CompletableFuture successful completion of which will indicate that the monitor request has succeeded and store has been updated with the latest account data.
-
-
-
-