Coder Social home page Coder Social logo

isOnCurve not right about solana-php-sdk HOT 5 CLOSED

verze-app avatar verze-app commented on August 23, 2024
isOnCurve not right

from solana-php-sdk.

Comments (5)

gabrielkoerich avatar gabrielkoerich commented on August 23, 2024 2

I found out here that sodium_crypto_sign_ed25519_pk_to_curve25519($binaryString) is almost always returning a SodiumException with "conversion failed" message.

Using \ParagonIE_Sodium_Compat::crypto_sign_ed25519_pk_to_curve25519($binaryString) I was able to get the correct address

from solana-php-sdk.

pantaovay avatar pantaovay commented on August 23, 2024 1

@neverything

For address q5xfHVuAsGmKRTmJNshERHHkVnHKxRX3cKzz5cYnFRn, it is on curve, the function should return true. Buf it returns false.

I checked #12 , the reason that the function generates false PDA is isOnCurse issue. If isOnCurve function works right, it has no issue.

I use another way to avoid this because the isOnCurve function in the other js lib is very difficult.

    public static function isOnCurve(PublicKey $publicKey): bool
    {
        try {
            $response = Di::getHttpClient()->sendGetRequest(sprintf(
                'http://127.0.0.1:3000/publickey/%s/is_on_curve',
                $publicKey->toBase58()
            ));

            $responseBody = json_decode($response->getBody()->getContents(), true);
            if (!is_array($responseBody) || !isset($responseBody['is_on_curve'])) {
                throw new \Exception($responseBody['error_code']);
            }

            return (bool) $responseBody['is_on_curve'];
        } catch (\Exception $exception) {
            Di::getLogger()->error('Check is on curve error: ' . $exception->getMessage());

            return false;
        }
    }

from solana-php-sdk.

neverything avatar neverything commented on August 23, 2024 1

@gabrielkoerich good catch, this does indeed seem like a bug. Feel free to write a pull request for it or I will eventually get to it in the future as it's bothering me a little 😄

from solana-php-sdk.

neverything avatar neverything commented on August 23, 2024 1

This is fixed in 7b1e6ae thanks to @gabrielkoerich

Not creating a new release yet, see #36

from solana-php-sdk.

neverything avatar neverything commented on August 23, 2024

@pantaovay not sure I'm getting the problem. Does it return trueor false for isOnCurve?

Sidenote, I had an issue with the getProgramAddress and solved it by checking multiple nonce values, see #12 (comment) for details.

from solana-php-sdk.

Related Issues (20)

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.