@SuppressWarnings("UnusedException")
  private static EcdsaPrivateKey parsePrivateKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(PRIVATE_TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to EcdsaProtoSerialization.parsePrivateKey: "
              + serialization.getTypeUrl());
    }
    try {
      com.google.crypto.tink.proto.EcdsaPrivateKey protoKey =
          com.google.crypto.tink.proto.EcdsaPrivateKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      com.google.crypto.tink.proto.EcdsaPublicKey protoPublicKey = protoKey.getPublicKey();
      EcdsaParameters parameters =
          EcdsaParameters.builder()
              .setHashType(toHashType(protoPublicKey.getParams().getHashType()))
              .setSignatureEncoding(toSignatureEncoding(protoPublicKey.getParams().getEncoding()))
              .setCurveType(toCurveType(protoPublicKey.getParams().getCurve()))
              .setVariant(toVariant(serialization.getOutputPrefixType()))
              .build();
      EcdsaPublicKey publicKey =
          EcdsaPublicKey.builder()
              .setParameters(parameters)
              .setPublicPoint(
                  new ECPoint(
                      BigIntegerEncoding.fromUnsignedBigEndianBytes(
                          protoPublicKey.getX().toByteArray()),
                      BigIntegerEncoding.fromUnsignedBigEndianBytes(
                          protoPublicKey.getY().toByteArray())))
              .setIdRequirement(serialization.getIdRequirementOrNull())
              .build();
      return EcdsaPrivateKey.builder()
          .setPublicKey(publicKey)
          .setPrivateValue(
              SecretBigInteger.fromBigInteger(
                  BigIntegerEncoding.fromUnsignedBigEndianBytes(
                      protoKey.getKeyValue().toByteArray()),
                  SecretKeyAccess.requireAccess(access)))
          .build();
    } catch (InvalidProtocolBufferException | IllegalArgumentException e) {
      throw new GeneralSecurityException("Parsing EcdsaPrivateKey failed");
    }
  }
Methods to serialize and parse {@link EcdsaPrivateKey} and {@link EcdsaPublicKey} objects and
{@link EcdsaParameters} objects.
java_src/src/main/java/com/google/crypto/tink/signature/internal/EcdsaProtoSerialization.java