简体   繁体   English

如何在 web3.js 中隐藏私钥

[英]How to hide private key in web3.js

I want to send signTransaction using web3, the problem is that for doing that, I need to use the privateKey of my Metamask account.我想使用 web3 发送 signTransaction,问题是为此,我需要使用我的 Metamask 帐户的 privateKey。 Anyone could see the "privatekey" from explorer.任何人都可以从资源管理器中看到“私钥”。

So how can I hide this variable in javascript for using it safety?那么如何在javascript中隐藏这个变量以安全使用它呢? The line of code in javascript in frontend is the following:前端javascript中的代码行如下:

web3.eth.accounts.signTransaction(rawTransaction, privateKey)

I would like to store the privatekey in backend and make a call to backend to obtain it, how should I do it in a safe way?我想将私钥存储在后端并调用后端获取它,我应该如何以安全的方式进行操作?

You are using blockchain wrong.你用错了区块链。

Make users to sign the transaction with their own private key.让用户用自己的私钥签署交易。 Furthermore MetaMask never exposes the private key in the browser in the first place.此外,MetaMask 从一开始就不会在浏览器中公开私钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM