Skip to content
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

perf: improve hash injectivity constraints #406

Merged
merged 1 commit into from
Nov 13, 2024
Merged

Conversation

daejunpark
Copy link
Collaborator

Previously, we formulated the hash injectivity axiom as hash(x) == hash(y) ==> x == y, which required generating local constraints for all combinations of hash inputs, resulting in O(n^2).

Now, we reformulate the injectivity axiom as "there exists f, such that f(hash(x)) == x," which requires only O(n) constraints, each of which is independent from other constraints.

@daejunpark daejunpark mentioned this pull request Nov 12, 2024
17 tasks
Comment on lines +116 to +117
# TODO: explore the impact of using a smaller bitsize for the range sort
f_inv_sha3_size = Function("f_inv_sha3_size", BitVecSort256, BitVecSort256)
Copy link
Collaborator

Choose a reason for hiding this comment

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

BitVecSort32 should work for the input size, right?

Copy link
Collaborator Author

@daejunpark daejunpark Nov 13, 2024

Choose a reason for hiding this comment

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

does the max size of byte arrays that can appear during execution not exceed 2^32 bits (2^29 bytes)? if so, yes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's definitely not realistic in the current EVM execution context. 2^20 is already huge (1MB)

Copy link
Collaborator

@karmacoma-eth karmacoma-eth left a comment

Choose a reason for hiding this comment

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

very nice! excited to give it a try. I can see this helping with storage-heavy tests

@daejunpark daejunpark merged commit 12232f8 into main Nov 13, 2024
53 checks passed
@daejunpark daejunpark deleted the perf/improve-hash-axiom branch November 13, 2024 00:39
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