zksecurity / noname

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

Display public input in kimchi and R1CS ASM #65

Open mimoo opened 4 months ago

mimoo commented 4 months ago

currently the ASM for kimchi does not display the public input. For example https://github.com/zksecurity/noname/blob/main/examples/arithmetic.asm

@ noname.0.7.0

DoubleGeneric<1>
DoubleGeneric<1,1,-1>
DoubleGeneric<1,0,0,0,-2>
(0,0) -> (1,1)
(1,2) -> (2,0)

we should figure out a way to display the public input there. For example we could have a pub: prefix in front of the gates that are for the public input, but this is a bit ugly and verbose, or we could have the number of public inputs displayed on the second line (like @ public_inputs: 1)

@ noname.0.7.0
+ @ public_inputs: 1

DoubleGeneric<1>
DoubleGeneric<1,1,-1>
DoubleGeneric<1,0,0,0,-2>
(0,0) -> (1,1)
(1,2) -> (2,0)

for R1CS maybe we could write something like this:

@ noname.0.7.0
+ @ v_0=1
+ @ pub=v_1 to v_3

v_3 == (v_3) * (1)
v_4 == (v_4) * (1)
v_3 == (v_1) * (1)
v_4 + 1 == (v_2) * (1)

but yeah haven't thought much about this one, open to suggestions