replaceForRecovery

Replaces the target's key in one atomic step, together with the claim of the recovery's nonce (AuthenticationNonceRepository, same nonces, under the target's address). In this order:

  1. the target has no registration: RecoveryReplacementResult.TARGET_NOT_REGISTERED;

  2. the target's current key was installed by the recovery with RecoveryReplacement.recoveryId: RecoveryReplacementResult.ALREADY_APPLIED, nothing written;

  3. the target's or the authorizer's key or epoch differ from the expected state, or the replacement key is the target's current key: RecoveryReplacementResult.CONFLICT, nothing written;

  4. the target's epoch is Long.MAX_VALUE: RecoveryReplacementResult.EPOCH_EXHAUSTED, nothing written;

  5. prunes nonces older than RecoveryReplacement.pruneBefore and claims the nonce; already claimed: RecoveryReplacementResult.REPLAY (the prune may commit);

  6. stores the replacement key, epoch + 1, the recovery ID and RecoveryReplacement.installedAt as installation time, and clears the rotation ID and the last-device recovery ID: RecoveryReplacementResult.REPLACED.

Nothing else changes: prekeys, mailboxes and other nonces stay. Concurrent calls behave as if they ran one after the other.