rotateRecoveryKey

Replaces the user's active recovery key in one atomic step. In this order:

  1. the user never registered a key: RecoveryKeyRotationResult.NOT_CONFIGURED;

  2. the active key was installed by the rotation with RecoveryKeyRotationTransition.rotationId and is its new key: RecoveryKeyRotationResult.ALREADY_APPLIED, nothing written;

  3. the key is revoked, or its key or epoch differ from the expected ones, or the new key is the active key, or the authorizing device's registration differs from RecoveryKeyRotationTransition.expectedAuthorizer (key and epoch): RecoveryKeyRotationResult.CONFLICT, nothing written;

  4. the epoch is Long.MAX_VALUE: RecoveryKeyRotationResult.EPOCH_EXHAUSTED;

  5. prunes nonces older than RecoveryKeyRotationTransition.pruneBefore and claims the nonce under the authorizing device (AuthenticationNonceRepository, same namespace); already claimed: RecoveryKeyRotationResult.REPLAY (the prune may commit);

  6. stores the new key, epoch + 1, the rotation ID (clearing a revocation ID) and RecoveryKeyRotationTransition.now as installation and transition time, and deletes every last-device recovery challenge and the pending reset of the user: RecoveryKeyRotationResult.ROTATED.

Nothing else changes: device registrations, epochs and installation times, prekeys, mailboxes and other nonces stay.