-
Notifications
You must be signed in to change notification settings - Fork 118
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
Can release o1js lib without sharedArrayBuffer ? #1787
Comments
This is an important request; I fully support it. Statistics show that more than 60% of MinaNFT users visit the minanft.io site from mobile devices, and having o1js/light with a small size that can work on both iPhone and Android is very important for user experience. I will be happy to participate in testing this version of the library. |
Would you have a use case for o1js without those features? |
Yes, this case already exists as MinaNFT does all the compiling and proof creation with zkCloudWorker in the cloud. In the browser
No compiling or proving is being made on the frontend, and this allows to present the Auro Wallet sign transaction form within 5 seconds after the user pressed the button. The compiling and proving take place in the cloud, where zkCloudWorker
o1js/light will be
|
The relevant discussion on discord: https://discord.com/channels/484437221055922177/1228326948078489642 |
Is there no other way besides SharedArrayBuffer? Because compatibility is also an important basis for the popularity of a library. |
|
It was in the press recently that the most used smartphone by Telegram users is Samsung costing $180. |
Yes, can it be built and signed only on the extension or Android, and the rest of the things (such as proof, compile, etc.) are handled by the server? Currently, due to compatibility, the Android cannot even create zkApp transactions |
Yeah that would be the o1js/light idea. It will take some refactors but it's definitely possible |
Isn't the mobile wallets like auro or pallad support zkapps? Is this mobile browser spesific request? Currently we are looking in to making o1js work on mobile applications directly. I like to know more details here. |
Looking forward to o1js/light |
Yes, you can try to open zkApp in Android webview and build zk-command. When building, the process will throw an exception. The error is just like what I said at the beginning |
Auro uses mina-signer, a lightweight TS library that should work everywhere but that can only sign, not create or prove, zkapp transactions |
At the moment, you need to run your zkApp inside the browser of the mobile wallet, but it is not possible to send zkApp tx now. What I expect for MinaNFT:
|
Would an ffi be a feasible solution? Of course, as dfst stated here user base might not have a powerful device for computation, but in a scenario of the existence of either C or any other efficient language that can be executed in a powerful mobile device could enable proving/compiling hence interaction with zkapps.
|
Hey, have folks tried setting the COOP and COEP headers? It looks like you can use sharedArrayBuffer if you set the COOP and COEP headers in the request. https://web.dev/articles/coop-coep |
@andrewferrone nice one, gonna try it in Pallad soon: |
So are we saying this is not an issue after all, because you can set those headers in extensions just as in normal websites? :D That would be great news for Private Credentials! |
So in Pallad the |
@mrcnk could you post your question in zkapps questions channel on Discord? |
And @mrcnk can you share the exact setup you tested on mobile please? |
It occurs in a browser extension's service worker context. I created a repro for this problem (though this time it's another
|
I looked at setting COOP and COEP like @andrewferrone suggested and it worked for me. I created a browser extension prototype and put the o1js related stuff in a sandboxed iframe. |
Hey, we're working on getting zkApp transaction proving functional in the browser on Android. We've got a proof of concept working now we believe. Is there anyone here with a zkApp looking to prove in browser on Android? We'd like to test our solution with you. @lvshaoping007 @EmrePiconbello |
Update: I did some additional tests in mobile environments. I have created a test zkApp: https://mobile-test.minatokens.com that can use Auro Wallet or a hardcoded private key, prove in the web or the cloud, and do some simple Merkle Map root calculations. It also shows system info, including CORS, SharedArrayBuffer status, and wallet info. I have tested four environments: iPhone Safari, Auro Wallet internal browser on iPhone, Android Chrome, and Auro Wallet internal browser on Android. The results:
Therefore, current limitations in comparison with the web:
As I understand, issues with The good news is that no more limitations exist to using o1js for building txs. I remember that I have tested several months ago o1js in Netlify functions that do not support SharedArrayBuffer too, and I was unable to do simple math like Field(1).add(Field(2)), now I can calculate MerkleMap root without SharedArrayBuffer and do some math with Fields in Android WebView, that is enough to build transaction. Therefore, o1js/light is not the absolute requirement for Android WebView, although it would be good not to load 100 MB library on mobile. Current tested workflow for the internal browser of Auro Wallet for Android:
Of course, it is a non-optimal user experience, but it works. Example of the zkApp tx sent from the internal browser of Auro Wallet for Android: https://minascan.io/devnet/tx/5JuK2RweaYegyt3ddyvd5EoJsaedh7ifNuMUHjx1Ne2VdRdW4Fgc?type=zk-tx Proposal:
|
I tested the Metamask SDK library on Android to see how a similar workflow works on Ethereum. I've added a checkbox to my app, https://mobile-test.minatokens.com/, to send the tx on Sepolia from the Android Chrome browser. The workflow:
SharedArrayBuffer is available in this setup; the wallet installed as a mobile app on Android is working. We can do the same for Mina protocol wallets. |
Thanks for looking into this @dfstio - this is super helpful! |
Can o1js teams release a new
o1js
lib withoutsharedArrayBuffer
? Because sharedArrayBuffer currently causes some compatibility issues, which affect the actual experience of users with o1jsextension:
extension cannot use o1js directly, because the front-end does not support
Function
andeval
So we tried sandbox, but it prompted a sharedArrayBuffer exception. The exception is as follows
Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.
but sandbox can not use crossOriginIsolatedAndroid:
The system browser on the Android does not support SharedArrayBuffer by default, so for Android users, they cannot use zkApp to build zk-transactions on the client.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
The text was updated successfully, but these errors were encountered: