Jose\KeyConverter\ECKey::toPublic PHP Method

toPublic() public static method

public static toPublic ( ECKey $private ) : ECKey
$private ECKey
return ECKey
    public static function toPublic(ECKey $private)
    {
        $data = $private->toArray();
        if (array_key_exists('d', $data)) {
            unset($data['d']);
        }
        return new self($data);
    }

Usage Example

Esempio n. 1
0
 /**
  * @param \Jose\Object\JWKInterface $key
  * @param string                    $data
  * @param string                    $R
  * @param string                    $S
  *
  * @return bool
  */
 private function verifyOpenSSLSignature(JWKInterface $key, $data, $R, $S)
 {
     $pem = ECKey::toPublic(new ECKey($key))->toPEM();
     $oid_sequence = new Sequence();
     $oid_sequence->addChildren([new Integer(gmp_strval($this->convertHexToGmp($R), 10)), new Integer(gmp_strval($this->convertHexToGmp($S), 10))]);
     return 1 === openssl_verify($data, $oid_sequence->getBinary(), $pem, $this->getHashAlgorithm());
 }