private static ProtoKeySerialization serializePrivateKey(
      EcdsaPrivateKey key, @Nullable SecretKeyAccess access) throws GeneralSecurityException {
    int encLength = getEncodingLength(key.getParameters().getCurveType());
    return ProtoKeySerialization.create(
        PRIVATE_TYPE_URL,
        com.google.crypto.tink.proto.EcdsaPrivateKey.newBuilder()
            .setPublicKey(getProtoPublicKey(key.getPublicKey()))
            .setKeyValue(
                ByteString.copyFrom(
                    BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                        key.getPrivateValue().getBigInteger(SecretKeyAccess.requireAccess(access)),
                        encLength)))
            .build()
            .toByteString(),
        KeyMaterialType.ASYMMETRIC_PRIVATE,
        toProtoOutputPrefixType(key.getParameters().getVariant()),
        key.getIdRequirementOrNull());
  }
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