Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile to WASM + Bindings #4

Open
gakonst opened this issue Aug 25, 2021 · 5 comments
Open

Compile to WASM + Bindings #4

gakonst opened this issue Aug 25, 2021 · 5 comments

Comments

@gakonst
Copy link
Collaborator

gakonst commented Aug 25, 2021

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:

  1. readZKeyAndWasm
  2. prove with the inputs in JS as a k-v object
    1. 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.)
    2. Calls the ark-circom WASM with the inputs from the previous step
  3. Call verify
@lsankar4033
Copy link

lsankar4033 commented Jul 7, 2022

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> {
    |            ^^^ --------  --------  ------

@lsankar4033
Copy link

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

@jinankjain
Copy link

@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

@gakonst
Copy link
Collaborator Author

gakonst commented Aug 9, 2022

that's just for parsing the types, the main issue we have here is the wasm witness generator unfortunately :(

@jinankjain
Copy link

We were mostly interested in verifier on-chain and had no use case for witness generator on chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@lsankar4033 @jinankjain @gakonst and others