Skip to content

fix(sdk-lib-mpc): re-derive dkgState from WASM bytes in restoreSession#8466

Open
mohammadalfaiyazbitgo wants to merge 1 commit intomasterfrom
worktree-WAL-396-fix-dkg-restore-session
Open

fix(sdk-lib-mpc): re-derive dkgState from WASM bytes in restoreSession#8466
mohammadalfaiyazbitgo wants to merge 1 commit intomasterfrom
worktree-WAL-396-fix-dkg-restore-session

Conversation

@mohammadalfaiyazbitgo
Copy link
Copy Markdown
Contributor

Summary

  • Dkg.restoreSession() now calls _deserializeState() after _restoreSession() to always derive dkgState from the actual WASM bytes, ignoring the caller-supplied value in DkgSessionData
  • Adds a Complete state override when keyShareBuff is present, since the WASM bytes still reflect WaitMsg4 after keyshare() frees the session
  • Adds a regression test asserting that a tampered dkgState in session data is ignored on restore

Test plan

  • yarn run unit-test --scope @bitgo/sdk-lib-mpc -- -- --grep "restoreSession" — new tampered-state test passes
  • yarn run unit-test --scope @bitgo/sdk-lib-mpc — all existing DKG round-trip tests continue to pass

WAL-396

🤖 Generated with Claude Code

Call _deserializeState() after _restoreSession() so dkgState is always
derived from the actual WASM bytes instead of the caller-supplied value.
When keyShareBuff is present, override state to Complete since the WASM
bytes still reflect WaitMsg4 after keyshare() frees the session.

Adds a regression test verifying tampered dkgState is ignored.

WAL-396

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@linear
Copy link
Copy Markdown

linear bot commented Apr 9, 2026

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo marked this pull request as ready for review April 9, 2026 20:37
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo requested review from a team as code owners April 9, 2026 20:37
Comment on lines +356 to +360
if (sessionData.keyShareBuff) {
// After keyshare() is called the WASM session is freed and dkgSessionBytes still reflect WaitMsg4.
// Presence of keyShareBuff is the reliable signal that the protocol completed.
dkg.dkgState = DkgState.Complete;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be handled by _deserializeState

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.

2 participants