circom-compat
circom-compat copied to clipboard
Compile to WASM + Bindings
We should make this lib compile to WASM and also provide bindings to it.
When using this library from the browser, the ideal JS API would be:
-
readZKeyAndWasm
-
prove
with the inputs in JS as a k-v object- Internally calls Circom's Witness Generator to generate the witness. (We cannot do this in Rust, because it requires calling WASM from WASM-compiled-Rust which is not possible.)
- Calls the ark-circom WASM with the inputs from the previous step
- Call
verify
EDIT: realized that these issues are both issues with dependencies assuming os-specific stuff. figuring out if there's an obvious workaround
trying to compile proving with wasm-pack and running into issues compiling deps libloading
and memmap2
(below)
am digging deeper, but lmk if the solution is obvious as i'm not v. familiar with rust
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
--> /Users/lakshmansankar/.cargo/registry/src/github.com-1ecc6299db9ec823/libloading-0.7.0/src/lib.rs:63:20
|
63 | pub struct Library(imp::Library);
| ^^^ use of undeclared crate or module `imp`
error[E0061]: this function takes 3 arguments but 4 arguments were supplied
--> /Users/lakshmansankar/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.2.3/src/lib.rs:229:9
|
229 | MmapInner::map(self.get_len(file)?, file, self.offset, self.populate)
| ^^^^^^^^^^^^^^ ------------------- ---- ----------- ------------- supplied 4 arguments
| |
| expected 3 arguments
|
note: associated function defined here
--> /Users/lakshmansankar/.cargo/registry/src/github.com-1ecc6299db9ec823/memmap2-0.2.3/src/stub.rs:18:12
|
18 | pub fn map(_: usize, _: &File, _: u64) -> io::Result<MmapInner> {
| ^^^ -------- -------- ------
approach I'm going with is extracting out all the wasm execution and just doing that in js. wasm-ing just the parts of this lib downstream of that
@gakonst We got a verifier working on Rust based chains (NEAR). We are following a slightly different approach but I think the same can be applied here to compile to wasm. We are also using arkwork as the base layer. https://github.com/Electron-Labs/electron-rs
that's just for parsing the types, the main issue we have here is the wasm witness generator unfortunately :(
We were mostly interested in verifier on-chain and had no use case for witness generator on chain.