Closed Jonas-Metzger closed 3 years ago
According to actual JavaScript sources it will pretty hard (promises, inline objects and etc) and I don't understand why you need this. PKIjs based on WebCrypto API which already very fast
Thank you. I want to run an existing JS tool (with pkijs dependencies) on a VM that only supports wasm. Performance isn't important. I'll have to use the Botan C++ library instead of pkijs then, which should compile to wasm via empscripten.
Is it possible to use a wasm compiled Botan from AS code easily? Could this combination be compiled into a single wasm file? Mainly asking out of curiosity, I assume it's easier to just port the remaining JS code I need to C++ as well.
Thanks!
I assume it's easier to just port the remaining JS code I need to C++ as well.
I guess better just find similar crypto library on C++ or Rust
Thanks! The JS tool I want to use on a wasm VM are (certain functions within) TLSNotary/PageSigner, it's unfortunately unique. I'm not very familiar with JS and less so with C++, so if it is possible to use a wasm compiled botan lib inside AS, such that I just have to port the functions from JS to AS and replace pkijs calls with botan calls, that seems much more feasible for me to do.
I know people have successfully compiled Botan to wasm and used it inside JS. Does the same work in AS? Can the result compile to a self-contained wasm file?
botan written on C++. Static linking different languajes like C++ and AssemblyScript not possible. So you should port everything to AssemblyScript (including Botan lib) or port everything to C++. I guess second approach easier. Also note if you required standalone wasm compilation (without js glue code) for C++ via emscripten it's also not easy and may have a lot of problems. It's not the same as compile to wasm in standard mode (with a lot of js glue code)
Oh no, that's annoying. Thanks a lot for the heads up! Is there anyway to anticipate when empscripten may run into issues with wasm standalone mode? E.g. should I try to compile botan and similar alternatives into standalone wasm first, and if one of them works, I could be optimistic about a subsequent C++ port working? The other TLSNotary code is just some basic json parsing, all heavy lifting is done by the pkijs crypto primitives.
just try to compile with STANDALONE_WASM flag
Thank you! Will try that. Other thought: would I have an easier time trying the same in Rust (i.e. switching pkijs to e.g. Rust Crypto and coding the remaining TLSNotary code in Rust)? Would this more likely compile without errors or creating gluecode?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in one week if no further activity occurs. Thank you for your contributions!
How hard is it to get the functionality of the pkijs package (Typescript Implementation) in AssemblyScript code?
Do I have to rewrite it in AssemblyScript or could the pkijs Typescript package just be imported as is?