/**
  * @param TransactionSignature $txSig
  * @return \BitWasp\Buffertools\Buffer
  */
 public function serialize(TransactionSignature $txSig)
 {
     $sig = $this->sigSerializer->serialize($txSig->getSignature());
     $parser = new Parser($sig->getHex());
     $parser->writeBytes(1, Buffer::int($txSig->getHashType(), 1));
     $buffer = $parser->getBuffer();
     return $buffer;
 }
 /**
  * @param \BitWasp\Bitcoin\Signature\TransactionSignature $txSig
  * @return \BitWasp\Buffertools\Buffer
  */
 public function serialize(\BitWasp\Bitcoin\Signature\TransactionSignature $txSig)
 {
     $sig = $this->sigSerializer->serialize($txSig->getSignature());
     $parser = new Parser($sig->getHex());
     $parser->writeInt(1, $txSig->getHashType());
     $buffer = $parser->getBuffer();
     return $buffer;
 }
Esempio n. 3
0
 /**
  * @param BufferInterface $signature
  * @return bool
  */
 public function isValidSignatureEncoding(BufferInterface $signature)
 {
     try {
         TransactionSignature::isDERSignature($signature);
         return true;
     } catch (SignatureNotCanonical $e) {
         /* In any case, we will return false outside this block */
     }
     return false;
 }
 /**
  * @param \BitWasp\Bitcoin\Signature\TransactionSignature $signature
  * @param PublicKeyInterface $publicKey
  * @return Script
  */
 public function payToPubKeyHash(TransactionSignature $signature, PublicKeyInterface $publicKey)
 {
     return ScriptFactory::create()->push($signature->getBuffer())->push($publicKey->getBuffer());
 }
 /**
  * @param Peer $sender
  * @param TransactionSignatureInterface $txSig
  * @return TransactionSignatureInterface
  */
 public function fixSig(Peer $sender, TransactionSignatureInterface $txSig, &$wasMalleated = false)
 {
     $sig = $txSig->getSignature();
     if (!$this->adapter->validateSignatureElement($sig->getS(), true)) {
         $ip = $sender->getRemoteAddr()->getIp();
         if (!isset($this->violators[$ip])) {
             $this->violators[$sender->getRemoteAddr()->getIp()] = 1;
         } else {
             $this->violators[$sender->getRemoteAddr()->getIp()]++;
         }
         $wasMalleated = true;
         $this->counter++;
         $txSig = new TransactionSignature($this->adapter, new Signature($this->adapter, $sig->getR(), $this->math->sub($this->order, $sig->getS())), $txSig->getHashType());
         if (!$this->adapter->validateSignatureElement($txSig->getSignature()->getS(), true)) {
             die('failed to produce a low-s signature');
         }
     }
     return $txSig;
 }
Esempio n. 6
0
 /**
  * @param Buffer $signature
  * @return bool
  */
 public function isValidSignatureEncoding(Buffer $signature)
 {
     try {
         \BitWasp\Bitcoin\Signature\TransactionSignature::isDERSignature($signature);
         return true;
     } catch (SignatureNotCanonical $e) {
         return false;
     }
 }