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

20 lines
501 B
JavaScript
Raw Permalink Normal View History

2022-04-22 06:05:56 +03:00
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}`)
}
}