2

I have a fair understanding of how ecrecover works, but I don't know how to enforce a parameter set that will deterministically return the 0x0 address. I need this in my contract tests.

Is this even possible?

2

I stumbled upon this thread, then I discovered this document and I now understand that setting v as any (positive?) number other than 27 or 28 will deterministically return 0x0 as the origin signer address.

Test it for yourself in solidity:

function getSignerZero(bytes32 msgHash, bytes32 r, bytes32 s) public returns (address _signer) {
    uint8 wrongV = 17; // should normally be 27 or 28
    return ecrecover(msgHash, wrongV, r, s);
}

Also, a caveat if you're using assembly and staticcall: it's actually incorrect to say that the value returned is 0x0. What happens there is that the precompile never gets back with a new value, so your program will just point to the same value it pointed before the call.

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.