Skip to content

Rewrite sha256/ripemd160/ecrecover without assembly and add Error#470

Open
axic wants to merge 4 commits into
argotorg:mainfrom
axic:precompiles
Open

Rewrite sha256/ripemd160/ecrecover without assembly and add Error#470
axic wants to merge 4 commits into
argotorg:mainfrom
axic:precompiles

Conversation

@axic

@axic axic commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread std/std.solc
Comment on lines +2189 to +2190
let ret = staticcall(gas(), 2, ptr, len, 0, 32);
require(ret != 0, Error(0x68c071bb)); // SHA256CallFailed()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it would be nice having gas comparison tests, as I do wonder what is the overhead of require. Ideally nothing.

Add a recoverFail() case that passes an invalid r = 0 signature
component. The ecrecover precompile succeeds but recovers nothing,
returning empty output, so ecrecover() yields 0 and the std helper
reverts with ECRecoverFailed() (0x4fbfae63). v and s are kept
well-formed so the malleability and call-failed guards don't fire.

Co-authored-by: Alex Beregszaszi <alex@rtfs.hu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants