classic-ui/modules/account/store/actions/decryptNote.js

17 lines
463 B
JavaScript
Raw Permalink Normal View History

2022-04-22 13:05:56 +10:00
import { decrypt } from 'eth-sig-util'
import { unpackEncryptedMessage } from '@/utils'
export async function decryptNote({ dispatch }, encryptedNote) {
try {
const recoveryKey = await dispatch('getRecoveryKey')
const unpackedMessage = unpackEncryptedMessage(encryptedNote)
const [, note] = decrypt(unpackedMessage, recoveryKey).split('-')
return note
} catch (err) {
console.warn(`Method decryptNote has error: ${err.message}`)
}
}