Comments (4)
The current state of Rust and WebAssembly is a shit show.
How are you compiling it?
I tried compiling rsign2
for wasix.
cargo wasix
is currently broken:
$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)
$ cargo wasix run
You might have to run `cargo update` to ensure the dependencies are used properly
error: package `clap v4.5.1` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.73.0-dev
Either upgrade to rustc 1.74 or newer, or use
cargo update [email protected] --precise ver
where `ver` is the latest version of `clap` supporting rustc 1.73.0-dev
But cargo wasi
works:
$ cargo wasi build
$ wasmer target/wasm32-wasi/debug/rsign.wasm
Usage: rsign2 [COMMAND]
from rust-minisign.
Thanks for getting back to me! That's fair to say :)
I'm just compiling my project with cargo build --release --target wasm32-unknown-unknown
. That part works fine. It's when I deploy my code into wasmer
and it gets put through the wasmer-cranelift-compiler
that I get an error
error occurred during test run: internal_error: Wasm runtime error: RuntimeError: WasmError { error: Compile("Error while importing \"__wbindgen_placeholder__\".\"__wbindgen_is_object\": unknown import. Expected Function(FunctionType { params: [I32], results: [I32] })") }
I don't know a huge amount about this step but I can find out more if that would be useful. My understanding stops with, the wasm I build for wasmer shouldn't contain anything that it that is intended for a different/JavaScript runtime.
from rust-minisign.
There are different variants of WebAssembly.
wasm32-unknown-unknown
is a funny name for what's called wasm32-freestanding
elsewhere. That variant doesn't include any functions to get random numbers. It's generally only used to generate code that runs in web browsers, and calls JavaScript functions in order to do so.
Unlike a runtime like bun
or node
, wasmer
doesn't support JavaScript. But the variants it supports are called emscripten
, wasi-core
and wasix
.
Rust is not able to target emscripten
any more until someone steps up to work on it, and the tool to target Wasix seems currently broken. So, we're left with wasi-core
, which is also planned to be abandoned for yet another variant, even though it may live on under a different name and with different maintainers, but for now, that works.
Long story short, you need to use the wasm32-wasi
target instead of wasm32-unknown-unknown
.
from rust-minisign.
Sorry it took me a while to get around to trying this. If I build the wasm with wasm32-wasi
I get a different error
error: Compile(\"Error while importing \\\"wasi_snapshot_preview1\\\".\\\"fd_write\\\": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] })\") }), wasm_trace: [] }))
This wasmer instance has been sandboxed so it can't access anything on the host. It's providing the random implementation that's missing in wasm32-unknown-unknown
apparently.
Thanks for the suggestions anyway! I've figured out that I can depend on minisign-verify
instead which means moving things around a bit but builds beautifully into wasm for this environment :)
from rust-minisign.
Related Issues (9)
- Sign and verify test times out HOT 5
- Clarification of nonce usage HOT 7
- The two function name are inconsistent HOT 1
- `Error: Wrong password for that key` for empty passwords on Windows
- Verification fails when using the `KeyPair` returned by `generate_encrypted_keypair` HOT 3
- Consider renaming "pk" to "pubkey" everywhere HOT 1
- Signature verification on prehashed files doesn't work HOT 3
- Reducing the number of dependencies HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-minisign.