public function Generate($message, $private_key)
    {
        $e         = '';
        $k         = '';
        $r         = '';
        $s         = '';

        $R         = array();
        $signature = array();

        $private_key = $this->encodeHex($private_key);

        $this->hexLenCheck($private_key);

        try {

            do {
                /* Get the message hash and a new random number */
                $e = $this->decodeHex('0x' . hash('sha256', $message));
                $k = $this->SecureRandomNumber();

                /* Calculate a new curve point from R=k*G (x1,y1) */
                $R      = $this->DoubleAndAdd($this->P, $k);
                $R['x'] = $this->addHexPrefix(str_pad($this->encodeHex($R['x'], false), 64, "0", STR_PAD_LEFT));

                /* r = x1 mod n */
                $r = $this->Modulo($this->decodeHex($R['x']), $this->n);

                /* s = k^-1 * (e+d*r) mod n */
                $dr  = $this->Multiply($this->decodeHex($private_key), $r);
                $edr = $this->Add($e, $dr);
                $s   = $this->Modulo($this->Multiply($this->Invert($k, $this->n), $edr), $this->n);
            } while ($this->zeroCompare($r, $s));

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

        $signature = array(
                           'r' => $this->addHexPrefix(str_pad($this->encodeHex($r, false), 64, "0", STR_PAD_LEFT)),
                           's' => $this->addHexPrefix(str_pad($this->encodeHex($s, false), 64, "0", STR_PAD_LEFT))
                          );

        $this->r_coordinate = $signature['r'];
        $this->s_coordinate = $signature['s'];

        $this->encoded_signature = $this->Encode($this->r_coordinate, $this->s_coordinate);

        return $this->encoded_signature;
    }