예제 #1
0
 /**
  * @param int|string $tweak
  * @return PublicKeyInterface
  */
 public function tweakAdd($tweak)
 {
     $adapter = $this->ecAdapter;
     $offset = $adapter->getGenerator()->mul($tweak);
     $newPoint = $this->point->add($offset);
     return $adapter->getPublicKey($newPoint, $this->compressed);
 }
예제 #2
0
파일: EcMath.php 프로젝트: sbwdlihao/phpecc
 /**
  * {@inheritDoc}
  * @see \Mdanter\Ecc\EcMathInterface::add()
  */
 public function add($addend)
 {
     $type = $this->identify($addend);
     if ($this->dataType == 'point' && $type == 'point') {
         $this->data = $this->data->add($addend);
         return $this;
     }
     if ($this->dataType == 'int' && $type == 'int') {
         $this->data = $this->modMath->add($this->data, $addend);
         return $this;
     }
     $this->handleOppositeTypes($addend, function (PointInterface $data, $addendInt) {
         // Multiply by generator and return a regular point to add to $data
         $point = $this->generator->mul($addendInt);
         //$point = $this->generator->getCurve()->getPoint($point->getX(), $point->getY(), $this->generator->getOrder());
         return $data->add($point);
     });
     return $this;
 }