private static com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey toProtoPrivateKey(
      EciesPrivateKey key, @Nullable SecretKeyAccess access) throws GeneralSecurityException {
    com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey.Builder builder =
        com.google.crypto.tink.proto.EciesAeadHkdfPrivateKey.newBuilder()
            .setVersion(0)
            .setPublicKey(toProtoPublicKey(key.getPublicKey()));
    if (key.getParameters().getCurveType().equals(EciesParameters.CurveType.X25519)) {
      builder.setKeyValue(
          ByteString.copyFrom(
              key.getX25519PrivateKeyBytes().toByteArray(SecretKeyAccess.requireAccess(access))));
    } else {
      int encLength = getEncodingLength(key.getParameters().getCurveType());
      builder.setKeyValue(
          ByteString.copyFrom(
              BigIntegerEncoding.toBigEndianBytesOfFixedLength(
                  key.getNistPrivateKeyValue().getBigInteger(SecretKeyAccess.requireAccess(access)),
                  encLength)));
    }
    return builder.build();
  }
Registers previously defined parser/serializer objects into a given registry.
java_src/src/main/java/com/google/crypto/tink/hybrid/internal/EciesProtoSerialization.java