Skip to content

fix(sdk-lib-mpc): use @bitgo/wasm-mps/web in browser to fix EdDSA MPCv2 DKG TypeError#8643

Open
bitgo-ai-agent-dev[bot] wants to merge 1 commit intomasterfrom
wci-251-eddsa-mps-browser-wasm-fix
Open

fix(sdk-lib-mpc): use @bitgo/wasm-mps/web in browser to fix EdDSA MPCv2 DKG TypeError#8643
bitgo-ai-agent-dev[bot] wants to merge 1 commit intomasterfrom
wci-251-eddsa-mps-browser-wasm-fix

Conversation

@bitgo-ai-agent-dev
Copy link
Copy Markdown

@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot commented Apr 28, 2026

Summary

  • Bumps @bitgo/wasm-mps to 1.8.1, which adds a --target web build exposed via the @bitgo/wasm-mps/web subpath export
  • In browser environments, loadWasmMps() now imports from @bitgo/wasm-mps/web and explicitly awaits init() before use — same pattern as @silencelaboratories/dkls-wasm-ll-web
  • In Node.js, behaviour is unchanged: import('@bitgo/wasm-mps') is compiled by tsc to require(), resolving the CJS build

Background

The existing @bitgo/wasm-mps builds are not browser-safe:

  • Webpack picks up the ESM bundler build. The internal wasm variable can be undefined at call time due to a __wbg_set_wasm timing issue →
    wasm.ed25519_dkg_round0_process is not a function
  • Turbopack falls through to the CJS build, which calls fs.readFileSync — not available in browsers → turbopack_context.r(...).readFileSync is
    not a function

The --target web build loads wasm via fetch() and exposes an explicit init(), eliminating both failure modes.

Linear

Ticket: WCI-251

🤖 Generated with Claude Code

@linear
Copy link
Copy Markdown

linear Bot commented Apr 28, 2026

@Marzooqa Marzooqa force-pushed the wci-251-eddsa-mps-browser-wasm-fix branch 2 times, most recently from cde1353 to 31a0c68 Compare April 28, 2026 19:21
@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot force-pushed the wci-251-eddsa-mps-browser-wasm-fix branch from 014ee99 to 2b74568 Compare April 28, 2026 19:26
@Marzooqa Marzooqa force-pushed the wci-251-eddsa-mps-browser-wasm-fix branch 3 times, most recently from a15675f to f4c386f Compare April 28, 2026 20:09
@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot force-pushed the wci-251-eddsa-mps-browser-wasm-fix branch from 6aa13cc to 9eaf2b5 Compare April 28, 2026 20:12
In browsers (webpack), importing @bitgo/wasm-mps resolves to the
--target bundler ESM build which has a race condition between
webpack's async WASM instantiation and __wbg_set_wasm being called.
This causes wasm.ed25519_dkg_round0_process to be undefined when
initDkg() runs.

Mirror the ECDSA pattern in ecdsa-dkls/dkg.ts: detect browser via
`typeof window !== 'undefined'` (excluding Electron via window.process
checks), then use @bitgo/wasm-mps/web which exposes an explicit
init() function — guaranteed ready after await.

Adds a local .d.ts shim for @bitgo/wasm-mps/web until WCI-250
publishes the ./web subpath export with its own types.

Ticket: WCI-251
@Marzooqa Marzooqa force-pushed the wci-251-eddsa-mps-browser-wasm-fix branch from 9eaf2b5 to c474524 Compare April 28, 2026 20:14
@Marzooqa Marzooqa marked this pull request as ready for review April 28, 2026 20:40
@Marzooqa Marzooqa requested review from a team as code owners April 28, 2026 20:40
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.

4 participants