Closed Gekctek closed 1 year ago
You can build a single wasm file by commenting out EMCC_OPT+=-s SINGLE_FILE=1
.
https://github.com/herumi/bls-wasm/blob/master/src/Makefile#L24
I was trying this before with no luck. Doing that I generate the js file and inside I see the base64 wasm but whenever i try to convert that base64 to a wasm file it doesnt seem to like it. Im not sure if there is special about the embedded base64 but I get an invalid wasm file
I was also trying to do something more like
emcc -o bls.wasm $(BLS_DIR)/src/bls_c384_256.cpp $(MCL_DIR)/src/fp.cpp $(EMCC_OPT)
with modified EMCC_OPT where it would just spit out the wasm but I get the error
But Im really just throwing stuff at the wall to see what works without much experience with emcc.
Any advice on general direction to go with it. Im trying to embed it in my C# code with something like https://github.com/bytecodealliance/wasmtime-dotnet so i can just call the wasm vs a native library
it would just spit out the wasm but I get the error undefined symbol: main
Since it is a library, it is natural that there is no main.
I've not used bytecodealliance. How about calling blsInit in bls.wasm from your C# according to the reference and https://github.com/herumi/bls/blob/master/ffi/cs/bls.cs#L170 ?
My question is more of do you have any support for building it as a plain wasm library, if not I'll just do some research and try to make that possible. I haven't even gotten to embedding in in C#, i was just showing where i when to go. The error i get is from trying to build with emcc
I can't answer your question unless you show me how you modified the Makefile, what you ran (system, emcc version, etc.), and what kind of error you got (text displayed, not images).
Ya my problem ended up being the missing -no-entry
when building just WASM. But it turned out also that the WASM generated in the JS was just fine, but the wasm2wat
tool doesnt seem to like to parse it, but the C# tool seems to think its ok.
I have it mostly setup (if youre curious https://github.com/edjCase/ICP.NET/blob/WASM/src/EdjCase.Cryptography.BLS/BlsLib.cs) but am still running into some issues. I am just getting a general issue with my signature validation now fails compared to the native library reference. My guess is its how Im encoding the strings when sending them over, but its hard to tell. Doesn't seem like there are a lot of debugging options to see what could be going on besides guess and check. Ill let you if I get anywhere with it
Alright. Looks like the issue was something to do with using the structs with fixed ulong fields. I just switched everything to using just byte arrays and it works great. Appreciate your help even though Im a bit absent minded
If you are curious about my implementation, its just a few files here https://github.com/edjCase/ICP.NET/tree/main/src/BLS
Okay. I'll check your code later.
As far as the WASM build, is it possible to build the standalone WASM file like
emcc ... -o output.wasm omits generating either JavaScript or HTML launcher file, and produces a single Wasm file built in standalone mode as if the -sSTANDALONE_WASM settting had been used.
I wasn't having much success poking at it, but im looking to just have the raw WASM that I can utilize in C# vs in the browser.