I'm trying to generate eth address on PHP. Having issue with keccak256.
I'm using this class: https://github.com/kornrunner/php-keccak
It works good, I checked many times on https://emn178.github.io/online-tools/keccak_256.html
Priv/pub keys are generated right, checked many times, but there is something with keccak256, and I get different address from myetherwallet and other tools.
Where is a mistake?
Here is my code:
include('./keccak.php');
use BitWasp\BitcoinLib\BitcoinLib;
require_once(__DIR__. '/vendor/autoload.php');
$priv = '17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55';
echo 'priv key: '.$priv;
echo "\r\n";
$pub=substr(BitcoinLib::private_key_to_public_key($priv),2); // deleting '04' padding from left side
echo 'pub key: '.$pub;
echo "\r\n";
$adr = \nmsps\Keccak::hash($pub, 256);
echo 'keccak256: '.$adr;
echo "\r\n";
echo 'ETH address:'.substr($adr,-40); // last 40
exit;
output:
priv key: 17d08f5fe8c77af811caa0c9a187e668ce3b74a99acc3f6d976f075fa8e0be55
pub key: 689268c0ff57a20cd299fa60d3fb374862aff565b20b5f1767906a99e6e09f3ff04ca2b2a5cd22f62941db103c0356df1a8ed20ce322cab2483db67685afd124
keccak256: c39d3fed9ca154a48cad5238a063d2fa1937d32fec5166ce0a27c6e6f94c95c8
ETH address: a063d2fa1937d32fec5166ce0a27c6e6f94c95c8 // should be 0x26d1eC50B4e62c1d1a40D16E7cacc6A6580757d5