Closed JameWade closed 2 years ago
Hey Jame,
I'm still new to this field so I might be wrong, but you may find your answer in Vitalik's post introducing zk-SNARKs. Have a look at the section in Finite Fields and his paragraph on division.
In summary, zk-SNARKs operate on a finite field where only integers are allowed. Since our traditional division method could result in an answer that is non-integer, there is a different method to perform divisions in finite fields to mimic traditional division. A consequence of this however, is that non-integer divisions will result in answers that we don't normally expect in our normal math world.
To answer your question, I believe non-integer divisions are allowed, just that they don't behave in the normal way we expect in traditional maths. In finite fields, that big answer you see is technically correct. If you wish to do floating point division in zk-SNARKs I imagine you'll have to implement your own floating point library on top of gnark.
Correct, a math/float
and non native field arithmetic (ie working with a different modulus than the one on which the zkSNARK is "instantiated" with) is currently not supported.
It is in our backlog.
dear vck3000 and gbotrel @vck3000 @gbotrel thanks for your reply,I have an idea about the implement of div.I read the code in jsnark. when a div b,they compute c = a div b,then verify a = b mul c. I want implement this func like xjsnark,but i failed. Can I do that?
Divisions on emulated fields are now available in #302.
like api.div(31,3),it returns