1. Go to this page and download the library: Download amashukov/secp256k1-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amashukov / secp256k1-php example snippets
use Amashukov\Secp256k1\Secp256k1;
$p = Secp256k1::p(); // curve modulus
$n = Secp256k1::n(); // curve order
$G = Secp256k1::g(); // generator point ['x' => GMP, 'y' => GMP]
// Public key from a 32-byte private key.
$priv = hex2bin('c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4');
$d = gmp_import($priv);
$pub = Secp256k1::scalarMul($G, $d, $p); // ['x' => GMP, 'y' => GMP]
// Given a (v, r, s) signature triple from an EVM wallet:
$pubKey = Ecdsa::recover($msgHash, $signature['v'], $signature['r'], $signature['s']);
// → 65 raw bytes uncompressed (`04 || x || y`), or null on failure
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.