public function Verify($sig, $msg, $pubkey)
    {
        if (true === empty($sig) || true === empty($msg) || true === empty($pubkey)) {
            throw new \Exception('The signature, public key and message parameters are required to verify a signature.  Value received for first parameter was "' . var_export($sig, true) . '", second parameter was "' . var_export($msg, true) . '" and third parameter was "' . var_export($pubkey, true) . '".');
        }

        $e         = '';
        $w         = '';
        $u1        = '';
        $u2        = '';
        $Z         = array();

        $coords = $this->parseSig($sig);

        $r = $this->CoordinateCheck($this->prepAndClean($coords['r']));
        $s = $this->CoordinateCheck($this->prepAndClean($coords['s']));

        $r_dec = $this->decodeHex($r);
        $s_dec = $this->decodeHex($s);

        /* Convert the hash of the hex message to decimal */
        $e = $this->decodeHex(hash('sha256', $msg));

        $n_dec  = $this->decodeHex($this->n);

        $pubkey = (substr($pubkey, 0, 2) == '04') ? $this->keyUtil->parseUncompressedPublicKey($pubkey) : $this->keyUtil->parseCompressedPublicKey($pubkey);

        /* Parse the x,y coordinates */
        $Q = $this->keyUtil->parseCoordinatePairFromPublicKey($pubkey);

        list($Q['x'], $Q['y']) = array($this->decodeHex($Q['x']), $this->decodeHex($Q['y']));

        $this->coordsRangeCheck($Q['x'], $Q['y']);

        try {
            /* Calculate w = s^-1 (mod n) */
            $w = $this->Invert($s_dec, $n_dec);

            /* Calculate u1 = e*w (mod n) */
            $u1 = $this->Modulo($this->Multiply($e, $w), $n_dec);

            /* Calculate u2 = r*w (mod n) */
            $u2 = $this->Modulo($this->Multiply($r_dec, $w), $n_dec);

            /* Get new point Z(x1,y1) = (u1 * G) + (u2 * Q) */
            $Z  = $this->pointAddW($this->DoubleAndAdd($this->P, $u1), $this->DoubleAndAdd($Q, $u2));

            /*
             * A signature is valid if r is congruent to x1 (mod n)
             * or in other words, if r - x1 is an integer multiple of n.
             */
            $congruent = $this->congruencyCheck($this->decodeHex($r), $this->decodeHex($Z['x']));

            return $congruent;

        } catch (\Exception $e) {
            throw $e;
        }
    }