Search in sources :

Example 6 with SignedPreKeyEntity

use of org.whispersystems.signalservice.api.push.SignedPreKeyEntity in project toshi-android-client by toshiapp.

the class ChatService method registerKeysWithTimestamp.

private Completable registerKeysWithTimestamp(final long timestamp, final IdentityKey identityKey, final PreKeyRecord lastResortKey, final String password, final int registrationId, final String signalingKey, final SignedPreKeyRecord signedPreKey, final List<PreKeyRecord> preKeys) {
    final long startTime = System.currentTimeMillis();
    final List<PreKeyEntity> entities = new LinkedList<>();
    for (PreKeyRecord preKey : preKeys) {
        final PreKeyEntity entity = new PreKeyEntity(preKey.getId(), preKey.getKeyPair().getPublicKey());
        entities.add(entity);
    }
    final PreKeyEntity lastResortEntity = new PreKeyEntity(lastResortKey.getId(), lastResortKey.getKeyPair().getPublicKey());
    final SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(), signedPreKey.getKeyPair().getPublicKey(), signedPreKey.getSignature());
    final long endTime = System.currentTimeMillis();
    final long elapsedSeconds = (endTime - startTime) / 1000;
    final long amendedTimestamp = timestamp + elapsedSeconds;
    final SignalBootstrap payload = new SignalBootstrap(entities, lastResortEntity, password, registrationId, signalingKey, signedPreKeyEntity, identityKey);
    final String payloadForSigning = JsonUtil.toJson(payload);
    return this.chatInterface.register(payloadForSigning, amendedTimestamp).observeOn(Schedulers.io()).subscribeOn(Schedulers.io()).toCompletable();
}
Also used : PreKeyEntity(org.whispersystems.signalservice.internal.push.PreKeyEntity) SignedPreKeyEntity(org.whispersystems.signalservice.api.push.SignedPreKeyEntity) SignalBootstrap(com.toshi.crypto.signal.model.SignalBootstrap) SignedPreKeyEntity(org.whispersystems.signalservice.api.push.SignedPreKeyEntity) PreKeyRecord(org.whispersystems.libsignal.state.PreKeyRecord) SignedPreKeyRecord(org.whispersystems.libsignal.state.SignedPreKeyRecord) LinkedList(java.util.LinkedList)

Example 7 with SignedPreKeyEntity

use of org.whispersystems.signalservice.api.push.SignedPreKeyEntity in project Signal-Android by signalapp.

the class PushServiceSocket method registerPreKeys.

public void registerPreKeys(ServiceIdType serviceIdType, IdentityKey identityKey, SignedPreKeyRecord signedPreKey, List<PreKeyRecord> records) throws IOException {
    List<PreKeyEntity> entities = new LinkedList<>();
    for (PreKeyRecord record : records) {
        PreKeyEntity entity = new PreKeyEntity(record.getId(), record.getKeyPair().getPublicKey());
        entities.add(entity);
    }
    SignedPreKeyEntity signedPreKeyEntity = new SignedPreKeyEntity(signedPreKey.getId(), signedPreKey.getKeyPair().getPublicKey(), signedPreKey.getSignature());
    makeServiceRequest(String.format(Locale.US, PREKEY_PATH, "", serviceIdType.queryParam()), "PUT", JsonUtil.toJson(new PreKeyState(entities, signedPreKeyEntity, identityKey)));
}
Also used : SignedPreKeyEntity(org.whispersystems.signalservice.api.push.SignedPreKeyEntity) SignedPreKeyEntity(org.whispersystems.signalservice.api.push.SignedPreKeyEntity) PreKeyRecord(org.whispersystems.libsignal.state.PreKeyRecord) SignedPreKeyRecord(org.whispersystems.libsignal.state.SignedPreKeyRecord) LinkedList(java.util.LinkedList)

Aggregations

SignedPreKeyEntity (org.whispersystems.signalservice.api.push.SignedPreKeyEntity)7 LinkedList (java.util.LinkedList)4 PreKeyRecord (org.whispersystems.libsignal.state.PreKeyRecord)4 SignedPreKeyRecord (org.whispersystems.libsignal.state.SignedPreKeyRecord)4 GroupsV2AuthorizationString (org.whispersystems.signalservice.api.groupsv2.GroupsV2AuthorizationString)2 SignalBootstrap (com.toshi.crypto.signal.model.SignalBootstrap)1 PreKeyEntity (org.whispersystems.signalservice.internal.push.PreKeyEntity)1