Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在使用用户的元掩码公共地址加密文件后上传文件,然后用户应该能够使用他的元掩码私钥对其进行解密。如何实现此功能?
Metamask 将允许您使用私钥对数据进行签名,但签名与加密不同。主要是因为没有办法解密。
而且你肯定无法从 Metamask 获得私钥。
您可以做的最好的事情是使用元掩码来签署用户的地址。然后您可以将其用作加密密钥。
const address = web3.eth.accounts[0]; const encryptionKey = web3.eth.personal_sign(address, address);