diff --git a/packages/core/src/secret/index.ts b/packages/core/src/secret/index.ts index d1fb32b9a32..39417e04a58 100644 --- a/packages/core/src/secret/index.ts +++ b/packages/core/src/secret/index.ts @@ -13,9 +13,7 @@ import { import { ed25519, nistp256, secp256k1 } from './curves'; import { decrypt, - encrypt, encryptAsync, - encryptString, encryptStringAsync, ensureSensitiveTextEncoded, } from './encryptors/aes256'; diff --git a/packages/kit-bg/src/migrations/v4ToV5Migration/v4local/V4LocalDbBase.ts b/packages/kit-bg/src/migrations/v4ToV5Migration/v4local/V4LocalDbBase.ts index bf3e05593bc..0519f2015d3 100644 --- a/packages/kit-bg/src/migrations/v4ToV5Migration/v4local/V4LocalDbBase.ts +++ b/packages/kit-bg/src/migrations/v4ToV5Migration/v4local/V4LocalDbBase.ts @@ -1,7 +1,7 @@ import { decrypt, decryptVerifyString, - encrypt, + encryptAsync, encryptVerifyString, ensureSensitiveTextEncoded, } from '@onekeyhq/core/src/secret'; @@ -184,7 +184,7 @@ export abstract class V4LocalDbBase extends V4LocalDbBaseContainer { tx, recordPairs: credentialsRecordPairs, name: EV4LocalDBStoreNames.Credential, - updater: (credential) => { + updater: async (credential) => { // imported credential if (credential.id.startsWith('imported')) { const importedCredential: IV4DBImportedCredentialRaw = JSON.parse( @@ -196,7 +196,10 @@ export abstract class V4LocalDbBase extends V4LocalDbBaseContainer { ); const importedCredentialRebuild: IV4DBImportedCredentialRaw = { privateKey: bufferUtils.bytesToHex( - encrypt(newPassword, privateKeyDecrypt), + await encryptAsync({ + password: newPassword, + data: privateKeyDecrypt, + }), ), }; @@ -211,9 +214,14 @@ export abstract class V4LocalDbBase extends V4LocalDbBaseContainer { const entropyDecrypt = decrypt(oldPassword, hdCredential.entropy); const hdCredentialRebuild: IV4DBHdCredentialRaw = { - seed: bufferUtils.bytesToHex(encrypt(newPassword, seedDecrypt)), + seed: bufferUtils.bytesToHex( + await encryptAsync({ password: newPassword, data: seedDecrypt }), + ), entropy: bufferUtils.bytesToHex( - encrypt(newPassword, entropyDecrypt), + await encryptAsync({ + password: newPassword, + data: entropyDecrypt, + }), ), };