public VerifyMeMessage GetVerifyMeMessage(OkSignThisMessage okSignThisMessage)
        {
            string          signedMessage   = SignMessage(okSignThisMessage.messageToSign);
            VerifyMeMessage verifyMeMessage = new VerifyMeMessage(LegacyAddress, signedMessage, PublicId);

            return(verifyMeMessage);
        }
        public BitloginProtocolMessage GetAuthenticationResult(VerifyMeMessage verifyMeMessage)
        {
            if (_accountsByLegacyAddress.TryGetValue(verifyMeMessage.legacyAddress, out Account accountToBeVerified))
            {
                if (accountToBeVerified.currentVerificationState == Account.VerificationState.verified)
                {
                    return(new ErrorMessage(300));
                }

                SignatureVerifier.SignatureVerificationResult signatureVerificationResult = SignatureVerifier.Verify(
                    accountToBeVerified.LegacyAddress.ToString(),
                    accountToBeVerified.messageToBeSigned,
                    verifyMeMessage.signature);

                if (signatureVerificationResult == SignatureVerifier.SignatureVerificationResult.SignatureIsValid)
                {
                    accountToBeVerified.currentVerificationState = Account.VerificationState.verified;
                    accountToBeVerified.publicId = verifyMeMessage.publicIdIWantToHave;
                    return(new AuthenticationSuccess());
                }

                if (signatureVerificationResult == SignatureVerifier.SignatureVerificationResult.SignatureDoesntMatchMessage)
                {
                    return(new ErrorMessage(400));
                }
                return(new ErrorMessage(500));
            }
            return(new ErrorMessage(200));
        }