GithubHelp home page GithubHelp logo

digitaldonkey / ecverify Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 13.0 11 KB

PHP based Ethereum web3 personal recover

Home Page: https://github.com/digitaldonkey/ethereum-php

License: MIT License

PHP 100.00%
ecrecover ecverify ethereum personal-ecrecover php web3

ecverify's Issues

Error when platform has bcmath but not gmp extension

@digitaldonkey digitaldonkey

If I run the sample code in Readme.md it causes the following error if the server/platform running the code does not have the php-gmp extension installed, but does have php-bcmath installed.

The dependency simplito/elliptic-php requires either gmp or bcmath to be installed as you can see in BigInteger.php.

First it tries to do the operation using gmp but if gmp is not installed it uses bcmath as a fallback.

This problem can be fixed (within this repo) by removing the '0x' that is prefixed to the $message_hash in EcRecover.php on line 20.

So this line

$message_hash =  '0x' . Keccak::hash(self::personalSignAddHeader($message), 256);

changes to this

$message_hash = Keccak::hash(self::personalSignAddHeader($message), 256);

Once that change has been implemented the sample code in Readme.md runs fine using both the gmp and bcmath methods.

I'm not sure if the proper solution here is for this repo to be modified as described above or if simplito/elliptic-php should somehow be modified instead. However if you look at the the README.md for simplito/elliptic-php under "Verifying Ethereum Signature" you can see that the example does not prefix the hash with '0x'.

For reference here is the exact code I am running that causes an error. This is the same code from Readme.md, just with a couple typo fixes.

        use Ethereum\EcRecover;

        $address = '0xbe93f9bacbcffc8ee6663f2647917ed7a20a57bb';
        $message = 'hello world';
        $signature = '0xce909e8ea6851bc36c007a0072d0524b07a3ff8d4e623aca4c71ca8e57250c4d0a3fc38fa8fbaaa81ead4b9f6bd03356b6f8bf18bccad167d78891636e1d69561b';
        
        // Verify known address
        $valid = EcRecover::personalVerifyEcRecover($message,  $signature,  $address);
        
        // Recover unknown address
        $recoveredAddress = EcRecover::personalEcRecover($message, $signature);
        if ($recoveredAddress === $address) {
          echo 'Jay! it was a long way here. ';
        }

This is the error I am getting:

Exception
Invalid characters
vendor/simplito/bigint-wrapper-php/lib/BigInteger.php:328

unable to verify

Hi All,

i have {
"message": {
"domain": "localhost:3000",
"address": "0x5F901aF6E1Bc15889c11aBe2C1c03B31544FBc98",
"statement": "hello world",
"uri": "http://localhost:3000",
"version": "1",
"chainId": 56,
"nonce": "3407d937dc17082a457a",
"issuedAt": "2022-12-28T23:10:14.286Z"
},
"signature": "0x3017e592092433ae903eb9eda9e62afc333403555b93b8fe063e8d56d374fc106fc186d4fc856c35423c37ff4befc5851984585600b868230698379e1df434931c",
}

SIWE::verifyAddress($a->statement, $json->signature) after multiple attempts the address still shows -> 0x26fea7722af194204c33502ae483c4af2add5ec2, 0x7f9cc389193346ace2b25f6436b1d6d47e465f6a, 0x204235a7552cb6994f7533015eeb3f9a3944c723.

random addresses like that, i want it to recover 0x5F901aF6E1Bc15889c11aBe2C1c03B31544FBc98

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.