verifyKeysQR method

Future<void> verifyKeysQR(
  1. SignableKey key, {
  2. bool shower = true,
})

shower is true only for reciprocated verifications (shower side)

Implementation

Future<void> verifyKeysQR(SignableKey key, {bool shower = true}) async {
  var verifiedMasterKey = false;
  final wasUnknownSession = client.isUnknownSession;

  key.setDirectVerified(true);
  if (key is CrossSigningKey && key.usage.contains('master')) {
    verifiedMasterKey = true;
  }

  if (verifiedMasterKey && userId == client.userID) {
    // it was our own master key, let's request the cross signing keys
    // we do it in the background, thus no await needed here
    // ignore: unawaited_futures
    maybeRequestSSSSSecrets();
  }
  if (shower) {
    await send(EventTypes.KeyVerificationDone, {});
  }
  final keyList = List<SignableKey>.from([key]);
  var askingSSSS = false;
  if (encryption.crossSigning.enabled &&
      encryption.crossSigning.signable(keyList)) {
    // these keys can be signed! Let's do so
    if (await encryption.crossSigning.isCached()) {
      // we want to make sure the verification state is correct for the other party after this event is handled.
      // Otherwise the verification dialog might be stuck in an unverified but done state for a bit.
      await encryption.crossSigning.sign(keyList);
    } else if (!wasUnknownSession) {
      askingSSSS = true;
    }
  }
  if (askingSSSS) {
    // no need to worry about shower/scanner here because if scanner was
    // verified, ssss is already
    setState(KeyVerificationState.askSSSS);
    if (shower) {
      _nextAction = 'done';
    } else {
      _nextAction = 'showQRSuccess';
    }
  } else {
    if (shower) {
      setState(KeyVerificationState.done);
    } else {
      setState(KeyVerificationState.showQRSuccess);
    }
  }
}