classic-ui/modules/account/store/actions/getEncryptedNote.js
Danil Kovtonyuk 44f31f8b9f
init
2022-04-22 13:14:19 +10:00

20 lines
501 B
JavaScript

import { encrypt } from 'eth-sig-util'
import { packEncryptedMessage } from '@/utils'
export function getEncryptedNote({ getters }, { data }) {
try {
const encryptedPublicKey = getters.encryptedPublicKey
if (!encryptedPublicKey) {
return
}
const encryptedData = encrypt(encryptedPublicKey, { data }, 'x25519-xsalsa20-poly1305')
return packEncryptedMessage(encryptedData)
} catch (err) {
throw new Error(`Method getEncryptedNote has error: ${err.message}`)
}
}