noir icon indicating copy to clipboard operation
noir copied to clipboard

Investigate whether we can compile the library to WASM with the C++ FFI

Open kevaundray opened this issue 3 years ago • 5 comments

kevaundray avatar Oct 22 '21 15:10 kevaundray

Js or WASM would be preferred; anything that allows it to be used in the browser

kevaundray avatar Oct 25 '21 10:10 kevaundray

One viable solution is not compile noir bundled with the backend, instead we compile Noir with no backend into wasm and then separately compile the backend into wasm.

  • The browser would then have a prover key, the Noir.wasm file and the backend.wasm file.
  • The Noir.wasm file will take a Prover.toml file with the Noir program and create the partial witnesses along with an ACIR structure.
  • The backend.wasm file will take the partial witnesses, the ACIR structure and the prover key and then compute the proof.

(The backend.wasm needs the ACIR structure to compute the rest of the witness values)

In the browser, there would be one JS file which co-ordinates communicating between Noir and the backend.

(Note that the prover key is computed locally, then it is copied into the browser)

kevaundray avatar Oct 25 '21 16:10 kevaundray

@kevaundray would you be able to give some pointers on how to go about your recommendation above and build for wasm32-unknown-unknown. Naively disabling features would result in compilation errors, starting with please specify a backend to compile with.

kobyhallx avatar Jul 25 '22 14:07 kobyhallx

@kobyhallx

Hey, I'm currently working on this, just have not committed the changes. Indeed just disabling things will give a compilation error (We want to compile noir without a backend)

Currently I have compiled the noir compiler to a wasm binary using wasm-bindgen which is being called from typescript.

Do you want me to ping you when I push the changes?

kevaundray avatar Jul 25 '22 14:07 kevaundray

Please do.

kobyhallx avatar Jul 25 '22 14:07 kobyhallx

This can now be closed and is now under the responsibility of the tooling team led by @kobyhallx

kevaundray avatar Jan 21 '23 19:01 kevaundray