private static com.google.crypto.tink.proto.JwtEcdsaPublicKey serializePublicKey(
      JwtEcdsaPublicKey key) throws GeneralSecurityException {
    int encLength = getEncodingLength(key.getParameters().getAlgorithm());
    ECPoint publicPoint = key.getPublicPoint();
    com.google.crypto.tink.proto.JwtEcdsaPublicKey.Builder builder =
        com.google.crypto.tink.proto.JwtEcdsaPublicKey.newBuilder()
            .setVersion(0)
            .setAlgorithm(toProtoAlgorithm(key.getParameters().getAlgorithm()))
            .setX(
                ByteString.copyFrom(
                    BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                        publicPoint.getAffineX(), encLength)))
            .setY(
                ByteString.copyFrom(
                    BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                        publicPoint.getAffineY(), encLength)));
    if (key.getParameters().getKidStrategy().equals(JwtEcdsaParameters.KidStrategy.CUSTOM)) {
      builder.setCustomKid(
          com.google.crypto.tink.proto.JwtEcdsaPublicKey.CustomKid.newBuilder()
              .setValue(key.getKid().get())
              .build());
    }
    return builder.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