public function generate()
    {
        if (!empty($this->hex)) {
            return $this;
        }

        do {
            $privateKey = \Bitpay\Util\SecureRandom::generateRandom(32);
            $this->hex  = strtolower(bin2hex($privateKey));
        } while (Math::cmp('0x'.$this->hex, '1') <= 0 || Math::cmp('0x'.$this->hex, '0x'.Secp256k1::N) >= 0);

        $this->dec = Util::decodeHex($this->hex);

        return $this;
    }
public function generate()
    {
        if (!empty($this->hex)) {
            return $this;
        }

        do {
            $privateKey = \Bitpay\Util\SecureRandom::generateRandom(32);
            $this->hex  = strtolower(bin2hex($privateKey));
        } while (Math::cmp('0x'.$this->hex, '1') <= 0 || Math::cmp('0x'.$this->hex, '0x'.Secp256k1::N) >= 0);

        $this->dec = Util::decodeHex($this->hex);

        return $this;
    }
public function generate ( ) { if ( ! empty ( $ this -> hex ) ) { return $ this ; } do { $ privateKey = \ Bitpay \ Util \ SecureRandom :: generateRandom ( 32 ) ; $ this -> hex = strtolower ( bin2hex ( $ privateKey ) ) ; } while ( Math :: cmp ( '0x' . $ this -> hex , '1' ) <= 0 || Math :: cmp ( '0x' . $ this -> hex , '0x' . Secp256k1 :: N ) >= 0 ) ; $ this -> dec = Util :: decodeHex ( $ this -> hex ) ; return $ this ; }
Generates an EC private key

@return \Bitpay\PrivateKey
Generates an EC private key