How to verify public key is on Ed25519 curve in PHP? (verify Solana address)

Viewed 249

Building a server-side implementation to do Solana verification for a contract, when we receive a Solana address (Ed25519 public key) from client. They only want me to use native PHP methods, no imports, idk why. Open source libraries are still helpful as I can try my best to pull bits and pieces from it. I do have access to all of the libsodium PHP\Sodium library methods here: https://www.php.net/manual/en/book.sodium.php (which I believe allows us to do Ed25519)

This is the implementation in JS: https://solana-labs.github.io/solana-web3.js/classes/PublicKey.html#isOnCurve

I need this in PHP. In other words:

How can I verify Solana addresses (such as AJXw4EJtRBGswEestiD3gztdbsAh8fe3VSJXs6U33UBv) in PHP? As in, how do I verify a public key is on the Ed25519 curve?

Thanks in advance! I don't usually post on StackOverflow but I'm hoping this answer will be useful as Web3 continues to evolve.

1 Answers
Related