privacy-scaling-explorations / sonobe

Experimental folding schemes library
https://privacy-scaling-explorations.github.io/sonobe-docs/
MIT License
179 stars 44 forks source link

Add support for Noir as frontend #124

Closed Savio-Sou closed 3 weeks ago

Savio-Sou commented 1 month ago

Add to sonobe the ability to parse Noir (more accurately ACIR, Noir's intermediate representation of choice) and specifically its folding opcode; hence the ability to fold, prove and generate verifiers for circuits written in Noir.

Relevant links:

dmpierre commented 1 month ago

Hey, thanks for suggesting this, we would indeed like to tackle this. Let me have a look!

dmpierre commented 1 month ago

(small update: waiting for the aztec noir team to circle back on a few questions)

Savio-Sou commented 1 month ago

Additional reference: Closest pointer to ACIR --> R1CS would be arkworks_bridge, which does conversion of ACIR opcodes but to a new data structure instead of R1CS (as in the circom_compat struct).

Note that conversion is incomplete, where only AssertZero ACIR opcodes are handled as they can be converted into R1CS cleanly, while other opcodes would fail.

A possible approach could be building a converter which:

  1. Decomposes every ACIR opcode into AssertZero opcodes (a la acvm_stdlib)
  2. Uses ACVM to perform witness generation on this ACIR
  3. Converts this ACIR into R1CS

Follows by witness generation, which can either be witness generation on the ACIR or custom witness generation on the R1CS output.

(Credit @TomAFrench for insights)

dmpierre commented 1 month ago

It seems like this approach is working. With a few modifications, I managed to test it for a circuit with a shape similar to what sonobe expects. I will work on integrating this modified version of the arkworks_bridge into the lib now!