Skip to content

feat(sdk-lib-mpc): EddsaRetrofitData type + DKG retrofit constructor + getFirstMessage routing - #9481

Merged
Marzooqa merged 1 commit into
masterfrom
WCI-1261-EddsaRetrofitData-DKG-constructor
Aug 14, 2026
Merged

feat(sdk-lib-mpc): EddsaRetrofitData type + DKG retrofit constructor + getFirstMessage routing#9481
Marzooqa merged 1 commit into
masterfrom
WCI-1261-EddsaRetrofitData-DKG-constructor

Conversation

@bitgo-ai-agent-dev

@bitgo-ai-agent-dev bitgo-ai-agent-dev Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What

  • Add optional `retrofitData?: EddsaRetrofitData` 4th parameter to the `DKG`
    constructor in `modules/sdk-lib-mpc/src/tss/eddsa-mps/dkg.ts`.
  • Store `retrofitData` as a private field on the instance.
  • In `getFirstMessage()`, branch on `this.retrofitData`: when set, call
    `wasm.ed25519_dkg_round0_import` with the party's clamped scalar,
    aggregate public key, and chain code; otherwise fall through to the
    existing `ed25519_dkg_round0_process` path.
  • Export `EddsaRetrofitData` as a named type from `eddsa-mps/index.ts` so
    callers can import it directly without going through the `MPSTypes` namespace.
  • Bump `@bitgo/wasm-mps` from `1.10.0` → `1.12.0` (exports
    `ed25519_dkg_round0_import` with a proper TypeScript signature — no
    `as any` cast needed) and update `yarn.lock` accordingly.
  • Extend `generateEdDsaDKGKeyShares` in `util.ts` to accept per-party
    `retrofitData` params and forward them to the `DKG` constructor.
  • Add three retrofit DKG tests in `test/unit/tss/eddsa/dkg.ts`:
    • routing test (all parties agree on public key after retrofit DKG)
    • differentiation test (retrofit vs fresh DKG produce distinct keys)
    • determinism test (same `retrofitData` inputs produce same public key)

Why

  • Parties migrating from MPCv1 (Zengo) to MPCv2 (Silence Labs MPS) already
    hold a valid EdDSA scalar (`pShare.u`). Generating fresh key material would
    produce a new public key, breaking wallet continuity.
  • `ed25519_dkg_round0_import` accepts the existing scalar and seeds a
    retrofit DKG ceremony that produces MPCv2 shares for the same aggregate
    public key, enabling transparent migration without user action.
  • Rounds 1 and 2 (`handleIncomingMessages`) are unchanged — both paths
    produce identical `dkgStateBytes` format, so no downstream code changes.

Test plan

  • `yarn workspace @bitgo/sdk-lib-mpc test` — all existing + new DKG tests pass.
  • TypeScript compiles cleanly in `modules/sdk-lib-mpc`.

Ticket: WCI-1261

@linear-code

linear-code Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

WCI-1261

@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from e79929c to 990112e Compare August 12, 2026 07:05
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 990112e to 54a371c Compare August 12, 2026 07:22
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 54a371c to 045559a Compare August 12, 2026 07:22
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 045559a to e94d057 Compare August 12, 2026 08:30
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from e94d057 to cf3cb10 Compare August 12, 2026 08:31
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from cf3cb10 to b5193dd Compare August 12, 2026 10:53
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from b5193dd to fdf95f7 Compare August 12, 2026 10:53
Base automatically changed from WCI-1263-getMpcV2RetrofitDataFromMpcV1Key-EdDSA to master August 13, 2026 06:24
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from fdf95f7 to d219ede Compare August 13, 2026 06:27
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch 2 times, most recently from 8f72917 to 58ebac8 Compare August 13, 2026 06:49
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 58ebac8 to 8d67c7c Compare August 13, 2026 07:24
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch 2 times, most recently from 9ad91ef to 20b67fd Compare August 13, 2026 08:39
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 20b67fd to 9ade6eb Compare August 13, 2026 10:16
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 9ade6eb to 61fb76a Compare August 13, 2026 10:16
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch 2 times, most recently from 20a5005 to 6117b6d Compare August 13, 2026 14:30
@Marzooqa
Marzooqa marked this pull request as ready for review August 13, 2026 15:59
@Marzooqa
Marzooqa requested review from a team as code owners August 13, 2026 15:59
@Marzooqa

Copy link
Copy Markdown
Contributor

@claude

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Marzooqa's task —— View job


PR Review: EdDSA Retrofit Data Implementation

Final Review Summary

This PR successfully implements EdDSA retrofit functionality for MPCv1 → MPCv2 migration. The implementation is well-designed, secure, and thoroughly tested.

Strengths

1. Clean Architecture & API Design

  • Optional 4th constructor parameter maintains backward compatibility
  • EddsaRetrofitData type exported directly for clean imports
  • Clear separation between retrofit and fresh DKG paths

2. Security Best Practices

  • Retrofit data cleared after round0 consumption (dkg.ts:149)
  • No any types used - proper TypeScript safety maintained
  • Session persistence includes retrofit data for proper state management
  • Error handling with descriptive messages around WASM calls

3. Implementation Quality

  • Correct WASM function routing: ed25519_dkg_round0_import vs ed25519_dkg_round0_process
  • Proper hex string → Buffer conversions for WASM interface
  • Dependencies correctly updated: @bitgo/wasm-mps 1.11.0 → 1.12.0

4. Excellent Test Coverage

  • 3 comprehensive retrofit tests: routing, differentiation, determinism
  • buildRetrofitData() helper mirrors real-world Eddsa class behavior
  • Session export/restore with retrofit data verification
  • Deterministic test seeds for reproducible results

5. Code Quality

  • No debug statements, TODOs, or code smells found
  • Follows existing patterns and conventions
  • Clear documentation and comments

Requirements Met

  • ✅ DKG constructor accepts optional retrofitData parameter
  • ✅ Retrofit data stored as private field and cleared after use
  • getFirstMessage() correctly branches on retrofit vs fresh DKG
  • EddsaRetrofitData exported as named type
  • @bitgo/wasm-mps bumped to 1.12.0 with proper TypeScript support
  • generateEdDsaDKGKeyShares extended with retrofit parameters
  • ✅ Three comprehensive retrofit tests added

📝 Minor Notes

  • All WASM calls properly wrapped in try-catch blocks
  • Session management correctly handles retrofit data persistence
  • Utility functions maintain backward compatibility

Overall Assessment: LGTM 🎉

This PR is ready for merge. The retrofit functionality enables seamless MPCv1 → MPCv2 migration while maintaining the same aggregate public key, exactly as specified.

--- |

Comment thread modules/sdk-lib-mpc/test/unit/tss/eddsa/dkg.ts Outdated
Comment thread modules/sdk-lib-mpc/test/unit/tss/eddsa/dkg.ts Outdated
vibhavgo
vibhavgo previously approved these changes Aug 14, 2026

@vibhavgo vibhavgo left a comment

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.

LGTM

@Marzooqa
Marzooqa force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 6117b6d to 502e157 Compare August 14, 2026 07:55
…tructor

Add optional `retrofitData` parameter to the `DKG` constructor so parties
can seed a retrofit DKG ceremony from their existing MPCv1 scalar instead
of generating fresh key material.

- Import and store `EddsaRetrofitData` on the `DKG` class instance.
- Constructor gains a 4th optional param: `retrofitData?: EddsaRetrofitData`.
- `getFirstMessage` branches on `this.retrofitData`: when set it calls
  `wasm.ed25519_dkg_round0_import` (ships in WCI-1217) passing the
  party's clamped scalar, aggregate public key, and chain code; otherwise
  it falls through to the existing `ed25519_dkg_round0_process` path.
- Clear `retrofitData` once consumed, and persist/restore it in the
  session blob so a restored party can still run round 0.
- Export `EddsaRetrofitData` as a named type from `eddsa-mps/index.ts`
  so callers can import it directly without going through `MPSTypes`.

Tests derive retrofit inputs via `buildRetrofitData`, mirroring
`Eddsa.keyShare` + `keyCombine`, and cover routing, determinism, and
session export/restore.

Ticket: WCI-1261
Co-authored-by: Cursor <cursoragent@cursor.com>
@Marzooqa
Marzooqa force-pushed the WCI-1261-EddsaRetrofitData-DKG-constructor branch from 502e157 to 06cf112 Compare August 14, 2026 08:03
@Marzooqa
Marzooqa enabled auto-merge August 14, 2026 08:14
@Marzooqa
Marzooqa added this pull request to the merge queue Aug 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Aug 14, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@louib
louib added this pull request to the merge queue Aug 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Aug 14, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@louib
louib added this pull request to the merge queue Aug 14, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Aug 14, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@Marzooqa
Marzooqa merged commit 4673c82 into master Aug 14, 2026
27 checks passed
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.

3 participants