如何用PHP验证以太坊签名的垃圾邮件?
使用Web3.js中的web3.personal.sign函数对消息进行签名,然后将签名发送到服务器。我如何用PHP验证它?
有一些……
使用包可以验证签名的消息 PHP-ecrecover 。
您可以使用此包获取原始邮件地址,然后验证它是否与预期地址相同。
JS标志:
let message = 'Hello World!' let address = web3.eth.coinbase web3.personal.sign(web3.fromUtf8(message), address, console.log);
PHP验证:
$address = '0xe12Aa5FB5659bb0DB3f488e29701fE303bcBAf65'; $message = 'Hello World!'; $signed = '0x2cb6b41177a5e6690ebbc61f182758fcf8f54403edcb848fc1089a772227d55163804b4dc7fcf72d15f0d977d741f6dd6bcc4fc4c74916378afcad06be77b2101b'; if ($address == personal_ecRecover($message, $signed)) { echo 'Message verified'; } else { echo 'Message not verified'; }