zksecurity / noname

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

fix error when private input is unused #71

Open mimoo opened 3 months ago

mimoo commented 3 months ago

the following noname code:

fn main(private_input: Field, x2: Field, pub public_input: Field) {
    let xx = private_input + public_input;
    assert_eq(xx, 2);
}

turns into

   ╭─[examples/arithmetic.no:1:1]
 1 │ ╭─▶ fn main(private_input: Field, x2: Field, pub public_input: Field) {
 2 │ │       let xx = private_input + public_input;
 3 │ ├─▶     assert_eq(xx, 2);
   · ╰──── here
 4 │     }
   ╰────
  help: private input not used in the circuit

which is a weird error, it should highlight the x2: Field part and that's it

to reproduce, modify arithmetic.no and then:

cargo run test --backend kimchi-vesta --path examples/arithmetic.no --private-inputs '{"private_input": "1", "x2": "3"}' --public-inputs '{"public_input": "1"}' --debug