/// <summary>
        /// Convert an external representation of a public key to an internal representation suitable for actual use.
        /// </summary>
        /// <param name="accountKey">The account key.</param>
        /// <returns>A UserPublicKey</returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static UserPublicKey ToUserPublicKey(this Api.Model.AccountKey accountKey)
        {
            if (accountKey == null)
            {
                throw new ArgumentNullException(nameof(accountKey));
            }

            IAsymmetricPublicKey publicKey = Resolve.AsymmetricFactory.CreatePublicKey(accountKey.KeyPair.PublicPem);

            return(new UserPublicKey(EmailAddress.Parse(accountKey.User), publicKey));
        }
        /// <summary>
        /// Convert an external representation of a key-pair to an internal representation that is suitable for actual use.
        /// </summary>
        /// <param name="accountKey">The account key.</param>
        /// <param name="passphrase">The passphrase to decrypt the private key, if any, with.</param>
        /// <returns>A UserKeyPair or null if it was not possible to decrypt it.</returns>
        public static UserKeyPair ToUserKeyPair(this Api.Model.AccountKey accountKey, Passphrase passphrase)
        {
            if (accountKey == null)
            {
                throw new ArgumentNullException(nameof(accountKey));
            }

            string privateKeyPem = DecryptPrivateKeyPem(accountKey.KeyPair.PrivateEncryptedPem, passphrase);

            if (privateKeyPem == null)
            {
                return(null);
            }

            IAsymmetricKeyPair keyPair            = Resolve.AsymmetricFactory.CreateKeyPair(accountKey.KeyPair.PublicPem, privateKeyPem);
            UserKeyPair        userAsymmetricKeys = new UserKeyPair(EmailAddress.Parse(accountKey.User), accountKey.Timestamp, keyPair);

            return(userAsymmetricKeys);
        }