I'm trying to follow this tutorial: https://programtheblockchain.com/posts/2018/02/17/signing-and-verifying-messages-in-ethereum/ But I cant seem to get it to work:
The following method doesnt make sense to me:
function signPayment(recipient, amount, nonce, contractAddress, callback) {
var hash = "0x" + ethereumjs.ABI.soliditySHA3(
["address", "uint256", "uint256", "address"],
[recipient, amount, nonce, contractAddress]
).toString("hex");
web3.personal.sign(hash, web3.eth.defaultAccount, callback);
}
It would seem that var hash
variable is going to be greater than 32 bytes and thus can never be the same value as:
keccak256(msg.sender, amount, nonce, this)
Has anyone been able to get his tutorial to work? Or explain how those two values are the same? Is there an alternative to soliditySHA3() that matches the functionality of keccak256()?