Skip to content

fix hacky registration of MiMC #1502

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

Merged
merged 10 commits into from
Jun 4, 2025
Merged

fix hacky registration of MiMC #1502

merged 10 commits into from
Jun 4, 2025

Conversation

Tabaie
Copy link
Contributor

@Tabaie Tabaie commented May 28, 2025

No description provided.

Copy link
Collaborator

@ivokub ivokub left a comment

Choose a reason for hiding this comment

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

Looks good - I would only change the the order of import to avoid import cycles in the future.

@Tabaie Tabaie requested a review from ivokub May 31, 2025 21:16
@Tabaie
Copy link
Contributor Author

Tabaie commented May 31, 2025

Seems like having mimc importing hash already creates a cycle.
Because BinaryHasher imports uints which ultimately imports mimc. Perhaps we should move BinaryHasher to another package?

@ivokub
Copy link
Collaborator

ivokub commented Jun 2, 2025

Seems like having mimc importing hash already creates a cycle. Because BinaryHasher imports uints which ultimately imports mimc. Perhaps we should move BinaryHasher to another package?

I'll check the import cycle. Maybe indeed having the BinaryHasher inside std/hash is not optimal, but I'll see maybe there is a way which still would allow keeping it there.

@ivokub
Copy link
Collaborator

ivokub commented Jun 2, 2025

@Tabaie - so I tried a few options and imo this looks the best. Imo having the constructor which returns the direct type MiMC is historic, so I kept it for backwards compatibility, but for new usages I think the mimc.New would be better anyway, as it concretely describes the interface we implement.

Another option would have to move BinaryHasher interface out from std/hash, but I have seen people already using it and I'd rather not break stuff. I think the option right now is a good balance between allowing to use MiMC internally whenever we need without importing std/hash while keeping the backwards compatibility.

But - before I'm satisfied with the PR fully, I'd still want to make the hash constants more type safe than they are right now. Imo using strings could cause issues and better to use the approach from Go std lib and gnark-crypto where we have the hash functions registered by constants. I'll do it tomorrow.

@ivokub ivokub merged commit 716710f into master Jun 4, 2025
6 checks passed
@ivokub ivokub deleted the fix/hashregistry-mimc branch June 4, 2025 13:29
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