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

fix: mimc is compliant with ethereum #125

Merged
merged 7 commits into from
Feb 3, 2022

Conversation

ThomasPiellard
Copy link
Contributor

Fixes #124 .

Example:

var data [3]fr.Element
	data[0].SetString("10909369219534740878285360918369814291778422174980871969149168794639722256599")
	data[1].SetString("3811523387212735178398974960485340561880938762308498768570292593755555588442")
	data[2].SetString("21761276089180230617904476026690048826689721630933485969915548849196498965166")

	h := NewMiMC("mimc")
	h.Write(data[0].Marshal())
	h.Write(data[1].Marshal())
	h.Write(data[2].Marshal())

	r := h.Sum(nil)

	var b big.Int
	b.SetBytes(r)
	fmt.Printf("%s\n", b.String())

outputs 7018430971635270450834876734052312213264841464458602476370836768879919501996

, as does this implementation ->
on python with DEFAULT_EXPONENT = 5 and DEFAULT_SEED = "mimc":

In [3]: mimc_hash([
   ...: 10909369219534740878285360918369814291778422174980871969149168794639722256599,
   ...: 3811523387212735178398974960485340561880938762308498768570292593755555588442,
   ...: 21761276089180230617904476026690048826689721630933485969915548849196498965166])
Out[3]: 7018430971635270450834876734052312213264841464458602476370836768879919501996

@gbotrel
Copy link
Collaborator

gbotrel commented Jan 26, 2022

@ThomasPiellard ?

@ThomasPiellard ThomasPiellard merged commit a70fdc7 into develop Feb 3, 2022
@ThomasPiellard ThomasPiellard deleted the fix/mimc_miyaguchipreneel branch February 3, 2022 13:32
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