@@ -175,7 +175,10 @@ export class Vault {
175175 await midenClient . webClient . addAccountSecretKeyToWebStore ( sk ) ;
176176 } else {
177177 const walletSeed = deriveClientSeed ( walletAccount . type , mnemonic , walletAccount . hdIndex ) ;
178- const secretKey = SecretKey . rpoFalconWithRNG ( walletSeed ) ;
178+ const secretKey =
179+ walletAccount . authScheme === AuthScheme . Falcon
180+ ? SecretKey . rpoFalconWithRNG ( walletSeed )
181+ : SecretKey . ecdsaWithRNG ( walletSeed ) ;
179182 await midenClient . webClient . addAccountSecretKeyToWebStore ( secretKey ) ;
180183 }
181184 }
@@ -380,7 +383,11 @@ export class Vault {
380383 async importAccount ( privateKey : string , name ?: string ) : Promise < WalletAccount [ ] > {
381384 return withError ( 'Failed to import account' , async ( ) => {
382385 const allAccounts = await fetchAndDecryptOneWithLegacyFallBack < WalletAccount [ ] > ( accountsStrgKey , this . passKey ) ;
383- const secretKey = SecretKey . deserialize ( new Uint8Array ( Buffer . from ( privateKey , 'hex' ) ) ) ;
386+ const buff = Buffer . from ( privateKey , 'hex' ) ;
387+ if ( buff [ 0 ] !== 0 && buff [ 0 ] !== 1 ) {
388+ throw new PublicError ( 'Invalid private key format' ) ;
389+ }
390+ const secretKey = SecretKey . deserialize ( new Uint8Array ( buff ) ) ;
384391 const pubKeyWord = secretKey . publicKey ( ) . toCommitment ( ) ;
385392
386393 const pubKeyHex = pubKeyWord . toHex ( ) . slice ( 2 ) ; // remove '0x' prefix
@@ -393,6 +400,7 @@ export class Vault {
393400 name : name || `Imported Account ${ allAccounts . length + 1 } ` ,
394401 isPublic : true ,
395402 type : WalletType . OnChain ,
403+ authScheme : buff [ 0 ] === 0 ? AuthScheme . Falcon : AuthScheme . ECDSA ,
396404 hdIndex : - 1 // -1 indicates imported account
397405 } ;
398406
0 commit comments