-
Notifications
You must be signed in to change notification settings - Fork 39
wasm vs asm returns different results #307
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
Comments
That would be slightly problematic to say the least since it is just a big black compilation box. |
also |
Indeed. The steps are a bit counter-intuitive, the |
ah I see, thanks chrome extension with latest manifest v3 doesnt allow webassembly (smh, the new manifest is a mess) |
The issue with the asm.js is that it is exceptionally large, so it really bloats everything when compiled into a web bundle. On the RN side there is no WASM support, so it is only enabled there. (It is quite a dance atm to swap between the two, but I don't have good ideas to make it "simple" - maybe the approach would be to have an wasm, asm and both of path exposed for easy access - but not sure how to get past init then either) I saw the manifest 3 thing, it was logged in the extension repo, it is a bridge I need to cross soon as well since the time is ticking. I can reproduce your issue and am looking at it. Weirdly it doesn't happen in #308 (and I did indeed check that the aliasing works correctly, i.e. that it indeed follows the asm path. So trying to figure out why there is a discrepancy between the two.) |
Ok... this is weird - I can reproduce it in the repo if I comment out all the other JS tests and only run the secp256k1 tests, specifically the 2 seed tests. If I add some more tests, it passes. Not that this helps, but thinking out loud -
At least can now reproduce it in here, so that is a step in the right direction. Update: If I remove only the scrypt test, the seed tests on secp256k1 fails (well, the first one fails), this line -
Update 2: Linked a PR that moves the secp256k1 tests first, which reproduced this on CI. |
oh wow never thought of that, had to go sleep after trying to debug for 3 hrs |
Would try to upgrade the wasm build deps - if an issue there, it is quite a bit behind so maybe there is a fix in there somewhere. I am guessing it is the lazy sections in the secp256k1. Worst case, will swap the Rust crate to the C++ wrapper. Either way, this is not great to say the least. |
All the WASM generator deps have been bumped. This had no effect. This HACK does yield the right results, which I'm certainly not happy with, but I have no other levers to pull here - e840a6f (Or rather, no levers that I could find, maybe the wasm/packages/wasm-crypto/src/bundle.ts Lines 57 to 72 in 0dfb491
Additionally going to add an assert in |
As an aside ... In the 5.0.1 release, the init would be simpler for asm-only or asm + wasm (intstead of duplicating what is done internally, this would hopefully make is easier for people to adjust) - // ... or initWasmAsm to have both asm & WASM support
import "@polkadot/wasm-crypto/initOnlyAsm";
import { secp256k1FromSeed, waitReady } from "@polkadot/wasm-crypto";
waitReady().then(() => {
console.log(
secp256k1FromSeed(new Uint8Array([
203, 109, 249, 222, 30, 252, 167, 163, 153, 138, 142,
173, 78, 2, 21, 157, 95, 169, 156, 62, 13, 79,
214, 67, 38, 103, 57, 11, 180, 114, 104, 84
]))
);
}); |
this is perfect for my use case, thanks @jacogr |
The need for the hack disappears in #318 - which is great news. The above swaps to the Bitcoin secp256k1 library, which also aligns with the use in Substrate and as a bonus is more performant. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query. |
outputs
however if you just use asm,
itll output
seems like asm is somehow broken
The text was updated successfully, but these errors were encountered: