privacy-scaling-explorations/sonobe

Circom frontend: allow to define the step_native in Rust

arnaucube opened this issue · 1 comments

Currently in the Circom frontend the step_native method extracts the value for $z_{i+1}$ from computing the witness and extracting it from the Circom circuit.
This approach was done initially to simplify things for the end dev, but in some cases we would like to allow the dev to define their own step_native logic natively in Rust, even having the circuit defined in Circom.

The idea is to allow to define the step_native in Rust that "overwrites" the default step_native of the Circom frontend FCircuit, but if the rust version is not defined it should default to use the already existing logic that obtains the next step from computing and extracting the Circom circuit witness.

For example, for a circuit that computes the SHA256 hash function:
If the dev does not define their custom step_native, the Circom frontend still works, computing the next state $z_{i+1}$ from computing the witness of the circuit and extracting it.
But if the dev wants a more efficient way to compute the step_native (which internally computes the hash), they can define that logic in rust using the SHA256 rust library, and then Sonobe will use that custom step_native, ending up being much more efficient in the computation of the step_native compared to the other approach.

Merged!
Thanks @vuvoth !