genKeyPair(); // 键值对 $priv = $pair->getPrivate('hex'); // 导出私钥 $pub = $pair->getPublic(false, 'hex'); // 导出公钥 $pub = substr($pub, 2); // 移除开头的04 $address = Keccak::hash(hex2bin($pub), 256); // 先转换为二进制, 再hash $address = Utils::fixHex(substr($address, -40)); // hash之后, 取后40位, 开头填充0x return ['key' => $priv, 'address' => $address]; } }