// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";

package cobalt;

import "observation.proto";
import "observation_batch.proto";

option java_multiple_files = true;
option java_package = "com.google.cobalt";

// A batch of unencrypted Observations with their metadata, similar to
// ObservationBatch.
//
// Unlike the ObservationBatch message, the Observations are not yet encrypted.
// UnencryptedObservationBatches are used as an intermediate object to store in
// the DB during observation generation.
// The Metadata for all of the observations in this batch.
message UnencryptedObservationBatch {
  // Data for Observations that have not yet been encrypted.
  ObservationMetadata metadata = 1;
  repeated ObservationToEncrypt unencrypted_observations = 2;
}

// The data for a single observation to send to the Cobalt server, similar to a
// EncryptedMessage that contains a serialized and encrypted Observation.
//
// Unlike the EncryptedMessage, the Observations are not yet serialized or
// encrypted.
message ObservationToEncrypt {
  // The `contribution_id` field is a cryptographically-secure random number
  // generated and attached by the Cobalt client. The shuffler counts the
  // number of unique ids to determine the contribution count per report.
  //
  // This field should only be set when the `observation` contains a Observation
  // that should be counted towards the shuffler threshold. All other
  // observations should not receive a `contribution_id`.
  //
  // Once an observation is assigned a `contribution_id` it should never be
  // given another id.
  bytes contribution_id = 1;

  // The observation to later serialize and encrypt, to be sent to the Cobalt
  // server.
  Observation observation = 2;
}