如何从流行的钱包扩展中安全地检索客户端公钥

发布于 2025-01-17 19:39:07 字数 599 浏览 4 评论 0原文

我正在创建一个桌面应用程序,该应用程序需要用户将其加密钱包连接到“登录”。

这是我当前的工作流程:

  1. 创建从桌面应用程序到服务器的套接字连接。
  2. 在我网站上的页面上打开一个浏览器选项卡,将套接字ID作为URL参数,
  3. 页面将促使用户
  4. 在连接成功后连接其钱包,Frontend将API调用到后端,钱包地址和插座ID。
  5. 后端用私钥签署了钱包地址,并使用套接字将地址和签名发送到客户端的桌面应用程序。

问题在于,任何人都可以创建与我的服务器的套接字连接,然后使用他们想要的任何钱包地址和连接的套接字ID在第4步中提出请求。成功地模仿别人的钱包。

使用浏览器钱包扩展程序将桌面应用程序安全地连接到桌面应用程序的任何解决方案?

我正在考虑的解决方案(如果可能的话)是:

使用公开的字符串并将其与用户私有密钥进行加密,并将其发送是步骤4中的请求的一部分。然后,后端可能只是解密带有钱包的公共地址的数据,并确保其等于原始字符串。这样可以验证,发送给服务器的公共钱包地址实际上是用户拥有的。

但是,我认为不可能使用钱包的私钥将钱包扩展名加密数据加密。如果有一种与著名的钱包扩展名相兼容的方法,那将是完美的修复。

I am creating a desktop application which requires the user to connect their crypto wallet to "sign in".

Here is my current workflow:

  1. Create a socket connection from desktop application to my server.
  2. Open a browser tab on the client machine that to page on my website, with the socket ID as a url parameter
  3. The page will prompt the user to connect their wallet
  4. After the connection was successful, the frontend makes an API call to the backend with the wallet address and the socket ID.
  5. The backend signs the wallet address with a private key and sends the address and the signature to the client's desktop application using sockets.

The problem with this is that anyone could create a socket connection to my server and then make the request made in step 4 with whatever wallet address they want and the socket ID of the connection they made. Successfully being able to impersonate someone else's wallet.

Any solutions to securely connect a the desktop app with the crypto wallet using a browser wallet extension?

The solution I am thinking about and would definitely work (if possible) is:

Use a publicly known string and encrypted it with the users private key and send this is a part of the request made in step 4. Then, the backend could just decrypt the data with the public address of the wallet and make sure it is equal to the original string. This way it can be verified that the public wallet address sent to the server is in fact owned by the user.

However, I do not think it is possible to be able to have the wallet extension encrypt data using the private key of the wallet. If there is a way that is compatible with the famous wallet extensions that would the perfect fix.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文