0

I try to implement Web3 login to my page. It works with MetaMask, but with other wallets (like LRC, Coinbase or Argent) it doesn't - recovered address differs from the original one.

Ethereum\EcRecover package does all the crypto work here.

<?php
require 'vendor/autoload.php';
use Ethereum\EcRecover;

$message = "Sign this message to validate that \nyou are the owner of the account. \n\nRandom string: 624ed7b003d9d";
$signature = '0x5bd34199cfcf1c4f374bd983a2c0a50ae76ea9cc41df2d70ec306a671352d42d45a819b1fd28090aa1ddd895d6f4ecbdd9715d4f31ae0b410ff00d12e2c34f5a1b';
$address = '0x1a44ba4b1C7bd22b896B76d4776dB3f6C541fb60'; // Safe address from test wallet

$recoveredAddress = EcRecover::personalEcRecover($message, $signature);

if ($recoveredAddress === $address) {
    echo "Verified\n";
} else {
    echo "Recovered address differs from the original one\n";
    echo "Original address:  $address\n";
    echo "Recovered address: $recoveredAddress\n";
}

1 Answer 1

0

EcRecover::personalVerifyEcRecover will always return a wallet address in lower case. You are comparing a lower cased wallet address and a mix cased wallet address.

Your comparison should look like this if ($recoveredAddress === strtolower($address))

The reason why it's working with metamask is because metamask returns a lower cased wallet address while other wallet may return a mix cased wallet address hence failing your comparison.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.