private function decryptPrivateKey(PKEncryptionEnabledUserInterface $user, array $params = array())
    {
        if (isset($params['password_digest'])) {
            $passwordDigest = base64_decode($params['password_digest']);
        }
        else {
            if (isset($params['password'])) {
                $salt = $user->getSalt();
                $passwordDigest = $this->cryptographyProvider->getPasswordDigest($params['password'], $salt);
            }
            else {
                throw new EncryptionException('Could not retrieve the user\'s key');
            }
        }

        $iv = $user->getPrivateKeyIv();
        $keyData = new KeyData($passwordDigest, $iv);
        $encryptedPrivateKey = $user->getPrivateKey();

        $privateKey = $this->cryptographyProvider->decrypt(
                        $encryptedPrivateKey,
                        $keyData,
                        CryptographyProviderInterface::PRIVATE_KEY_ENCRYPTION);

        return $privateKey;
    }