0

I have a contract where the hash value is also the key to unlock the money.

As the full ecrecover parameters are fetched from transaction parameters, and it was compiled in 2016, it is vulnerable to the ECrecoverMalformedInput compiler bug.

But actually what are examples calls to ecrecover() built‑in contract which can make it returns nothing ?

1 Answer 1

0

A unit test was added when it was fixed https://github.com/ethereum/solidity/blob/v0.4.14/test/libsolidity/SolidityEndToEndTest.cpp#L8257-L8274.

contract C {
    function f() returns (address) {
        return recover(
            0x77e5189111eb6557e8a637b27ef8fbb15bc61d61c2f00cc48878f3a296e5e0ca,
            0, // invalid v value
            0x6944c77849b18048f6abe0db8084b0d0d0689cdddb53d2671c36967b58691ad4,
            0xef4f06ba4f78319baafd0424365777241af4dfd3da840471b4b4b087b7750d0d,
            0xca35b7d915458ef540ade6068dfe2f44e8fa733c,
            0xca35b7d915458ef540ade6068dfe2f44e8fa733c
        );
    }
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s, uint blockExpired, bytes32 salt)
        returns (address)
    {
        require(hash == keccak256(blockExpired, salt));
        return ecrecover(hash, v, r, s);
    }
}
3
  • and outside invalid v value, what can cause it to returns null ? Commented Oct 18, 2019 at 19:23
  • From the commit fix github.com/ethereum/solidity/commit/…, the code generated didn't reset the output when there was an error.
    – Ismael
    Commented Oct 18, 2019 at 23:53
  • Sorry, but I mean how to have ecrecover returning nothing with a correct v value ? Commented Oct 19, 2019 at 0:22

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.