简体   繁体   English

Elrond 在后端 PHP 上验证签名

[英]Elrond Verify Signature on Backend PHP

I have a dApp where you login with your Elrond wallet and you generate a signature (containing the wallet address and some more data).我有一个 dApp,您可以在其中使用 Elrond 钱包登录并生成签名(包含钱包地址和更多数据)。

While making requests to an endpoint, I pass the signature on payload and I need to verify it on the backend (so you can't change the wallet address and make requests on someone else's behalf).在向端点发出请求时,我在有效负载上传递签名,我需要在后端验证它(因此您不能更改钱包地址并代表其他人发出请求)。

I am using PHP with Laravel Framework.我正在使用带有 Laravel 框架的 PHP。

How can I verify the signature on the backend and get the wallet address?如何在后端验证签名并获取钱包地址?

i've written a Laravel SDK for Elrond that can help you with that, or you can copy the logic from: https://github.com/Superciety/elrond-sdk-laravel我已经为 Elrond 编写了一个 Laravel SDK 可以帮助您,或者您可以从以下位置复制逻辑: https ://github.com/Superciety/elrond-sdk-laravel

note: it's still work in progress & mostly undocumented - i'd welcome any contributions注意:它仍在进行中并且大部分没有记录 - 我欢迎任何贡献

to verify signatures coming from your dapp, you'd use it this way:要验证来自您的 dapp 的签名,您可以这样使用它:

$isValid = Elrond::crypto()->verifyLogin($token, $signature, $address);

where $token is an arbitrary string unique to the user's session to avoid replay其中 $token 是用户会话唯一的任意字符串,以避免重播

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

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