zksecurity / noname

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

support different backends #17

Closed mimoo closed 4 months ago

mimoo commented 1 year ago

Currently only plonk (specifically kimchi) is supported. I'd be cool to be able to support different backends, specifically snarkjs which has quite the amount of traction.

I'm wondering about several potential paths here, and I'm not sure which would make more sense:

mimoo commented 6 months ago

I think these are the steps we should take:

  1. make the circuit-writer (or noname in general) generic based on Field (different proof systems use different fields). Right now we hardcode the field to Pallas' base field. So something like pub struct CircuitWriter<F> where F: ark_ff::Field is probably a good start.
  2. move all the kimchi fields (witness_vars, rows_of_vars, gates, wiring, double_generic_gate_optimization, pending_generic_gate) to some kimchi-related struct, then make sure that code compiles
  3. modularize the circuit-writer: have an enum that allows you to choose between R1CS or Kimchi, fix compiler errors. We might be able to reuse some data structures from arkworks
  4. at this point anything R1CS should be unimplemented!(). Try to compile simple examples like arithmetic.no with R1CS arithmetization
mimoo commented 6 months ago

current progress: @katat has a nice trait for Backend that different backends can implement. We now realize the goal is to move as little as possible to the backend trait, so that most code remain the same between backends. There's some refactors needed in builtins, as well as fields, to make things generic on the backend or field