Skip to content
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

fix: nodejs wasm error #50

Merged
merged 3 commits into from
Mar 18, 2023
Merged

fix: nodejs wasm error #50

merged 3 commits into from
Mar 18, 2023

Conversation

Ansonhkg
Copy link
Collaborator

@Ansonhkg Ansonhkg commented Mar 18, 2023

What

A previous fix for issue #20 has caused node.js to break when combining shares.

[Lit-JS-SDK v2.1.86] Failed to combine signatures: RuntimeError: unreachable
    at __rust_start_panic (wasm://wasm/000bc506:wasm-function[678]:0x1d21c)
    at rust_panic (wasm://wasm/000bc506:wasm-function[435]:0x1bf45)
    at std::panicking::rust_panic_with_hook::h61526751b8cd9479 (wasm://wasm/000bc506:wasm-function[150]:0x1524b)
    at std::panicking::begin_panic_handler::{{closure}}::h43c4acb92b12b353 (wasm://wasm/000bc506:wasm-function[198]:0x175c1)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h26ed495360c53bfb (wasm://wasm/000bc506:wasm-function[541]:0x1cb84)
    at rust_begin_unwind (wasm://wasm/000bc506:wasm-function[366]:0x1b21a)
    at core::panicking::panic_fmt::h210f123621d50106 (wasm://wasm/000bc506:wasm-function[374]:0x1b3ef)
    at core::result::unwrap_failed::h10f64d212245e66a (wasm://wasm/000bc506:wasm-function[213]:0x17d62)
    at <ecdsa_wasm::curv::elliptic::curves::secp256_k1::Secp256k1Scalar as ecdsa_wasm::curv::elliptic::curves::traits::ECScalar<secp256k1::SecretKey>>::new_random::h809e490eefd73c9a (wasm://wasm/000bc506:wasm-function[189]:0x17023)
    at <ecdsa_wasm::curv::elliptic::curves::secp256_k1::Secp256k1Scalar as ecdsa_wasm::curv::elliptic::curves::traits::ECScalar<secp256k1::SecretKey>>::add::h2b2ace4c587d6646 (wasm://wasm/000bc506:wasm-function[126]:0x13822)
[Lit-JS-SDK v2.1.86] signature 
Error: signature missing v and recoveryParam (argument="signature", value={"r":"0xundefined","s":"0xundefined"}, code=INVALID_ARGUMENT, version=bytes/5.7.0)
    at Logger.makeError (/Users/nson/Projects/js-sdk-main/node_modules/@ethersproject/logger/lib/index.js:238:21)
    at Logger.throwError (/Users/nson/Projects/js-sdk-main/node_modules/@ethersproject/logger/lib/index.js:247:20)
    at Logger.throwArgumentError (/Users/nson/Projects/js-sdk-main/node_modules/@ethersproject/logger/lib/index.js:250:21)
    at splitSignature (/Users/nson/Projects/js-sdk-main/node_modules/@ethersproject/bytes/lib/index.js:359:24)
    at joinSignature (/Users/nson/Projects/js-sdk-main/node_modules/@ethersproject/bytes/lib/index.js:419:17)
    at /Users/nson/Projects/js-sdk-main/dist/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.js:900:62
    at Array.forEach (<anonymous>)
    at LitNodeClientNodeJs.getSignatures (/Users/nson/Projects/js-sdk-main/dist/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.js:863:18)
    at LitNodeClientNodeJs.executeJs (/Users/nson/Projects/js-sdk-main/dist/packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.js:1052:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  reason: 'signature missing v and recoveryParam',
  code: 'INVALID_ARGUMENT',
  argument: 'signature',
  value: [Object]
}
[ECDSA-SDK] __wbg_require_edfaedd93e302925
[ECDSA-SDK] ret: crypto
panicked at 'called `Result::unwrap()` on an `Err` value: Error { internal_code: 2147483661, description: "Node.js API crypto.randomFillSync is unavailable" }', src/curv/elliptic/curves/secp256_k1.rs:135:52

Stack:

Error
    at imports.wbg.__wbg_new_693216e109162396 (/Users/nson/Projects/js-sdk-main/dist/packages/ecdsa-sdk/src/lib/ecdsa-sdk.js:458:19)
    at console_error_panic_hook::hook::hcf53d7f427a4ce64 (wasm://wasm/000bc506:wasm-function[112]:0x12677)
    at core::ops::function::Fn::call::heedcc26ca94af21b (wasm://wasm/000bc506:wasm-function[654]:0x1d164)
    at std::panicking::rust_panic_with_hook::h61526751b8cd9479 (wasm://wasm/000bc506:wasm-function[150]:0x15220)
    at std::panicking::begin_panic_handler::{{closure}}::h43c4acb92b12b353 (wasm://wasm/000bc506:wasm-function[198]:0x175c1)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h26ed495360c53bfb (wasm://wasm/000bc506:wasm-function[541]:0x1cb84)
    at rust_begin_unwind (wasm://wasm/000bc506:wasm-function[366]:0x1b21a)
    at core::panicking::panic_fmt::h210f123621d50106 (wasm://wasm/000bc506:wasm-function[374]:0x1b3ef)
    at core::result::unwrap_failed::h10f64d212245e66a (wasm://wasm/000bc506:wasm-function[213]:0x17d62)
    at <ecdsa_wasm::curv::elliptic::curves::secp256_k1::Secp256k1Scalar as ecdsa_wasm::curv::elliptic::curves::traits::ECScalar<secp256k1::SecretKey>>::new_random::h809e490eefd73c9a (wasm://wasm/000bc506:wasm-function[189]:0x17023)

Solution

Reverting back and pushed to master for now. Will be looking at creating a separated ecdsa-sdk package for browser so that the React warning wouldn't appear. Sorry for that!

@Ansonhkg Ansonhkg merged commit ac4ce7d into master Mar 18, 2023
@Ansonhkg Ansonhkg mentioned this pull request May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant