Exemple #1
0
 /**
  * @param string $content
  * @param Binary $address
  * @param string $signature
  * @return bool
  * @throws \Exception
  */
 public function verify($content, Binary $address, $signature)
 {
     if (!strpos($signature, self::$SIGNATURE_GLUE)) {
         throw new \Exception('Invalid signature.');
     }
     list($r, $s) = explode(self::$SIGNATURE_GLUE, $signature);
     $math = MathAdapterFactory::getAdapter();
     $serializer = new DerPublicKeySerializer($math);
     $inflatedPublicKey = $this->deserialize($address->getData(), $serializer);
     $hash = $this->hash($content);
     $signer = new Signer($math);
     return $signer->verify($inflatedPublicKey, new Signature($r, $s), $hash);
 }
Exemple #2
0
 /**
  * @param string $content
  * @param Binary $address
  * @param string $signature
  * @return bool
  */
 public function verify($content, Binary $address, $signature)
 {
     $signed = $this->sign($content, new Binary($address->getData() . ' key'));
     return $signed == $signature;
 }