private function decodeBase58($base58)
    {
        $origbase58  = $base58;
        $base58chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
        $return      = '0';
        for ($i = 0; $i < strlen($base58); $i++) {
            $current = (string)strpos($base58chars, $base58[$i]);
            $return  = (string)bcmul($return, "58", 0);
            $return  = (string)bcadd($return, $current, 0);
        }
        $return = $this->encodeHex($return);
        //leading zeros
        for ($i = 0; $i < strlen($origbase58) && $origbase58[$i] == '1'; $i++) {
            $return = '00' . $return;
        }
        if (strlen($return) % 2 != 0) {
            $return = '0' . $return;
        }

        return $return;
    }