/** * @param PublicKeyInterface $publicKey * @return Buffer */ public function serialize(PublicKeyInterface $publicKey) { $point = $publicKey->getPoint(); $parser = new Parser(); $parser->writeBytes(1, $this->getPrefix($publicKey->isCompressed(), $point)); $math = $this->ecAdapter->getMath(); $publicKey->isCompressed() ? $parser->writeBytes(32, $math->decHex($point->getX())) : $parser->writeBytes(32, $math->decHex($point->getX()))->writeBytes(32, $math->decHex($point->getY())); return $parser->getBuffer(); }
/** * @param PublicKeyInterface $oldPublic * @param string $newBinary * @return \BitWasp\Bitcoin\Key\PublicKey */ private function getRelatedPublicKey(PublicKeyInterface $oldPublic, $newBinary) { return PublicKeyFactory::fromHex(bin2hex($newBinary), $this)->setCompressed($oldPublic->isCompressed()); }
/** * @param PublicKeyInterface $oldPublic * @param PointInterface $newPoint * @return \BitWasp\Bitcoin\Key\PublicKey */ private function getRelatedPublicKey(PublicKeyInterface $oldPublic, PointInterface $newPoint) { return new PublicKey($this, $newPoint, $oldPublic->isCompressed()); }