Skip to content

feat(sdk-core): getUserAndBackupSession + createKeychains retrofit wiring - #9482

Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
WCI-1261-EddsaRetrofitData-DKG-constructorfrom
WCI-1264-getUserAndBackupSession-createKeychains-retrofit
Draft

feat(sdk-core): getUserAndBackupSession + createKeychains retrofit wiring#9482
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
WCI-1261-EddsaRetrofitData-DKG-constructorfrom
WCI-1264-getUserAndBackupSession-createKeychains-retrofit

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown
Contributor

What

  • Added retrofit?: DecryptedRetrofitPayload to EddsaMPCv2Utils.createKeychains() params
  • Added private getUserAndBackupSession(retrofit?) method that branches on the retrofit flag:
    • With retrofit: derives EddsaRetrofitData from MPCv1 key shares via getMpcV2RetrofitDataFromMpcV1Keys and constructs DKG instances with retrofit data
    • Without retrofit: constructs plain DKG instances (existing behavior unchanged)
  • Replaced inline new EddsaMPSDkg.DKG(...) calls in createKeychains with getUserAndBackupSession
  • Extended sendKeyGenerationRound1 / sendKeyGenerationRound1BySender payload types to allow walletId?: string
  • Spread walletId into the R1 request body when params.retrofit?.walletId is present, so server-side isRound1RetrofitDKG() detection kicks in
  • Unit tests for getUserAndBackupSession (both paths) and for walletId presence/absence in the captured R1 payload

Why

  • EdDSA wallet retrofit (upgrading MPCv1 → MPCv2) requires the DKG ceremony to be seeded with the existing MPCv1 key material instead of fresh randomness, so the resulting MPCv2 keychain derives from the same root key that the wallet already uses
  • The server identifies a retrofit DKG round by the presence of walletId in the R1 payload; without this wiring the server would treat every key-gen as a fresh creation
  • Follows the identical pattern already implemented for ECDSA in ecdsaMPCv2.ts (line 639 getUserAndBackupSession, line 126-129 walletId spread)

Test plan

  • EddsaMPCv2Utils.getUserAndBackupSession — returns plain DKG sessions when retrofit is undefined
  • EddsaMPCv2Utils.getUserAndBackupSession — returns retrofit-seeded DKG sessions when retrofit payload is supplied
  • EddsaMPCv2Utils.createKeychains with retrofit wiringwalletId present in R1 payload when retrofit provided
  • EddsaMPCv2Utils.createKeychains with retrofit wiringwalletId absent from R1 payload when no retrofit
  • All existing EddsaMPCv2Utils unit tests continue to pass

Stack

This PR is part 3 of 3 in a stacked series. Review and merge in order:

  1. WCI-1261EddsaRetrofitData type + DKG retrofit constructor + getFirstMessage routing (base: master)
  2. WCI-1263getMpcV2RetrofitDataFromMpcV1Keys for EdDSA (base: WCI-1261-EddsaRetrofitData-DKG-constructor)
  3. This PR — getUserAndBackupSession + createKeychains retrofit wiring (base: WCI-1261-EddsaRetrofitData-DKG-constructor) ← you are here

Ticket: WCI-1264

@linear-code

linear-code Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

WCI-1264

@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1264-getUserAndBackupSession-createKeychains-retrofit branch from 800cab5 to b1cb0e7 Compare August 12, 2026 08:49
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1264-getUserAndBackupSession-createKeychains-retrofit branch from b1cb0e7 to 6c7bcfa Compare August 12, 2026 09:38
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1264-getUserAndBackupSession-createKeychains-retrofit branch from 6c7bcfa to 47cfe16 Compare August 12, 2026 09:38
@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
@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 from d219ede to ce90652 Compare August 13, 2026 06:27
@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 from 8d67c7c to 4055fe5 Compare August 13, 2026 07:24
@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
…ring

Wire the retrofit path into EddsaMPCv2Utils.createKeychains(). When a
retrofit payload is supplied, getUserAndBackupSession() initialises user
and backup DKG sessions with EddsaRetrofitData (via
getMpcV2RetrofitDataFromMpcV1Keys) instead of fresh randomness. The R1
request body includes walletId so the server-side
isRound1RetrofitDKG() detection kicks in.

Changes:
- Add retrofit?: DecryptedRetrofitPayload to createKeychains() params
- Add private async getUserAndBackupSession() that branches on retrofit
- Replace inline DKG construction with getUserAndBackupSession() call
- Extend sendKeyGenerationRound1/BySender payload type to allow walletId
- Spread walletId into R1 payload when retrofit.walletId is present
- Tests for getUserAndBackupSession (no-retrofit and retrofit paths) and
  for walletId presence/absence in the captured R1 payload

Follows the same pattern as ecdsaMPCv2.ts getUserAndBackupSession
(line 639) and the walletId spread (line 126-129).

Ticket: WCI-1264
Session-Id: 597157b8-fee3-4515-b21b-4030e08362e8
Task-Id: 15dfe9c9-d429-4559-b0fc-771ada5e3c3a
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the WCI-1264-getUserAndBackupSession-createKeychains-retrofit branch from 47cfe16 to 5965a4c Compare August 13, 2026 14:33
@ralph-bitgo
ralph-bitgo Bot force-pushed the WCI-1264-getUserAndBackupSession-createKeychains-retrofit branch from 5965a4c to 007e0c8 Compare August 13, 2026 14:33
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