17 lines
463 B
JavaScript
17 lines
463 B
JavaScript
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}`)
|
|
}
|
|
}
|