public function testSignAndIsCanonical()
 {
     $cnt = (getenv('BITCOINLIB_EXTENSIVE_TESTING') ?: 1) * 10;
     $math = EccFactory::getAdapter();
     $G = EccFactory::getSecgCurves()->generator256k1();
     $private = $G->createPrivateKey();
     for ($i = 0; $i < $cnt; $i++) {
         $randomMsgHash = $math->hexDec((string) hash('sha256', 'random' . $i));
         $randomK = $math->hexDec((string) bin2hex(mcrypt_create_iv(32, \MCRYPT_DEV_URANDOM)));
         $signer = new \Mdanter\Ecc\Crypto\Signature\Signer($math);
         $sign = $signer->sign($private, $randomMsgHash, $randomK);
         $this->assertInstanceOf('Mdanter\\Ecc\\Crypto\\Signature\\Signature', $sign);
         $sig = RawTransaction::encode_signature($sign);
         $this->assertTrue(RawTransaction::is_canonical_signature($sig));
     }
 }