private static int getEncodingLength(JwtEcdsaParameters.Algorithm algorithm)
      throws GeneralSecurityException {
    // We currently encode with one extra 0 byte at the beginning, to make sure
    // that parsing is correct even if passing of a two's complement encoding is used.
    // We want to prevent bugs similar to b/264525021
    if (algorithm.equals(JwtEcdsaParameters.Algorithm.ES256)) {
      return 33;
    }
    if (algorithm.equals(JwtEcdsaParameters.Algorithm.ES384)) {
      return 49;
    }
    if (algorithm.equals(JwtEcdsaParameters.Algorithm.ES512)) {
      return 67;
    }
    throw new GeneralSecurityException("Unknown algorithm: " + algorithm);
  }
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