@AccessesPartialKey
  static com.google.crypto.tink.hybrid.HpkePublicKey parsePublicKey(HpkePublicKey protoKey)
      throws GeneralSecurityException {
    if (protoKey.getVersion() != 0) {
      throw new GeneralSecurityException("Only version 0 keys are accepted");
    }
    if (protoKey.getParams().getKem() != HpkeKem.DHKEM_X25519_HKDF_SHA256) {
      throw new GeneralSecurityException("Only HpkeKem.DHKEM_X25519_HKDF_SHA256 is supported");
    }
    if (protoKey.getParams().getKdf() != HpkeKdf.HKDF_SHA256) {
      throw new GeneralSecurityException("Only HpkeKdf.HKDF_SHA256 is supported");
    }
    if (protoKey.getParams().getAead() != HpkeAead.AES_128_GCM) {
      throw new GeneralSecurityException("Only HpkeAead.AES_128_GCM is supported");
    }
    HpkeParameters parameters =
        HpkeParameters.builder()
            .setVariant(HpkeParameters.Variant.NO_PREFIX)
            .setKemId(HpkeParameters.KemId.DHKEM_X25519_HKDF_SHA256)
            .setKdfId(HpkeParameters.KdfId.HKDF_SHA256)
            .setAeadId(HpkeParameters.AeadId.AES_128_GCM)
            .build();
    BigInteger n =
        BigIntegerEncoding.fromUnsignedBigEndianBytes(protoKey.getPublicKey().toByteArray());
    byte[] encodedPublicKeyBytes = BigIntegerEncoding.toBigEndianBytesOfFixedLength(n, 32);
    return com.google.crypto.tink.hybrid.HpkePublicKey.create(
        parameters, Bytes.copyFrom(encodedPublicKeyBytes), /* idRequirement= */ null);
  }
A KeyManager for HPKE Encrypt with a custom type URL for testing.
java_src/src/main/java/com/google/crypto/tink/hybrid/internal/testing/LegacyHybridEncryptKeyManager.java