syntax = "proto3";

package common;

enum WireEventLogTypeSystem {
  Identity = 0;
  Account = 1;
  Device = 2;
  Files = 3;
}

message WireEventLogTypeUser {
  bytes folder_id = 1; 
}

message WireEventLogType {
  oneof inner {
    WireEventLogTypeSystem system = 1;
    WireEventLogTypeUser user = 2;
  }
}

message WireSecretPath {
  bytes folder_id = 1;
  bytes secret_id = 2;
}

message WireCommitHash {
  // Bytes for the commit hash.
  bytes hash = 1;
}

message WireCommitProof {
  // Root hash for the proof.
  WireCommitHash root = 1;
  // Merkle proof serialized to bytes.
  bytes proof = 2;
  // Length of the tree.
  uint64 length = 3;
  // Proof indices.
  repeated uint64 indices = 4;
}

message WireCommitState {
  // Commit hash.
  WireCommitHash hash = 1;
  // Commit proof.
  WireCommitProof proof = 2;
}

message WireUtcDateTime {
  int64 seconds = 1;
  uint32 nanos = 2;
}

message WireEventRecord {
  // Date and time of the event record.
  WireUtcDateTime time = 1;
  // Commit hash of the previous event.
  WireCommitHash last_commit = 2;
  // Commit hash of this event.
  WireCommitHash commit = 3;
  /// Encoded event buffer.
  bytes event = 4;
}

message WireCheckedPatchSuccess {
  WireCommitProof proof = 1;
}

message WireCheckedPatchConflict {
  WireCommitProof head = 1;
  optional WireCommitProof contains = 2;
}

message WireCheckedPatch {
  oneof inner {
    WireCheckedPatchSuccess success = 1;
    WireCheckedPatchConflict conflict = 2;
  }
}

