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

20 lines
501 B
JavaScript
Raw Normal View History

2022-04-21 23:05:56 -04: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}`)
}
}