Example #1
0
 /**
  * @param PrivateKeyInterface $privateKey
  * @return \BitWasp\Bitcoin\Key\PublicKey
  * @throws \Exception
  */
 public function privateToPublic(PrivateKeyInterface $privateKey)
 {
     $publicKey = '';
     $ret = \secp256k1_ec_pubkey_create($privateKey->getBuffer()->getBinary(), (int) $privateKey->isCompressed(), $publicKey);
     if ($ret === 1) {
         $public = PublicKeyFactory::fromHex(bin2hex($publicKey), $this);
         return $public;
     }
     throw new \Exception('Unable to convert private to public key');
 }
Example #2
0
 /**
  * @param PrivateKeyInterface $oldPrivate
  * @param $newSecret
  * @return \BitWasp\Bitcoin\Key\PrivateKey
  */
 private function getRelatedPrivateKey(PrivateKeyInterface $oldPrivate, $newSecret)
 {
     return new PrivateKey($this, $newSecret, $oldPrivate->isCompressed());
 }