我想使用元掩码公共加密密钥解密消息并使用 eth_decrypt 进行解密

问题描述 投票:0回答:0

这是我如何使用公钥加密消息,后者应该使用“eth_decrypt”方法解密该消息

  const handleDec = async () => {
    const decMessage = await window.ethereum.request({
      method: 'eth_decrypt',
      params: [encryptedMessage, address]
    })

    console.log('decMessage', decMessage)
  }
  const handleKey = async () => {
    const publicKey = await window.ethereum.request({
      method: 'eth_getEncryptionPublicKey',
      params: [address]
    })
    console.log('publicKey', publicKey)
  }
  const handleEnc = async () => {
    const publicKey = 'from previous function'

    const encMessage = **????**

    console.log(encMessage)
  }

我正在开发以太坊区块链上的一个项目,我需要实现一种安全方法来使用收件人的公钥对消息进行加密,然后使用“eth_decrypt”方法对其进行解密。我想知道我们如何加密消息。

有人可以指导我如何在以太坊智能合约中实现这个加密和解密过程吗?具体来说,我想知道:

reactjs encryption blockchain cryptojs metamask
© www.soinside.com 2019 - 2024. All rights reserved.