/** * @param PrivateKeyInterface $key * @return BitString */ private function encodePubKey(PrivateKeyInterface $key) { return new BitString($this->pubKeySerializer->getUncompressedKey($key->getPublicKey())); }
private static function getUncompressedKeys(PrivateKeyInterface $privateKeyObject) { $pointSerializer = new UncompressedPointSerializer(EccFactory::getAdapter()); $vapid['publicKey'] = base64_encode(hex2bin($pointSerializer->serialize($privateKeyObject->getPublicKey()->getPoint()))); $vapid['privateKey'] = base64_encode(hex2bin(str_pad(gmp_strval($privateKeyObject->getSecret(), 16), 2 * self::PRIVATE_KEY_LENGTH, '0', STR_PAD_LEFT))); return $vapid; }
/** * @param EcDomain $domain * @param CertificateSubject $subject * @param PrivateKeyInterface $privateKey * @return Csr */ public static function getCsr(EcDomain $domain, CertificateSubject $subject, PrivateKeyInterface $privateKey) { $subjectSerializer = new CertificateSubjectSerializer(); $serialized = $subjectSerializer->serialize($subject); return new Csr($domain, $subject, $privateKey->getPublicKey(), $domain->getSigner()->sign($privateKey, $domain->getHasher()->hashDec($serialized), RandomGeneratorFactory::getUrandomGenerator()->generate($domain->getGenerator()->getOrder()))); }