/** * @param PrivateKeyInterface $privateKey * @return Buffer */ public function serialize(PrivateKeyInterface $privateKey) { $multiplier = $privateKey->getSecretMultiplier(); return Buffer::hex($this->ecAdapter->getMath()->decHex($multiplier), 32); }
/** * @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); }
/** * @param PrivateKeyInterface $privateKey * @return \BitWasp\Bitcoin\Key\PublicKey */ public function privateToPublic(PrivateKeyInterface $privateKey) { return new PublicKey($this, $this->getGenerator()->mul($privateKey->getSecretMultiplier()), $privateKey->isCompressed()); }