In development document, PCR API, Metamask provided an encrypting example:
const ethUtil = require('ethereumjs-util');
const encryptedMessage = ethUtil.bufferToHex(
Buffer.from(
JSON.stringify(
sigUtil.encrypt(
encryptionPublicKey,
{ data: 'Hello world!' },
'x25519-xsalsa20-poly1305'
)
),
'utf8'
)
);
But I don’t know what is sigUtil? It isn’t in ‘ethereumjs-util’. I can’t find this package in npm and the eth-sig-util package can’t be used in brower. So how can I use the encrypt function of Metamask in brower.