Skip to content

Commit e9c8790

Browse files
refactor(sdk-core): consolidate WebAuthn passphrase type
MpcWebauthnInfo and GenerateWalletWebauthnInfo were identical shapes. Promote GenerateWalletWebauthnInfo to iKeychains.ts as the single canonical type, re-export it from iWallets.ts, and drop the duplicate definition. All createKeychains implementations and CreateMpcOptions now reference the shared type. The onchain hot wallet path in generateWallet already wires webauthnInfo through userKeychainPromise; no additional changes are needed there. Ticket: WAL-761
1 parent 4eae3e5 commit e9c8790

9 files changed

Lines changed: 26 additions & 33 deletions

File tree

modules/sdk-core/src/bitgo/keychain/iKeychains.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ export interface WebauthnInfo {
1212
encryptedPrv: string;
1313
}
1414

15-
/** WebAuthn PRF-based encryption info passed to MPC key creation. The passphrase is the
16-
* PRF-derived key used to encrypt the user private share before it is persisted. */
17-
export interface MpcWebauthnInfo {
15+
/** WebAuthn PRF-based encryption info for protecting the user private key with a hardware
16+
* authenticator. The passphrase is the PRF-derived key used to encrypt the user private
17+
* key/share before it is persisted. Never sent to the server. */
18+
export interface GenerateWalletWebauthnInfo {
1819
otpDeviceId: string;
1920
prfSalt: string;
2021
passphrase: string;
@@ -196,7 +197,7 @@ export interface CreateMpcOptions {
196197
originalPasscodeEncryptionCode?: string;
197198
enterprise?: string;
198199
retrofit?: DecryptedRetrofitPayload;
199-
webauthnInfo?: MpcWebauthnInfo;
200+
webauthnInfo?: GenerateWalletWebauthnInfo;
200201
}
201202

202203
export interface RecreateMpcOptions extends Omit<CreateMpcOptions, 'retrofit' | 'multisigType'> {

modules/sdk-core/src/bitgo/utils/mpcUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import assert from 'assert';
55
import { decrypt, readMessage, readPrivateKey, SerializedKeyPair } from 'openpgp';
66
import { IBaseCoin, KeychainsTriplet } from '../baseCoin';
77
import { BitGoBase } from '../bitgoBase';
8-
import { AddKeychainOptions, Keychain, KeyType, MpcWebauthnInfo } from '../keychain';
8+
import { AddKeychainOptions, Keychain, KeyType, GenerateWalletWebauthnInfo } from '../keychain';
99
import { encryptText, getBitgoGpgPubKey } from './opengpgUtils';
1010
import {
1111
IntentRecipient,
@@ -105,7 +105,7 @@ export abstract class MpcUtils {
105105
passphrase: string;
106106
enterprise?: string;
107107
originalPasscodeEncryptionCode?: string;
108-
webauthnInfo?: MpcWebauthnInfo;
108+
webauthnInfo?: GenerateWalletWebauthnInfo;
109109
}): Promise<KeychainsTriplet>;
110110

111111
/**

modules/sdk-core/src/bitgo/utils/tss/baseTSSUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as openpgp from 'openpgp';
33
import { Key, readKey, SerializedKeyPair } from 'openpgp';
44
import { IBaseCoin, KeychainsTriplet } from '../../baseCoin';
55
import { BitGoBase } from '../../bitgoBase';
6-
import { Keychain, KeyIndices, MpcWebauthnInfo } from '../../keychain';
6+
import { Keychain, KeyIndices, GenerateWalletWebauthnInfo } from '../../keychain';
77
import { getTxRequest } from '../../tss';
88
import { IWallet } from '../../wallet';
99
import { MpcUtils } from '../mpcUtils';
@@ -194,7 +194,7 @@ export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtil
194194
enterprise?: string | undefined;
195195
originalPasscodeEncryptionCode?: string | undefined;
196196
isThirdPartyBackup?: boolean;
197-
webauthnInfo?: MpcWebauthnInfo;
197+
webauthnInfo?: GenerateWalletWebauthnInfo;
198198
}): Promise<KeychainsTriplet> {
199199
throw new Error('Method not implemented.');
200200
}

modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Key, SerializedKeyPair } from 'openpgp';
22
import { IRequestTracer } from '../../../api';
33
import { KeychainsTriplet, ParsedTransaction, TransactionParams } from '../../baseCoin';
4-
import { ApiKeyShare, Keychain, MpcWebauthnInfo } from '../../keychain';
4+
import { ApiKeyShare, Keychain, GenerateWalletWebauthnInfo } from '../../keychain';
55
import { ApiVersion, Memo, WalletType } from '../../wallet';
66
import { EDDSA, GShare, Signature, SignShare } from '../../../account-lib/mpc/tss';
77
import { Signature as EcdsaSignature } from '../../../account-lib/mpc/tss/ecdsa/types';
@@ -482,7 +482,7 @@ export type CreateKeychainParamsBase = {
482482
passphrase?: string;
483483
enterprise?: string;
484484
originalPasscodeEncryptionCode?: string;
485-
webauthnInfo?: MpcWebauthnInfo;
485+
webauthnInfo?: GenerateWalletWebauthnInfo;
486486
};
487487

488488
export type CreateBitGoKeychainParamsBase = Omit<CreateKeychainParamsBase, 'bitgoKeychain'>;

modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsa.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { EcdsaPaillierProof, EcdsaRangeProof, EcdsaTypes, hexToBigInt, minModulu
77
import { bip32 } from '@bitgo/utxo-lib';
88

99
import { ECDSA, Ecdsa } from '../../../../account-lib/mpc/tss';
10-
import { AddKeychainOptions, Keychain, KeyType, MpcWebauthnInfo } from '../../../keychain';
10+
import { AddKeychainOptions, Keychain, KeyType, GenerateWalletWebauthnInfo } from '../../../keychain';
1111
import ECDSAMethods, { ECDSAMethodTypes } from '../../../tss/ecdsa';
1212
import { KeychainsTriplet } from '../../../baseCoin';
1313
import {
@@ -106,7 +106,7 @@ export class EcdsaUtils extends BaseEcdsaUtils {
106106
passphrase: string;
107107
enterprise?: string | undefined;
108108
originalPasscodeEncryptionCode?: string | undefined;
109-
webauthnInfo?: MpcWebauthnInfo;
109+
webauthnInfo?: GenerateWalletWebauthnInfo;
110110
}): Promise<KeychainsTriplet> {
111111
const MPC = new Ecdsa();
112112
const m = 2;
@@ -309,7 +309,7 @@ export class EcdsaUtils extends BaseEcdsaUtils {
309309
bitgoKeychain: Keychain,
310310
passphrase: string,
311311
originalPasscodeEncryptionCode?: string,
312-
webauthnInfo?: MpcWebauthnInfo
312+
webauthnInfo?: GenerateWalletWebauthnInfo
313313
): Promise<Keychain> {
314314
const bitgoKeyShares = bitgoKeychain.keyShares;
315315
if (!bitgoKeyShares) {

modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from '@bitgo/public-types';
2121

2222
import { Ecdsa } from '../../../../account-lib';
23-
import { AddKeychainOptions, Keychain, KeyType, MpcWebauthnInfo } from '../../../keychain';
23+
import { AddKeychainOptions, Keychain, KeyType, GenerateWalletWebauthnInfo } from '../../../keychain';
2424
import { DecryptedRetrofitPayload } from '../../../keychain/iKeychains';
2525
import { ECDSAMethodTypes, getTxRequest } from '../../../tss';
2626
import { sendSignatureShareV2, sendTxRequest } from '../../../tss/common';
@@ -57,7 +57,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
5757
enterprise: string;
5858
originalPasscodeEncryptionCode?: string;
5959
retrofit?: DecryptedRetrofitPayload;
60-
webauthnInfo?: MpcWebauthnInfo;
60+
webauthnInfo?: GenerateWalletWebauthnInfo;
6161
}): Promise<KeychainsTriplet> {
6262
const { userSession, backupSession } = this.getUserAndBackupSession(2, 3, params.retrofit);
6363
const userGpgKey = await generateGPGKeyPair('secp256k1');
@@ -353,7 +353,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
353353
reducedPrivateMaterial?: Buffer,
354354
passphrase?: string,
355355
originalPasscodeEncryptionCode?: string,
356-
webauthnInfo?: MpcWebauthnInfo
356+
webauthnInfo?: GenerateWalletWebauthnInfo
357357
): Promise<Keychain> {
358358
let source: string;
359359
let encryptedPrv: string | undefined = undefined;
@@ -531,7 +531,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
531531
reducedPrivateMaterial: Buffer,
532532
passphrase: string,
533533
originalPasscodeEncryptionCode?: string,
534-
webauthnInfo?: MpcWebauthnInfo
534+
webauthnInfo?: GenerateWalletWebauthnInfo
535535
): Promise<Keychain> {
536536
return this.createParticipantKeychain(
537537
MPCv2PartiesEnum.USER,

modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsa.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import assert from 'assert';
55
import * as openpgp from 'openpgp';
66
import Eddsa, { GShare, SignShare } from '../../../../account-lib/mpc/tss';
7-
import { AddKeychainOptions, CreateBackupOptions, Keychain, MpcWebauthnInfo } from '../../../keychain';
7+
import { AddKeychainOptions, CreateBackupOptions, Keychain, GenerateWalletWebauthnInfo } from '../../../keychain';
88
import { verifyWalletSignature } from '../../../tss/eddsa/eddsa';
99
import { createShareProof, encryptText, generateGPGKeyPair, getBitgoGpgPubKey } from '../../opengpgUtils';
1010
import {
@@ -357,7 +357,7 @@ export class EddsaUtils extends baseTSSUtils<KeyShare> {
357357
passphrase?: string;
358358
enterprise?: string;
359359
originalPasscodeEncryptionCode?: string;
360-
webauthnInfo?: MpcWebauthnInfo;
360+
webauthnInfo?: GenerateWalletWebauthnInfo;
361361
}): Promise<KeychainsTriplet> {
362362
const MPC = await Eddsa.initialize();
363363
const m = 2;

modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@bitgo/public-types';
1212
import { EddsaMPSDkg, MPSComms, MPSTypes } from '@bitgo/sdk-lib-mpc';
1313
import { KeychainsTriplet } from '../../../baseCoin';
14-
import { AddKeychainOptions, Keychain, KeyType, MpcWebauthnInfo } from '../../../keychain';
14+
import { AddKeychainOptions, Keychain, KeyType, GenerateWalletWebauthnInfo } from '../../../keychain';
1515
import { envRequiresBitgoPubGpgKeyConfig, isBitgoEddsaMpcv2PubKey } from '../../../tss/bitgoPubKeys';
1616
import { generateGPGKeyPair } from '../../opengpgUtils';
1717
import { MPCv2PartiesEnum } from '../ecdsa/typesMPCv2';
@@ -24,7 +24,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
2424
passphrase: string;
2525
enterprise: string;
2626
originalPasscodeEncryptionCode?: string;
27-
webauthnInfo?: MpcWebauthnInfo;
27+
webauthnInfo?: GenerateWalletWebauthnInfo;
2828
}): Promise<KeychainsTriplet> {
2929
const userKeyPair = await generateGPGKeyPair('ed25519');
3030
const userGpgKey = await pgp.readPrivateKey({ armoredKey: userKeyPair.privateKey });
@@ -174,7 +174,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
174174
reducedPrivateMaterial?: Buffer,
175175
passphrase?: string,
176176
originalPasscodeEncryptionCode?: string,
177-
webauthnInfo?: MpcWebauthnInfo
177+
webauthnInfo?: GenerateWalletWebauthnInfo
178178
): Promise<Keychain> {
179179
let source: string;
180180
let encryptedPrv: string | undefined = undefined;
@@ -243,7 +243,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
243243
reducedPrivateMaterial: Buffer,
244244
passphrase: string,
245245
originalPasscodeEncryptionCode?: string,
246-
webauthnInfo?: MpcWebauthnInfo
246+
webauthnInfo?: GenerateWalletWebauthnInfo
247247
): Promise<Keychain> {
248248
return this.createParticipantKeychain(
249249
MPCv2PartiesEnum.USER,

modules/sdk-core/src/bitgo/wallet/iWallets.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export interface GenerateBaseMpcWalletOptions {
4242
walletVersion?: number;
4343
}
4444

45+
export { GenerateWalletWebauthnInfo } from '../keychain';
46+
4547
export interface GenerateMpcWalletOptions extends GenerateBaseMpcWalletOptions {
4648
passphrase: string;
4749
originalPasscodeEncryptionCode?: string;
@@ -53,16 +55,6 @@ export interface GenerateSMCMpcWalletOptions extends GenerateBaseMpcWalletOption
5355
coldDerivationSeed?: string;
5456
}
5557

56-
/** WebAuthn PRF-based encryption info for protecting the user private key with a hardware authenticator. */
57-
export interface GenerateWalletWebauthnInfo {
58-
/** The OTP device ID of the WebAuthn authenticator. */
59-
otpDeviceId: string;
60-
/** The PRF salt used to derive the passphrase from the authenticator. */
61-
prfSalt: string;
62-
/** PRF-derived passphrase used to encrypt the user private key. Never sent to the server. */
63-
passphrase: string;
64-
}
65-
6658
export interface GenerateWalletOptions {
6759
label?: string;
6860
passphrase?: string;

0 commit comments

Comments
 (0)