decryptWithCallback method

Future<Uint8List> decryptWithCallback(
  1. PreKeySignalMessage ciphertext,
  2. DecryptionCallback? callback
)

Implementation

Future<Uint8List> decryptWithCallback(
    PreKeySignalMessage ciphertext, DecryptionCallback? callback) async {
  final sessionRecord = await _sessionStore.loadSession(_remoteAddress);
  final unsignedPreKeyId =
      await _sessionBuilder.process(sessionRecord, ciphertext);
  final plaintext = _decrypt(sessionRecord, ciphertext.getWhisperMessage());

  if (callback != null) {
    callback(plaintext);
  }

  await _sessionStore.storeSession(_remoteAddress, sessionRecord);

  if (unsignedPreKeyId.isPresent) {
    await _preKeyStore.removePreKey(unsignedPreKeyId.value);
  }

  return plaintext;
}