Skip to content

fix: use bit size for sha256/ripemd160/modexp precompile input sorts - #592

Open
joshdrv wants to merge 1 commit into
a16z:mainfrom
joshdrv:fix/precompile-bitvec-sizes
Open

joshdrv wants to merge 1 commit into
a16z:mainfrom
joshdrv:fix/precompile-bitvec-sizes

Conversation

@joshdrv

@joshdrv joshdrv commented Oct 3, 2026 •

Copy link
Copy Markdown

Ran into this bug while formally verifying a function that did sha256(abi.encode(...)).

The sha256, ripemd160 and modexp precompile models size their z3 function sorts with arg_size, which is in bytes, but the input bitvector is arg_size * 8 bits. So any call with symbolic input fails with Z3Exception: Sort mismatch.

The fix is * 8 on the input sorts, and on modexp's modulus_size output sort, the same way sha3_data already does it.

Added Precompile.t.sol with a symbolic test for each precompile. They error on main and pass with this change.

The fix is similar to #591 but also fixes ripemd and modexp

This branch has not been deployed

No deployments
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.

1 participant