Exemplo n.º 1
0
 /**
  * @param PublicKeyInterface $publicKey
  * @param int|string $integer
  * @return \BitWasp\Bitcoin\Key\PublicKey
  * @throws \Exception
  */
 public function publicKeyMul(PublicKeyInterface $publicKey, $integer)
 {
     $pubKey = $publicKey->getBuffer()->getBinary();
     $ret = (bool) \secp256k1_ec_pubkey_tweak_mul($pubKey, $this->getBinaryScalar($integer));
     if ($ret === false) {
         throw new \Exception('Secp256k1 pubkey tweak mul: failed');
     }
     return $this->getRelatedPublicKey($publicKey, $pubKey);
 }
Exemplo n.º 2
0
 /**
  * @param int $tweak
  * @return PublicKey
  * @throws \Exception
  */
 public function tweakMul($tweak)
 {
     $context = $this->ecAdapter->getContext();
     $math = $this->ecAdapter->getMath();
     $bin = pack('H*', str_pad($math->decHex($tweak), 64, '0', STR_PAD_LEFT));
     $clone = $this->clonePubkey();
     if (1 !== secp256k1_ec_pubkey_tweak_mul($context, $clone, $bin)) {
         throw new \RuntimeException('Secp256k1: tweak mul failed.');
     }
     return new PublicKey($this->ecAdapter, $clone, $this->compressed);
 }
 /**
  * @expectedException \PHPUnit_Framework_Error_Warning
  */
 public function testEnforceZvalString()
 {
     $tweak = $this->pack('0af79b2b747548d59a4a765fb73a72bc4208d00b43d0606c13d332d5c284b0ef');
     $publicKey = array();
     \secp256k1_ec_pubkey_tweak_mul(TestCase::getContext(), $publicKey, $tweak);
 }