1

I am using the keccak256 hashing algo to retrieve a message for a signature however I am getting the return value above.

Here is the code:

function adminAuthorizedSwap(string price, string quantity,
    string sellerAddress, uint8 adminV, bytes32 adminR,
    bytes32 adminS) public payable returns(address, uint, uint, bytes32)
{
    bytes memory prefix = "\x19Ethereum Signed Message:\n54";
    bytes32 agreementHash = keccak256(prefix, price, "|", quantity, "|",  sellerAddress);
    //if the agreement hash matches then the trade can take place
    bool agreementIsValid = ecrecover(agreementHash, adminV, adminR, adminS) == admin;
    return(ecrecover(agreementHash, adminV, adminR, adminS), parseInt(price, 0), 
        parseInt(quantity, 0), agreementHash);
}

price, quanitity and sellerAddress are all cast as strings.

The values passed to the function are: "100000000", "1", "0xFE6d4bC2De2D0b0E6FE47f08A28Ed52F9d052A02", 28,"0x023409a3bfeaa29209c72704a9ad3e9b95abf14f329c4582155d5533103e00d5", "0x699a3597749ac2ae016ed9fdc31c7f73b70d0a8860d7ffd68d32564957c4c38b"

please note that the message length is hardcoded for this example as I was testing a fixed message.

Here are the return values:

{
   "string price": "100000000",
   "string quantity": "1",
   "string sellerAddress": "0xFE6d4bC2De2D0b0E6FE47f08A28Ed52F9d052A02",
    "uint8 adminV": "28",
    "bytes32 adminR": "0x023409a3bfeaa29209c72704a9ad3e9b95abf14f329c4582155d5533103e00d5",
    "bytes32 adminS": "0x699a3597749ac2ae016ed9fdc31c7f73b70d0a8860d7ffd68d32564957c4c38b"
}
 decoded output     {
    "0": "address: 0x56953edcc55c834bf26fdfe00aba302b09c00202",
    "1": "uint256: 100000000",
    "2": "uint256: 1",
    "3": "bytes32: 0x0000000000000000000000000000000000000000000000000000000000000000"
}
2
  • 2
    Please provide complete enough code to reproduce the issue. This does not reproduce it, but of course I'm just guessing values: return keccak256("\x19Ethereum Signed Message:\n54", "1", "|", "100000000", "|", 0x1234567890123456789012345678901234567890);.
    – user19510
    Commented Dec 28, 2017 at 12:48
  • Does the function work if you pass in a simpler value? What does keccak256(5) return for example?
    – wtk219
    Commented Dec 28, 2017 at 16:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.