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: faster poseidon hades permutation #170

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

feltroidprime
Copy link

@feltroidprime feltroidprime commented Sep 8, 2023

This gives ~7x improvement by not using numpy for vectors/matrices, using native python pow function, and using the mds matrix directly instead of matrix multiplication, taking advantage of the small constants.

This would allow faster trace generation when using cairo-run for programs that uses intensively the Poseidon builtin since the permutation is used in the builtin runner.

Quite a few interesting programs could benefit from it. :)

For ~100k hashes on a i7-12700h (one core), it takes around 13 seconds instead of 90.
The only counterpart is that it is removing generality over the Mds Matrix, but it's not really a problem in our context.


This change is Reviewable

@0xLucqs
Copy link

0xLucqs commented Feb 5, 2024

Fyi a slightly different version of this will be in 0.13.1. Thanks for the contrib

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