noname icon indicating copy to clipboard operation
noname copied to clipboard

Display Number of Public Inputs

Open mantej opened this issue 1 year ago • 8 comments

Displaying the number of public inputs in Kimchi and R1CS (to do). Addresses this issue suggested by @mimoo.

As an example, when passing in {"public_input": ["1", "2"]} to array.no:

gate 0
gate 1
gate 2
gate 3
@ noname.0.7.0

@ public inputs: 2

Or when passing in {"public_input": "2"} to arithmetic.no:

gate 0
gate 1
gate 2
gate 3
@ noname.0.7.0

@ public inputs: 1

mantej avatar Sep 03 '24 14:09 mantej

thanks so much! a simple change but I've been waiting for this for a long time haha. Do you think you could take a look at the r1cs backend as well?

in addition, you will have to update the compiled circuits in examples/ to pass CI. I'm not sure if there's a command to easily do that (cc @katat)

mimoo avatar Sep 03 '24 15:09 mimoo

Of course! I was playing around with displaying R1CS in a format you had mentioned,

@ v_0=1
@ pub=v_1 to v_3

and I ran into an issue when collecting the public input range. I only spent a few minutes on it last night, but I'll tackle it again shortly. Alternatively, we can just list the number of public inputs similarly to Kimchi above?

mantej avatar Sep 03 '24 17:09 mantej

This is going to be an useful feature to add! It can help debug with the asm.

I'm not sure if there's a command to easily do that (cc @katat)

atm, it has to manually update the asm files. yeah, it would be nice to automatically update the asm files in a batch.

katat avatar Sep 04 '24 07:09 katat

For now, Public Inputs for R1CS are identical to Kimchi; for the array.no example from above:

@ noname.0.7.0

@ public inputs: 2
╭────────────────────────────────────────────────────────────────────────────────
│ 0 │ 1 == (v_1) * (1)
╭────────────────────────────────────────────────────────────────────────────────
│ FILE: examples/array.no
│────────────────────────────────────────────────────────────────────────────────
│ 4:     assert_eq(public_input[0], xx[0]);
│        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╰────────────────────────────────────────────────────────────────────────────────
╭────────────────────────────────────────────────────────────────────────────────
│ 1 │ 2 == (v_2) * (1)
╭────────────────────────────────────────────────────────────────────────────────
│ FILE: examples/array.no
│────────────────────────────────────────────────────────────────────────────────
│ 5:     assert_eq(public_input[1], xx[1]);
│        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╰────────────────────────────────────────────────────────────────────────────────

mantej avatar Sep 07 '24 19:09 mantej

Updated newlines so public inputs is right below the version, and the additional newline is after the public inputs:

@ noname.0.7.0
@ public inputs: 2

╭────────────────────────────────────────────────────────────────────────────────
│ 0 │ 1 == (v_1) * (1)
...

mantej avatar Sep 11 '24 18:09 mantej

@katat just manually updated the asm files, waiting on the build to complete to ensure output looks okay. how does look to you? any suggestions?

mantej avatar Sep 12 '24 17:09 mantej

Thanks @mantej

btw, you can also run cargo test to do the check locally.

katat avatar Sep 13 '24 00:09 katat

@katat all tests are passing locally

mantej avatar Sep 15 '24 23:09 mantej

@katat I pushed the cargo fmt commit, but I don't have write access to merge.

mantej avatar Sep 21 '24 19:09 mantej

Thanks!

katat avatar Sep 22 '24 02:09 katat