public static function pubKeyHashFromKey($prefix, $publicKey)
    {
        $length = strlen($publicKey);
        if ($length === 33) {
            if ($publicKey[0] !== "\x02" && $publicKey[0] !== "\x03") {
                throw new CashAddressException("Invalid public key");
            }
        } else if ($length === 65) {
            if ($publicKey[0] !== "\x04") {
                throw new CashAddressException("Invalid public key");
            }
        } else {
            throw new CashAddressException("Invalid public key");
        }

        return self::pubKeyHash($prefix, hash('ripemd160', hash('sha256', $publicKey, true), true));
    }