Zokrates / ZoKrates

A toolbox for zkSNARKs on Ethereum
https://zokrates.github.io
GNU Lesser General Public License v3.0
1.83k stars 361 forks source link

Confused about using mimc #960

Closed edoroth closed 3 years ago

edoroth commented 3 years ago

In my code, I import as follows:

import "hashes/sha256/512bit" as sha256 import "hashes/mimc7/mimc7" as mimc

I'm able to use sha256 with no problems. However, I don't quite understand the syntax of how mimc is defined: def main<ROUNDS>(field x_in, field k) -> field:

I try calling it like this in my file enc.zok: return mimc(u[0]+v[0], 1) (these are two field variables)

I end up with the following error:

enc.zok: Call site /Users/edo/.zokrates/stdlib/hashes/mimc7/mimc7.zok/main<_>(field, field) -> field incompatible with declaration enc.zok/mimc<ROUNDS>(field, field) -> field

How can I specify this "ROUNDS" variable? I have a large circuit - what should I set it to, and how do I do this in syntax?

In previous version of ZoKrates, I did not have to do this - my above code would compile and work correctly. What has changed?

Schaeff commented 3 years ago

Hi @edoroth, the number of rounds used to be hardcoded to 10, you should be able to reproduce this behaviour with mimc::<10>(u[0]+v[0], 1)

Schaeff commented 3 years ago

Hey @edoroth feel free to close this if your problem is solved :)