/** * @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 $publicKey * @param $integer * @return \BitWasp\Bitcoin\Key\PublicKey */ public function publicKeyMul(PublicKeyInterface $publicKey, $integer) { $newPoint = $publicKey->getPoint()->mul($integer); return $this->getRelatedPublicKey($publicKey, $newPoint); }