Search in sources :

Example 1 with PreKeyEntity

use of org.whispersystems.signalservice.internal.push.PreKeyEntity 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)

Aggregations

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