@@ -1452,7 +1452,7 @@ export class KeyringController<
14521452 return this . #persistOrRollback( async ( ) => {
14531453 assertIsValidPassword ( password ) ;
14541454 await this . #deriveEncryptionKey( password , {
1455- useVaultKeyMetadata : false ,
1455+ ignoreExistingVault : true ,
14561456 } ) ;
14571457 } ) ;
14581458 }
@@ -1532,7 +1532,7 @@ export class KeyringController<
15321532 // If the vault is being upgraded, we want to ignore the metadata
15331533 // that is already in the vault, so we can effectively
15341534 // re-encrypt the vault with the new encryption config.
1535- useVaultKeyMetadata : false ,
1535+ ignoreExistingVault : true ,
15361536 } ) ;
15371537 await this . #updateVault( ) ;
15381538 }
@@ -1877,7 +1877,9 @@ export class KeyringController<
18771877 delete state . encryptionSalt ;
18781878 } ) ;
18791879
1880- await this . #deriveEncryptionKey( password ) ;
1880+ await this . #deriveEncryptionKey( password , {
1881+ ignoreExistingVault : true ,
1882+ } ) ;
18811883
18821884 await this . #clearKeyrings( ) ;
18831885 await this . #createKeyringWithFirstAccount( keyring . type , keyring . opts ) ;
@@ -1893,14 +1895,18 @@ export class KeyringController<
18931895 * using the salt from the vault. If the vault is empty, a new salt
18941896 * is generated and used to derive the key.
18951897 *
1898+ * If `options.ignoreExistingVault` is set to `false`, the existing
1899+ * vault is completely ignored: the new key won't be able to decrypt
1900+ * the existing vault, and should be used to re-encrypt it.
1901+ *
18961902 * @param password - The password to use for decryption or derivation.
18971903 * @param options - Options for the key derivation.
1898- * @param options.useVaultKeyMetadata - Whether to use the vault key metadata
1904+ * @param options.ignoreExistingVault - Whether to use the existing vault salt and key metadata
18991905 */
19001906 async #deriveEncryptionKey(
19011907 password : string ,
1902- options : { useVaultKeyMetadata : boolean } = {
1903- useVaultKeyMetadata : true ,
1908+ options : { ignoreExistingVault : boolean } = {
1909+ ignoreExistingVault : false ,
19041910 } ,
19051911 ) : Promise < void > {
19061912 this . #assertControllerMutexIsLocked( ) ;
@@ -1911,7 +1917,7 @@ export class KeyringController<
19111917 }
19121918
19131919 let serializedEncryptionKey : string , salt : string ;
1914- if ( vault && options . useVaultKeyMetadata ) {
1920+ if ( vault && ! options . ignoreExistingVault ) {
19151921 // The `decryptWithDetail` method is being used here instead of
19161922 // `keyFromPassword` + `exportKey` to let the encryptor handle
19171923 // any legacy encryption formats and metadata that might be
0 commit comments