private static com.google.crypto.tink.proto.EciesAeadHkdfPublicKey toProtoPublicKey(
      EciesPublicKey key) throws GeneralSecurityException {
    if (key.getParameters().getCurveType().equals(EciesParameters.CurveType.X25519)) {
      return com.google.crypto.tink.proto.EciesAeadHkdfPublicKey.newBuilder()
          .setVersion(0)
          .setParams(toProtoParameters(key.getParameters()))
          .setX(ByteString.copyFrom(key.getX25519CurvePointBytes().toByteArray()))
          .setY(ByteString.EMPTY)
          .build();
    }

    int encLength = getEncodingLength(key.getParameters().getCurveType());
    ECPoint publicPoint = key.getNistCurvePoint();
    if (publicPoint == null) {
      throw new GeneralSecurityException("NistCurvePoint was null for NIST curve");
    }
    return com.google.crypto.tink.proto.EciesAeadHkdfPublicKey.newBuilder()
        .setVersion(0)
        .setParams(toProtoParameters(key.getParameters()))
        .setX(
            ByteString.copyFrom(
                BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                    publicPoint.getAffineX(), encLength)))
        .setY(
            ByteString.copyFrom(
                BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                    publicPoint.getAffineY(), encLength)))
        .build();
  }
Registers previously defined parser/serializer objects into a given registry.
java_src/src/main/java/com/google/crypto/tink/hybrid/internal/EciesProtoSerialization.java