-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ ECDSA Wrapper #247
base: v7
Are you sure you want to change the base?
✨ ECDSA Wrapper #247
Conversation
Ok, let it marinate for a day or few. |
@Vectorized I wanted you make you aware of a recent finding (h/t to @axic). All client implementations of the precompile |
@pcaversaccio I have already removed the check and rearranged some opcodes for lesser stack operations. ;) I also knew that the precompile had the checks all along lol 😂 But kept the check back then cuz it made the invalid signature case much cheaper (by 3k gas). Glad that the provocative PR inspired a yellowpaper clarification. But the tweets made me rethink it’s better to optimize for the happy case for this PR (since we aren’t reverting here). |
@Vectorized I just saw your recent commit. I looked at it yesterday and quickly chatted with @transmissions11 first and then came back today to raise it without checking for new commits. Yeah agreed on the happy case :-D - I mean who doesn't want to optimise for the happy case lol |
@1kresh If you can't wait use this first: https://github.com/Vectorized/solady |
Is it still planned to get this merged? |
Any reason this PR doesn't seem to be getting merged? |
Description
For #244.
Using this can save about 700 gas over OpenZeppelin's implementation.
Tests are ported over from OpenZeppelin.
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/utils/cryptography/ECDSA.test.js
Although I recommend that
toEthSignedMessageHash(bytes32 hash)
be used for efficiency reasons, I've included thetoEthSignedMessageHash(bytes memory s)
function for completeness. If you want to remove the latter, let me know.Due to the use of
staticcall
andgas()
to callecrecover
in assembly,the
recover
function has to be marked asview
instead ofpure
.If you know how to force the compiler to accept the function as
pure
, let me know.Checklist
Ensure you completed all of the steps below before submitting your pull request:
forge snapshot
?npm run lint
?forge test
?Pull requests with an incomplete checklist will be thrown out.