/**
  * @param PrivateKeyInterface $privateKey
  * @return Buffer
  */
 public function serialize(PrivateKeyInterface $privateKey)
 {
     $multiplier = $privateKey->getSecretMultiplier();
     return Buffer::hex($this->ecAdapter->getMath()->decHex($multiplier), 32);
 }
示例#2
0
 /**
  * @param EcAdapterInterface $ecAdapter
  * @param PrivateKeyInterface $privateKey
  * @param Buffer $messageHash
  * @param string $algo
  */
 public function __construct(EcAdapterInterface $ecAdapter, PrivateKeyInterface $privateKey, Buffer $messageHash, $algo = 'sha256')
 {
     $mdPk = new MdPrivateKey($ecAdapter->getMath(), $ecAdapter->getGenerator(), $privateKey->getSecretMultiplier());
     $this->ecAdapter = $ecAdapter;
     $this->hmac = new HmacRandomNumberGenerator($ecAdapter->getMath(), $mdPk, $messageHash->getInt(), $algo);
 }
示例#3
0
 /**
  * @param PrivateKeyInterface $privateKey
  * @return \BitWasp\Bitcoin\Key\PublicKey
  */
 public function privateToPublic(PrivateKeyInterface $privateKey)
 {
     return new PublicKey($this, $this->getGenerator()->mul($privateKey->getSecretMultiplier()), $privateKey->isCompressed());
 }