-
Notifications
You must be signed in to change notification settings - Fork 10
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
Check if wasm/zkey/vkey exist on RLN initialization #49
Comments
Agreed. I'd like to add that if we add a check in the constructor, we should also make sure the check is working in the browser. |
I'm considering working on this issue. Would it be okay to add the following code to rln.ts?
I find it challenging to add conditions for verificationKey since it's not a file path but an actual verification key. Also, I believe that when the data types for wasmFilePath and finalZkeyPath are Uint8Array, they already contain the file contents. Therefore, I think there's no need to add conditions in those cases. |
Hey @s-ekai , thanks for working on this and the clarification. I think it's good to have two |
Thank you for your response. I hadn't considered running it in a browser. I'll think about whether there's a good way to do it. Thank you also for telling me about the library! |
Hey @s-ekai no problem :) Actually we've already used roIlup to bundle the package. I'm thinking if polyfill can automatically replace
I'm not sure if it's this is the correct way to check though. Let me know your thoughts on this 🙏 |
Thank you for explaining so clearly. I also suspect that it is probably being loaded automatically. I have a question about debugging methods. If you know of any better ways to verify this, I would appreciate your guidance. |
I realized that I should modify the code below. I'll check it out. |
Yeah you're right. If you wanted to modify code rlnjs and test it in the examples/browser. You could also do something like the followings
In examples/browser/package.json
# Go to rlnjs project root
cd ../../
npm run build
cd examples/browser
npm install && npm test |
@mhchia Thank you very much! And there is no way to load(read) local files from a browser. In APIs that communicate with local files on the browser side, as far as I can see, they use the input tag to load the file. For this implementation, if the data type of args.finalZkeyPath is a string, I thought it might be considered as running in a node environment rather than in a browser. (It might also be good to check if the process is defined for safety reasons.) Could you tell me your opinion? |
Hey @s-ekai, sorry for the late response, and thanks for your input. You're right that browsers cannot access local files. However, |
Thank you for reaching out! |
I had forgotten that we can't perform asynchronous operations in a class constructor. Therefore, I feel that if I need to check whether the URL is valid, I can only do it within the create function. Is this approach okay? I'm also thinking of moving the conditions that are already in the constructor to the create function as much as possible. |
Thanks for bringing this up. Yes, we can do it in
Can you elaborate on what conditions are you moving? or we can discuss it in your pull request too :) |
Thank you.
|
@s-ekai Great work! I just left some comments in the pull request in your repo. Let me know your thoughts on them :)
What if we check |
@mhchia https://github.com/s-ekai/rlnjs/pull/1/files I believe that just checking the 'process' variable should be sufficient, but I can't say for certain. I looked into discussions on Stack Overflow, and some people are checking with 'require' or 'global' variables. For this case, just to be safe, I'm checking for the existence of both 'process' and 'window' variables to determine if it's a browser environment. |
Hey @s-ekai , awesome work! Thanks for the investigation and also for your tests. Can you also do the same check for |
Thank you. I will make the corrections and create a PR (Pull Request)! On a different note, while I was testing in the browser, I encountered the following error. It might be a good idea to change the CORS settings on the S3 side. (If you're not expecting this file to be accessed from the browser, please disregard this comment.)
I've modified and executed the code inside examples/browser as follows.
|
Wasm/zkey isn't getting fetched until a proof is generated; this is bad developer experience since they won't know something is wrong until they actually go to generate a proof, instead of on RLN instantiation.
The text was updated successfully, but these errors were encountered: