public async Task TestCheckSign_IsCorrect() { var guid = Guid.NewGuid(); var amount = 50; EthUtils.GuidToBigInteger(guid); var strForHash = EthUtils.GuidToByteArray(guid).ToHex() + _tokenAdapterAddress.HexToByteArray().ToHex() + _clientA.HexToByteArray().ToHex() + _clientA.HexToByteArray().ToHex() + EthUtils.BigIntToArrayWithPadding(new BigInteger(amount)).ToHex(); var hash = new Sha3Keccack().CalculateHash(strForHash.HexToByteArray()); var sign = Sign(hash, _privateKeyA).ToHex(); //var externalSign = await _exchangeService.GetSign(guid, _tokenAdapterAddress, ClientA, ClientA, new BigInteger(amount)); var result = _exchangeService.CheckSign(guid, _tokenAdapterAddress, _clientA, _clientA, new BigInteger(amount), sign); Assert.IsTrue(result); }
public async Task <IActionResult> CheckSign([FromBody] CheckSignModel model) { if (!ModelState.IsValid) { throw new ClientSideException(ExceptionType.WrongParams, JsonConvert.SerializeObject(ModelState.Errors())); } await Log("CheckSign", $"Begin Process {this.GetIp()}", model); BigInteger amount = BigInteger.Parse(model.Amount); var result = _exchangeContractService.CheckSign(model.Id, model.CoinAdapterAddress, _addressUtil.ConvertToChecksumAddress(model.FromAddress), _addressUtil.ConvertToChecksumAddress(model.ToAddress), amount, model.Sign); await Log("CheckSign", "End Process", model, result.ToString()); return(Ok(new CheckSignResponse { SignIsCorrect = result })); }