Skip to content

Commit dd33d5b

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 462c755 commit dd33d5b

9 files changed

Lines changed: 27 additions & 34 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;
@@ -197,7 +198,7 @@ export interface CreateMpcOptions {
197198
originalPasscodeEncryptionCode?: string;
198199
enterprise?: string;
199200
retrofit?: DecryptedRetrofitPayload;
200-
webauthnInfo?: MpcWebauthnInfo;
201+
webauthnInfo?: GenerateWalletWebauthnInfo;
201202
encryptionVersion?: EncryptionVersion;
202203
}
203204

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';
@@ -216,7 +216,7 @@ export default class BaseTssUtils<KeyShare> extends MpcUtils implements ITssUtil
216216
enterprise?: string | undefined;
217217
originalPasscodeEncryptionCode?: string | undefined;
218218
isThirdPartyBackup?: boolean;
219-
webauthnInfo?: MpcWebauthnInfo;
219+
webauthnInfo?: GenerateWalletWebauthnInfo;
220220
encryptionVersion?: EncryptionVersion;
221221
}): Promise<KeychainsTriplet> {
222222
throw new Error('Method not implemented.');

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 { EncryptionVersion, IEncryptionSession, 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
encryptionVersion?: EncryptionVersion;
487487
encryptionSession?: IEncryptionSession;
488488
};

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
@@ -21,7 +21,7 @@ import {
2121
} from '@bitgo/public-types';
2222

2323
import { Ecdsa } from '../../../../account-lib';
24-
import { AddKeychainOptions, Keychain, KeyType, MpcWebauthnInfo } from '../../../keychain';
24+
import { AddKeychainOptions, Keychain, KeyType, GenerateWalletWebauthnInfo } from '../../../keychain';
2525
import { DecryptedRetrofitPayload } from '../../../keychain/iKeychains';
2626
import { ECDSAMethodTypes, getTxRequest } from '../../../tss';
2727
import { sendSignatureShareV2, sendTxRequest } from '../../../tss/common';
@@ -63,7 +63,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
6363
enterprise: string;
6464
originalPasscodeEncryptionCode?: string;
6565
retrofit?: DecryptedRetrofitPayload;
66-
webauthnInfo?: MpcWebauthnInfo;
66+
webauthnInfo?: GenerateWalletWebauthnInfo;
6767
encryptionVersion?: EncryptionVersion;
6868
}): Promise<KeychainsTriplet> {
6969
const { userSession, backupSession } = this.getUserAndBackupSession(2, 3, params.retrofit);
@@ -368,7 +368,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
368368
reducedPrivateMaterial?: Buffer,
369369
passphrase?: string,
370370
originalPasscodeEncryptionCode?: string,
371-
webauthnInfo?: MpcWebauthnInfo,
371+
webauthnInfo?: GenerateWalletWebauthnInfo,
372372
encryptionSession?: {
373373
encrypt(plaintext: string): Promise<string>;
374374
decrypt(ciphertext: string): Promise<string>;
@@ -558,7 +558,7 @@ export class EcdsaMPCv2Utils extends BaseEcdsaUtils {
558558
reducedPrivateMaterial: Buffer,
559559
passphrase: string,
560560
originalPasscodeEncryptionCode?: string,
561-
webauthnInfo?: MpcWebauthnInfo,
561+
webauthnInfo?: GenerateWalletWebauthnInfo,
562562
encryptionSession?: {
563563
encrypt(plaintext: string): Promise<string>;
564564
decrypt(ciphertext: string): Promise<string>;

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 {
@@ -368,7 +368,7 @@ export class EddsaUtils extends baseTSSUtils<KeyShare> {
368368
passphrase?: string;
369369
enterprise?: string;
370370
originalPasscodeEncryptionCode?: string;
371-
webauthnInfo?: MpcWebauthnInfo;
371+
webauthnInfo?: GenerateWalletWebauthnInfo;
372372
encryptionVersion?: EncryptionVersion;
373373
}): Promise<KeychainsTriplet> {
374374
const MPC = await Eddsa.initialize();

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 });
@@ -182,7 +182,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
182182
reducedPrivateMaterial?: Buffer,
183183
passphrase?: string,
184184
originalPasscodeEncryptionCode?: string,
185-
webauthnInfo?: MpcWebauthnInfo
185+
webauthnInfo?: GenerateWalletWebauthnInfo
186186
): Promise<Keychain> {
187187
let source: string;
188188
let encryptedPrv: string | undefined = undefined;
@@ -251,7 +251,7 @@ export class EddsaMPCv2Utils extends BaseEddsaUtils {
251251
reducedPrivateMaterial: Buffer,
252252
passphrase: string,
253253
originalPasscodeEncryptionCode?: string,
254-
webauthnInfo?: MpcWebauthnInfo
254+
webauthnInfo?: GenerateWalletWebauthnInfo
255255
): Promise<Keychain> {
256256
return this.createParticipantKeychain(
257257
MPCv2PartiesEnum.USER,

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as t from 'io-ts';
22

33
import { EncryptionVersion, IRequestTracer } from '../../api';
44
import { KeychainsTriplet, LightningKeychainsTriplet } from '../baseCoin';
5-
import { Keychain, WebauthnInfo } from '../keychain';
5+
import { GenerateWalletWebauthnInfo, Keychain, WebauthnInfo } from '../keychain';
66
import { IWallet, PaginationOptions, WalletShare } from './iWallet';
77
import { Wallet } from './wallet';
88

@@ -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;
@@ -54,16 +56,6 @@ export interface GenerateSMCMpcWalletOptions extends GenerateBaseMpcWalletOption
5456
coldDerivationSeed?: string;
5557
}
5658

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

0 commit comments

Comments
 (0)