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

Make resources standalone files #93

Closed
mhchia opened this issue Aug 24, 2023 · 2 comments · Fixed by #97
Closed

Make resources standalone files #93

mhchia opened this issue Aug 24, 2023 · 2 comments · Fixed by #97
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mhchia
Copy link
Member

mhchia commented Aug 24, 2023

What’s wrong?

Default resources (.zkey and .wasm) generated by snarkjs are encoded in base64 and put inside typescript files. It's a workaround. They should be individual files originally since it's easier to maintain and it allows developers to decide whether or not to load a file. base64 approach has been used because I find it harder to make RLNjs work with standalone files while supporting both browser and nodejs.

How to fix it?

At the moment I can only think of using environment variables to determine whether it's in the browser or nodejs, and access resources in different ways. Maybe there is a better approach though.

@mhchia mhchia added enhancement New feature or request help wanted Extra attention is needed labels Aug 24, 2023
@mhchia
Copy link
Member Author

mhchia commented Aug 24, 2023

I didn't label it "good first issue" since it might be troublesome. But feel free to fix it if you have any ideas.

@mhchia
Copy link
Member Author

mhchia commented Aug 25, 2023

Thanks to the suggestion from @0xtsukino , if we have a static server hosting resources, it will be a lot easier to support the browser by fetching the resource by URL.

Below is referenced from zkitter-js

  const wasmResp = await fetch(`https://api.zkitter.com/circuits/rln/wasm`);
  const wasmbuf = Buffer.from(await wasmResp.arrayBuffer());
  const zkeyResp = await fetch(`https://api.zkitter.com/circuits/rln/zkey`);
  const zkeybuf = Buffer.from(await zkeyResp.arrayBuffer());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant