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 ?


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(
            0, // invalid v value
    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);
  • and outside invalid v value, what can cause it to returns null ? Oct 18 '19 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
    Oct 18 '19 at 23:53
  • Sorry, but I mean how to have ecrecover returning nothing with a correct v value ? Oct 19 '19 at 0:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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