Skip to content

Commit

Permalink
fix: v4 db
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon committed Dec 25, 2024
1 parent 4419142 commit 6f91271
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions packages/core/src/secret/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import {
import { ed25519, nistp256, secp256k1 } from './curves';
import {
decrypt,
encrypt,
encryptAsync,
encryptString,
encryptStringAsync,
ensureSensitiveTextEncoded,
} from './encryptors/aes256';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
decrypt,
decryptVerifyString,
encrypt,
encryptAsync,
encryptVerifyString,
ensureSensitiveTextEncoded,
} from '@onekeyhq/core/src/secret';
Expand Down Expand Up @@ -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(
Expand All @@ -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,
}),
),
};

Expand All @@ -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,
}),
),
};

Expand Down

0 comments on commit 6f91271

Please sign in to comment.