/**
  * @dataProvider getDeterministicSign2Data
  */
 public function testDeterministicSign2($curve, $size, $algo, $privKey, $message, $eK, $eR, $eS)
 {
     //echo "Try {$test->curve} / {$test->algorithm} / '{$test->message}'\n";
     $G = CurveFactory::getGeneratorByName($curve);
     // Initialize private key and message hash (decimal)
     $privateKey = $G->getPrivateKeyFrom($this->math->hexDec($privKey));
     $hashHex = hash($algo, $message);
     $messageHash = $this->math->hexDec($hashHex);
     // Derive K
     $drbg = RandomGeneratorFactory::getHmacRandomGenerator($privateKey, $messageHash, $algo);
     $k = $drbg->generate($G->getOrder());
     $this->assertEquals($this->math->hexdec($eK), $k, 'k');
     $hexSize = strlen($hashHex);
     $hashBits = $this->math->baseConvert($messageHash, 10, 2);
     if (strlen($hashBits) < $hexSize * 4) {
         $hashBits = str_pad($hashBits, $hexSize * 4, '0', STR_PAD_LEFT);
     }
     $messageHash = $this->math->baseConvert(substr($hashBits, 0, $size), 2, 10);
     $signer = new Signer($this->math);
     $sig = $signer->sign($privateKey, $messageHash, $k);
     // R and S should be correct
     $sR = $this->math->hexDec($eR);
     $sS = $this->math->hexDec($eS);
     $this->assertTrue($signer->verify($privateKey->getPublicKey(), $sig, $messageHash));
     $this->assertSame($sR, $sig->getR(), 'r');
     $this->assertSame($sS, $sig->getS(), 's');
 }