Skip to content

perf: improve hash injectivity constraints#406

Merged
daejunpark merged 1 commit into
mainfrom
perf/improve-hash-axiom
Nov 13, 2024
Merged

perf: improve hash injectivity constraints#406
daejunpark merged 1 commit into
mainfrom
perf/improve-hash-axiom

Conversation

@daejunpark

Copy link
Copy Markdown
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 thread src/halmos/utils.py
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
Copy Markdown
Contributor

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?

@daejunpark daejunpark Nov 13, 2024

Copy link
Copy Markdown
Collaborator Author

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
Copy Markdown
Contributor

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)

@0xkarmacoma 0xkarmacoma left a comment

Copy link
Copy Markdown
Contributor

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
@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