private static JwtEcdsaPublicKey parsePublicKeyFromProto(
      com.google.crypto.tink.proto.JwtEcdsaPublicKey protoKey,
      OutputPrefixType outputPrefixType,
      @Nullable Integer idRequirement)
      throws GeneralSecurityException {
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }

      JwtEcdsaParameters.Builder parametersBuilder = JwtEcdsaParameters.builder();
      JwtEcdsaPublicKey.Builder keyBuilder = JwtEcdsaPublicKey.builder();

    if (outputPrefixType.equals(OutputPrefixType.TINK)) {
        if (protoKey.hasCustomKid()) {
          throw new GeneralSecurityException(
              "Keys serialized with OutputPrefixType TINK should not have a custom kid");
      }
        if (idRequirement == null) {
          throw new GeneralSecurityException(
              "Keys serialized with OutputPrefixType TINK need an ID Requirement");
        }
        parametersBuilder.setKidStrategy(JwtEcdsaParameters.KidStrategy.BASE64_ENCODED_KEY_ID);
        keyBuilder.setIdRequirement(idRequirement);
    } else if (outputPrefixType.equals(OutputPrefixType.RAW)) {
        if (protoKey.hasCustomKid()) {
          parametersBuilder.setKidStrategy(JwtEcdsaParameters.KidStrategy.CUSTOM);
          keyBuilder.setCustomKid(protoKey.getCustomKid().getValue());
        } else {
          parametersBuilder.setKidStrategy(JwtEcdsaParameters.KidStrategy.IGNORED);
        }
      }
      parametersBuilder.setAlgorithm(toAlgorithm(protoKey.getAlgorithm()));
      keyBuilder.setPublicPoint(
          new ECPoint(
              BigIntegerEncoding.fromUnsignedBigEndianBytes(protoKey.getX().toByteArray()),
              BigIntegerEncoding.fromUnsignedBigEndianBytes(protoKey.getY().toByteArray())));
      return keyBuilder.setParameters(parametersBuilder.build()).build();
  }
Methods to serialize and parse {@link JwtEcdsaPrivateKey}, {@link JwtEcdsaPublicKey}, and {@link
JwtEcdsaParameters} objects.
java_src/src/main/java/com/google/crypto/tink/jwt/JwtEcdsaProtoSerialization.java