marlin
marlin copied to clipboard
Underflow panic
Summary of Bug
While adding Marlin as a backend for ZoKrates, I'm hitting an underflow panic during the setup phase:
This works (1 public input: the return value):
def main(private field x) -> field:
return x**2
This fails (1 public input: the return value):
def main(private field x) -> field:
return x
attempt to subtract with overflow ark-marlin-0.2.0/src/ahp/mod.rs:108:28
It seems like k_size
is expected to be bigger than 2, but in this case isn't.
Version
0.2.0
Steps to Reproduce
For these examples I used a universal setup degree of 5 for all parameters.
We should add some assertions on that or try to support very simple statements. But basically, the problem is here: the matrices of the statement are way too simple, such that the number of nonzeros in the matrices ("k_size") is smaller than 2. This issue would not appear if one is proving statements that are more complicated.
It is separate from Marlin only supports instances where the public inputs are of size one less than a power of 2
.
A quick fix is this: pads the constraint system with at least two simple constraints like a * a = a. A more formal fix is possible, but I need to examine the protocol further.
Thanks for the quick response!
This is indeed a very trivial program, it would be nice to support it if possible though, or at least have a specification of which programs are not accepted so that we can check on our side instead of crashing.
I updated my examples due to a mistake on my end. These are even simpler now.