public IRpcMethodResult SignMessage(string address, string message) { try { var account = new AccountComponent().GetAccountById(address); if (account == null || string.IsNullOrWhiteSpace(account.PrivateKey)) { throw new CommonException(ErrorCode.Service.Account.ACCOUNT_NOT_FOUND); } ECDsa dsa = ECDsa.ImportPrivateKey(Base16.Decode(DecryptPrivateKey(account.PrivateKey))); var signResult = Base16.Encode(dsa.SingnData(Encoding.UTF8.GetBytes(message))); var result = new { signature = signResult, publicKey = account.PublicKey }; return(Ok(result)); } catch (CommonException ce) { return(Error(ce.ErrorCode, ce.Message, ce)); } catch (Exception ex) { return(Error(ErrorCode.UNKNOWN_ERROR, ex.Message, ex)); } }