-
Notifications
You must be signed in to change notification settings - Fork 98
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 #46
Comments
The crate can now be compiled to WASM:
|
I was experimenting with creating a web ui for age. I'm having an issue with Because an upstream fix seems unlikely in the near future a workaround may be useful. The easiest fix is to hardcode workload values for scrypt used for passphrase things but maybe this is not appropriate. (doing this makes passphrase based de/encryption work so nothing else is blocking) at std::time::SystemTime::now::h1e14849775e247ed (wasm-function[4185]:0x13af88)
at age::format::scrypt::target_scrypt_work_factor::hb3a1eefd94ad935d (wasm-function[364]:0xc9939)
at age::format::scrypt::RecipientLine::wrap_file_key::hf9740611422cef03 (wasm-function[103]:0x9a9c4)
at age::protocol::EncryptorType::wrap_file_key::h8632c3a0773139d9 (wasm-function[237]:0xb7bff)
at age::protocol::Encryptor::wrap_output::h99da53e943eaf299 (wasm-function[66]:0x8c2ff) |
thanks for the quick response! I like the fix, it works on wasm32-unknown-unknown. I currently don't have a wasi enabled environment ready unfortunately. The only remaining problem I have is that on my dualcore i7 laptop (not the best, not the worst) it takes ages (no pun intended) (like about three minutes). (Given that I'd expect about a 2x perf decrease from web assembly this seems a bit off to me. When I "hacked" up the solution I used a value of 12 which still "felt" quick, (but not instantaneous). If your judgement is that 18 should be kept thats fine with me as I can patch it up for experiments if needed. |
Yeah, do check that you aren't in debug mode. This tripped me up earlier; rage was auto-selecting 12 as around one second of work in debug, but 18 in release mode, and because these differ by more than 4 I couldn't decrypt in debug mode anything I encrypted in release mode. I'll see if I can use the cfg flags to handle the guesses internally. If it turns out that we need different guesses for different targets, I'll rework the PR. |
This very much sounds like it could be my issue so thats good to know. Based on that |
Sounds good. Please open a new issue for any future requests or feedback 🙂 |
@benmkw I'm curious, did you ever get a web UI up and running to use Age? What's the JS usage like once it's compiled to WASM? (It'd help me a ton to see any code snippets of the JS API even if you never got a full thing running!) |
I started building a WASM wrapper for I'd definitely appreciate contributions there from people who know JavaScript better than I (or even better, converting what's there to TypeScript). |
So I have a small project up as well but it’s just using strings as in and output so that’s not ideal, I think @str4d project handles this much better using streams so probably better to look at that. Speed was about 2x slower than native I believe so i think age on the web is totally feasible. |
@pirate one thing that might be nice is to have npm run dev e.g. invoke cargo, in my setup you can change any rust or js/ts file and everything reloads as necessary (https://github.com/benmkw/svelte_rust_test) but these things always take some trial and error but I guess this would be appreciated :D @str4d a friend made these mockups for an app UI/ mobile version which we could translate (sorry its german, was just a quick mockup) to englisch and share if that would help, we did not yet manage to make much progress on the coding part (time and stuff :D) so its basically just collecting dust at the moment. The UI we imagined is basically:
This is not perfect but we thought about making this as approachable as possible basically for non IT people. There are some considerations e.g. if the user does not input a password, a strong one time key could be generated and if a password is used that would not be ideal but the user can reuse that several times using password based enc/dec. Also the enc/ dec screens are not displayed here. |
Let's make the
age
crate usable in WASM!The text was updated successfully, but these errors were encountered: