// Copyright 2021 Prysmatic Labs.
//
// 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 ethereum.eth.v1alpha1;

import "proto/eth/ext/options.proto";

option csharp_namespace = "Ethereum.Eth.V1";
option go_package = "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1;eth";
option java_multiple_files = true;
option java_outer_classname = "SyncCommitteeProto";
option java_package = "org.ethereum.eth.v1alpha1";
option php_namespace = "Ethereum\\Eth\\v1alpha1";

// Sync committee object to support light client.
message SyncCommitteeMessage {
  // Slot to which this contribution pertains.
  uint64 slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"];

  // 32 byte block root for this signature.
  bytes block_root = 2 [(ethereum.eth.ext.ssz_size) = "32"];

  // Index of the validator that produced this signature.
  uint64 validator_index = 3 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.ValidatorIndex"];

  // Signature by the validator over the block root of `slot`.
  bytes signature = 4 [(ethereum.eth.ext.ssz_size) = "96"];
}

// Aggregated sync committee object to support light client.
message SyncCommitteeContribution {
  // Slot to which this contribution pertains.
  uint64 slot = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.Slot"];

  // 32 byte block root for this signature.
  bytes block_root = 2 [(ethereum.eth.ext.ssz_size) = "32"];

  // The subcommittee this contribution pertains to out of the broader sync committee.
  uint64 subcommittee_index = 3;

  // A bit is set if a signature from the validator at the corresponding
  // index in the subcommittee is present in the aggregate `signature`.
  bytes aggregation_bits = 4 [(ethereum.eth.ext.ssz_size) = "sync_committee_aggregate_bytes.size", (ethereum.eth.ext.cast_type) = "sync_committee_aggregate_bits.type"];
  // Signature by the validator(s) over the block root of `slot`.
  bytes signature = 5 [(ethereum.eth.ext.ssz_size) = "96"];
}

// Aggregated sync committee signature object with selection proof to support light client.
message ContributionAndProof {
  // Index of the aggregator that produced this proof.
  uint64 aggregator_index = 1 [(ethereum.eth.ext.cast_type) = "github.com/prysmaticlabs/eth2-types.ValidatorIndex"];

  SyncCommitteeContribution contribution = 2;

  // The selection proof itself.
  bytes selection_proof = 3 [(ethereum.eth.ext.ssz_size) = "96"];
}

// Signed aggregated sync committee signature object with selection proof to support light client.
message SignedContributionAndProof {
  ContributionAndProof message = 1;

  // Signature of the aggregator that produced `message`.
  bytes signature = 4 [(ethereum.eth.ext.ssz_size) = "96"];
}
