-
Notifications
You must be signed in to change notification settings - Fork 192
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: use inverse as a bijection for bw6-761 mimc #471
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, but I'm not sure about the security analysis. Is there a reference which supports using inverse as a encryption function?
And in that case I'm not sure if we should keep it as MiMC or instead define a new hash function MiMC-Inverse?
@ThomasPiellard, do you have thoughts?
Well we just need the s-box to be a bijection so given that From the Section "Previous Versions" in the Abstract of the new version, one can read:
I am not sure if it is fair to translate blindly the security analysis of Poseidon to MiMC but I think it would be safe to revert the use of the inverse s-box in MiMC. For the record, if we revert commit Consensys/gnark@bdab848 in PR Consensys/gnark#949, the total nb of constraint is 342k instead of 317k for the 2-chain case (emulated case not impacted). So that's not terrible. |
Yup, skimming the different versions I think I have the same impression. I think for safety now we can revert bdab848 in 949 (to use pow5 instead of inv). With Consensys/gnark#960 we get additional savings when batching and I think we already can fit many proofs in 2-chain currently. I think we can save quite a lot more when going to 8- or 16-bit decomposition when marshalling G1 points. Right now the overhead is quite significant. And we can still look into implementing Pedersen instead of using MiMC. But just in case I would leave this PR open. It may still work out after reconsidering nb of rounds. |
Description
Currently BW6-761 MiMC hash uses
pow5
as a bijection. This PR suggests to use theInverse
function instead. This reduces the number of constraints needed for the plonk verifier gadget in gnark (see Consensys/gnark#949) but increases the out-circuit execution time.TODO:
Type of change
Please delete options that are not relevant.
How has this been tested?
Same tests as in the master branch.
How has this been benchmarked?
Please describe the benchmarks that you ran to verify your changes.
Checklist:
golangci-lint
does not output errors locally