/** * @param PrivateKey $privateKey * @return BufferInterface */ private function doSerialize(PrivateKey $privateKey) { return new Buffer($privateKey->getSecretBinary(), 32, $this->ecAdapter->getMath()); }
/** * @param BufferInterface $msg32 * @param PrivateKey $privateKey * @return CompactSignature */ private function doSignCompact(BufferInterface $msg32, PrivateKey $privateKey) { $sig_t = ''; /** @var resource $sig_t */ if (1 !== secp256k1_ecdsa_sign_recoverable($this->context, $msg32->getBinary(), $privateKey->getBinary(), $sig_t)) { throw new \RuntimeException('Secp256k1: failed to sign'); } $recid = ''; $ser = ''; if (!secp256k1_ecdsa_recoverable_signature_serialize_compact($this->context, $sig_t, $ser, $recid)) { throw new \RuntimeException('Failed to obtain recid'); } unset($ser); return new CompactSignature($this, $sig_t, $recid, $privateKey->isCompressed()); }