-
Notifications
You must be signed in to change notification settings - Fork 201
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
feat(mimc): adds SetState and State methods to MiMC #560
Conversation
I guess the utility of the function would be to store the state of the hasher and recreate it later? In this case, wouldn't it make more sense to implement And in that case - a serialize-deserialize roundtrip test would be good. |
As a piece of context, the use of this PR is to support this PR. TLDR, I need to save the state of the FS hasher to restore it at specific points during the protocol. A corresponding branch also exists on gnark. [io.WriterTo] and [io.ReadFrom] are interesting, but I wonder if we can make sense of that in the gnark circuit world. There is also a significant potential for confusion between the state of the hasher and the digest: from a user perspective, it's unclear what the function would serialize. They are the same for MiMC but not for Keccak256, Poseidon and that's a byproduct of these using the sponge construction. Generally speaking, I prefer to use standard interfaces unless what the function concretely implements is totally unambiguous. |
I agree about the ambiguity when using And I guess that when we don't care that much about being hasher agnostic, then having dedicated methods only for MiMC would work well. I'll have a look at your PR at monorepo and then review the current PR. |
See #564 for a generic proposal. See if it would make more sense. Currently depends on code generator upgrade, but it introduces more changes which I wanted to avoid in this PR. |
@AlexandreBelling - #564 is now done with all the tests, documentation update etc. The interface for using in Linea should be the same, but you don't have to check interfaces anymore. If that one looks good, then I propose merging #564 and closing this one (#560). |
Closing - work continues in #564 |
Description
The PR adds getter and setter methods
SetState
and aState
to the MiMC hasher. In the current state, the method is not raised to the interface level because the interface would not work for other hashers where the state is more than just a field element. In addition, it exposes the Digest method to make the functions reachable by the user. Beside the implementation ofhash.Hash
is switched to pointer receivers to make changes on the fieldh
effective.Type of change
Please delete options that are not relevant.
How has this been tested?
It has not been extensively tested as these are just getters and setters.
How has this been benchmarked?
No benchmark done
Checklist:
golangci-lint
does not output errors locally