zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
178 stars 44 forks source link

Enhance R1CS debug info #75

Open katat opened 3 months ago

katat commented 3 months ago

After the constraint is optimized, it might be helpful to keep the trace of how it comes up with the constraint and reduce the repeated info.

For example:

Refine the following(this is what it current shows):

v_4 == (v_3) * (-1 * v_1 + v_2)
v_6 == (v_5) * (-1 * v_1 + v_2)

To:

lc = -1 * v_1 + v_2
v_4 == (v_3) * (lc_1)
v_6 == (v_5) * (lc_1)

So while it can still trace where the lc(linear combination) is from, it avoids repeated string behind lc.

By retaining the trace of the linear combination being accumulated in the constraint generation process, we can map the traces to the lines of noname code, which can be helpful in debugging and analyzing constraints. Related issue: https://github.com/zksecurity/noname/issues/114