-
Notifications
You must be signed in to change notification settings - Fork 304
feat: add external signer support for ECDSA and EdDSA TSS key generation #9128
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
Open
danielpeng1
wants to merge
1
commit into
master
Choose a base branch
from
WCN-682/callbacks-mpc-tss-wallet-gen
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,241
−21
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import * as t from 'io-ts'; | ||
| import { DklsTypes } from '@bitgo/sdk-lib-mpc'; | ||
| import { MPCv2BroadcastMessage, MPCv2P2PMessage } from '@bitgo/public-types'; | ||
|
|
||
| import { EncryptionVersion, IRequestTracer } from '../../api'; | ||
| import { KeychainsTriplet, LightningKeychainsTriplet } from '../baseCoin'; | ||
| import { Keychain, WebauthnInfo } from '../keychain'; | ||
| import { ApiKeyShare, Keychain, WebauthnInfo } from '../keychain'; | ||
| import { IWallet, PaginationOptions, WalletShare } from './iWallet'; | ||
| import { Wallet } from './wallet'; | ||
|
|
||
|
|
@@ -76,6 +78,105 @@ export interface CreateKeychainCallbackResult { | |
|
|
||
| export type CreateKeychainCallback = (params: CreateKeychainCallbackParams) => Promise<CreateKeychainCallbackResult>; | ||
|
|
||
| /** Per-source encrypted session state threaded through MPC rounds by the external signer. */ | ||
| export interface ExternalSignerMpcState { | ||
| encryptedData: string; | ||
| encryptedDataKey: string; | ||
| } | ||
|
|
||
| /** A key share supplied by the external signer — routing fields (from/to) are added by the SDK. */ | ||
| export type ExternalSignerKeyShare = Omit<ApiKeyShare, 'from' | 'to'> & { | ||
| privateShareProof: string; | ||
| vssProof: string; | ||
| gpgKey: string; | ||
| }; | ||
|
|
||
| export type EcdsaMPCv2KeyGenInitializeCallback = (params: { | ||
| enterprise: string; | ||
| bitgoPublicGpgKey: string; | ||
| }) => Promise<{ | ||
| userGpgPublicKey: string; | ||
| backupGpgPublicKey: string; | ||
| round1Messages: DklsTypes.AuthEncMessages; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }>; | ||
|
|
||
| export type EcdsaMPCv2KeyGenRound2Callback = (params: { | ||
| sessionId: string; | ||
| bitgoMsg1: MPCv2BroadcastMessage; | ||
| bitgoToUserMsg2: MPCv2P2PMessage; | ||
| bitgoToBackupMsg2: MPCv2P2PMessage; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }) => Promise<{ | ||
| round2Messages: DklsTypes.AuthEncMessages; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }>; | ||
|
|
||
| export type EcdsaMPCv2KeyGenRound3Callback = (params: { | ||
| sessionId: string; | ||
| bitgoCommitment2: string; | ||
| bitgoToUserMsg3: MPCv2P2PMessage; | ||
| bitgoToBackupMsg3: MPCv2P2PMessage; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }) => Promise<{ | ||
| round3Messages: DklsTypes.AuthEncMessages; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }>; | ||
|
|
||
| export type EcdsaMPCv2KeyGenFinalizeCallback = (params: { | ||
| sessionId: string; | ||
| bitgoMsg4: MPCv2BroadcastMessage; | ||
| bitgoCommonKeychain: string; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| }) => Promise<{ commonKeychain: string }>; | ||
|
|
||
| export interface EcdsaMPCv2KeyGenCallbacks { | ||
| initializeCallback: EcdsaMPCv2KeyGenInitializeCallback; | ||
| round2Callback: EcdsaMPCv2KeyGenRound2Callback; | ||
| round3Callback: EcdsaMPCv2KeyGenRound3Callback; | ||
| finalizeCallback: EcdsaMPCv2KeyGenFinalizeCallback; | ||
| } | ||
|
|
||
| export interface EddsaKeyGenInitializeResult { | ||
| userGpgPublicKey: string; | ||
| backupGpgPublicKey: string; | ||
| userToBitgoKeyShare: ExternalSignerKeyShare; | ||
| backupToBitgoKeyShare: ExternalSignerKeyShare; | ||
| userState: ExternalSignerMpcState; | ||
| backupState: ExternalSignerMpcState; | ||
| backupCounterPartyKeyShare: ExternalSignerKeyShare; | ||
| } | ||
|
|
||
| export type EddsaKeyGenInitializeCallback = (params: { | ||
| enterprise: string; | ||
| bitgoPublicGpgKey: string; | ||
| }) => Promise<EddsaKeyGenInitializeResult>; | ||
|
|
||
| export type EddsaKeyGenFinalizeResult = { | ||
| commonKeychain: string; | ||
| counterpartyKeyShare?: ExternalSignerKeyShare; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: optional in the type but required when source is 'user'. no type-level indication of when it's required vs. omittable. |
||
| }; | ||
|
|
||
| export type EddsaKeyGenFinalizeCallback = (params: { | ||
| source: 'user' | 'backup'; | ||
| coin: string; | ||
| bitgoKeychain: Keychain; | ||
| counterPartyGPGKey: string; | ||
| counterPartyKeyShare: ExternalSignerKeyShare; | ||
| state: ExternalSignerMpcState; | ||
| }) => Promise<EddsaKeyGenFinalizeResult>; | ||
|
|
||
| export interface EddsaKeyGenCallbacks { | ||
| initializeCallback: EddsaKeyGenInitializeCallback; | ||
| finalizeCallback: EddsaKeyGenFinalizeCallback; | ||
| } | ||
|
|
||
| export interface GenerateWalletOptions { | ||
| label?: string; | ||
| passphrase?: string; | ||
|
|
@@ -115,9 +216,11 @@ export interface GenerateWalletOptions { | |
| export interface GenerateWalletWithExternalSignerOptions | ||
| extends Omit<GenerateWalletOptions, 'passphrase' | 'userKey' | 'backupXpub' | 'backupXpubProvider'> { | ||
| label: string; | ||
| createKeychainCallback: CreateKeychainCallback; | ||
| createKeychainCallback?: CreateKeychainCallback; | ||
| /** Optional user-key signatures over backup/bitgo pubs. Omit when the external signer cannot produce them (equivalent to a cold wallet). */ | ||
| keySignatures?: { backup: string; bitgo: string }; | ||
| ecdsaMPCv2Callbacks?: EcdsaMPCv2KeyGenCallbacks; | ||
| eddsaCallbacks?: EddsaKeyGenCallbacks; | ||
| } | ||
|
|
||
| export const GenerateLightningWalletOptionsCodec = t.intersection( | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: reads as 'backup's counterparty share' rather than 'the share backup provides to user.'
backupToUserCounterPartyKeySharewould clarify direction.