@SuppressWarnings("UnusedException")
  private static EciesPrivateKey parsePrivateKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(PRIVATE_TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to EciesProtoSerialization.parsePrivateKey: "
              + serialization.getTypeUrl());
    }
    try {
      com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey protoKey =
          com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      com.google.crypto.tink.proto.EciesAeadHkdfPublicKey protoPublicKey = protoKey.getPublicKey();
      EciesParameters parameters =
          fromProtoParameters(serialization.getOutputPrefixType(), protoPublicKey.getParams());
      if (parameters.getCurveType().equals(EciesParameters.CurveType.X25519)) {
        EciesPublicKey publicKey =
            EciesPublicKey.createForCurveX25519(
                parameters,
                Bytes.copyFrom(protoPublicKey.getX().toByteArray()),
                serialization.getIdRequirementOrNull());
        return EciesPrivateKey.createForCurveX25519(
            publicKey,
            SecretBytes.copyFrom(
                protoKey.getKeyValue().toByteArray(), SecretKeyAccess.requireAccess(access)));
      }
      ECPoint point =
          new ECPoint(
              BigIntegerEncoding.fromUnsignedBigEndianBytes(protoPublicKey.getX().toByteArray()),
              BigIntegerEncoding.fromUnsignedBigEndianBytes(protoPublicKey.getY().toByteArray()));

      EciesPublicKey publicKey =
          EciesPublicKey.createForNistCurve(
              parameters, point, serialization.getIdRequirementOrNull());
      return EciesPrivateKey.createForNistCurve(
          publicKey,
          SecretBigInteger.fromBigInteger(
              BigIntegerEncoding.fromUnsignedBigEndianBytes(protoKey.getKeyValue().toByteArray()),
              SecretKeyAccess.requireAccess(access)));
    } catch (InvalidProtocolBufferException | IllegalArgumentException e) {
      throw new GeneralSecurityException("Parsing EcdsaPrivateKey failed");
    }
  }
Registers previously defined parser/serializer objects into a given registry.
java_src/src/main/java/com/google/crypto/tink/hybrid/internal/EciesProtoSerialization.java