// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: proto/device_to_device_messages.proto

#include "proto/device_to_device_messages.pb.h"

#include <algorithm>

#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG
namespace securegcm {
constexpr DeviceToDeviceMessage::DeviceToDeviceMessage(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : message_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , sequence_number_(0){}
struct DeviceToDeviceMessageDefaultTypeInternal {
  constexpr DeviceToDeviceMessageDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~DeviceToDeviceMessageDefaultTypeInternal() {}
  union {
    DeviceToDeviceMessage _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT DeviceToDeviceMessageDefaultTypeInternal _DeviceToDeviceMessage_default_instance_;
constexpr InitiatorHello::InitiatorHello(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : public_dh_key_(nullptr)
  , protocol_version_(0){}
struct InitiatorHelloDefaultTypeInternal {
  constexpr InitiatorHelloDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~InitiatorHelloDefaultTypeInternal() {}
  union {
    InitiatorHello _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT InitiatorHelloDefaultTypeInternal _InitiatorHello_default_instance_;
constexpr ResponderHello::ResponderHello(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : public_dh_key_(nullptr)
  , protocol_version_(0){}
struct ResponderHelloDefaultTypeInternal {
  constexpr ResponderHelloDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~ResponderHelloDefaultTypeInternal() {}
  union {
    ResponderHello _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT ResponderHelloDefaultTypeInternal _ResponderHello_default_instance_;
constexpr EcPoint::EcPoint(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : x_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , y_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , curve_(1)
{}
struct EcPointDefaultTypeInternal {
  constexpr EcPointDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~EcPointDefaultTypeInternal() {}
  union {
    EcPoint _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EcPointDefaultTypeInternal _EcPoint_default_instance_;
constexpr SpakeHandshakeMessage::SpakeHandshakeMessage(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : hash_value_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , payload_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , ec_point_(nullptr)
  , flow_number_(0){}
struct SpakeHandshakeMessageDefaultTypeInternal {
  constexpr SpakeHandshakeMessageDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~SpakeHandshakeMessageDefaultTypeInternal() {}
  union {
    SpakeHandshakeMessage _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SpakeHandshakeMessageDefaultTypeInternal _SpakeHandshakeMessage_default_instance_;
}  // namespace securegcm
namespace securegcm {
bool Curve_IsValid(int value) {
  switch (value) {
    case 1:
      return true;
    default:
      return false;
  }
}

static ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<std::string> Curve_strings[1] = {};

static const char Curve_names[] =
  "ED_25519";

static const ::PROTOBUF_NAMESPACE_ID::internal::EnumEntry Curve_entries[] = {
  { {Curve_names + 0, 8}, 1 },
};

static const int Curve_entries_by_number[] = {
  0, // 1 -> ED_25519
};

const std::string& Curve_Name(
    Curve value) {
  static const bool dummy =
      ::PROTOBUF_NAMESPACE_ID::internal::InitializeEnumStrings(
          Curve_entries,
          Curve_entries_by_number,
          1, Curve_strings);
  (void) dummy;
  int idx = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumName(
      Curve_entries,
      Curve_entries_by_number,
      1, value);
  return idx == -1 ? ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString() :
                     Curve_strings[idx].get();
}
bool Curve_Parse(
    ::PROTOBUF_NAMESPACE_ID::ConstStringParam name, Curve* value) {
  int int_value;
  bool success = ::PROTOBUF_NAMESPACE_ID::internal::LookUpEnumValue(
      Curve_entries, 1, name, &int_value);
  if (success) {
    *value = static_cast<Curve>(int_value);
  }
  return success;
}

// ===================================================================

class DeviceToDeviceMessage::_Internal {
 public:
  using HasBits = decltype(std::declval<DeviceToDeviceMessage>()._has_bits_);
  static void set_has_message(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_sequence_number(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

DeviceToDeviceMessage::DeviceToDeviceMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:securegcm.DeviceToDeviceMessage)
}
DeviceToDeviceMessage::DeviceToDeviceMessage(const DeviceToDeviceMessage& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  message_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    message_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_message()) {
    message_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_message(), 
      GetArenaForAllocation());
  }
  sequence_number_ = from.sequence_number_;
  // @@protoc_insertion_point(copy_constructor:securegcm.DeviceToDeviceMessage)
}

inline void DeviceToDeviceMessage::SharedCtor() {
message_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  message_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
sequence_number_ = 0;
}

DeviceToDeviceMessage::~DeviceToDeviceMessage() {
  // @@protoc_insertion_point(destructor:securegcm.DeviceToDeviceMessage)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void DeviceToDeviceMessage::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  message_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void DeviceToDeviceMessage::ArenaDtor(void* object) {
  DeviceToDeviceMessage* _this = reinterpret_cast< DeviceToDeviceMessage* >(object);
  (void)_this;
}
void DeviceToDeviceMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void DeviceToDeviceMessage::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void DeviceToDeviceMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:securegcm.DeviceToDeviceMessage)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    message_.ClearNonDefaultToEmpty();
  }
  sequence_number_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* DeviceToDeviceMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional bytes message = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          auto str = _internal_mutable_message();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional int32 sequence_number = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          _Internal::set_has_sequence_number(&has_bits);
          sequence_number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* DeviceToDeviceMessage::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:securegcm.DeviceToDeviceMessage)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional bytes message = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteBytesMaybeAliased(
        1, this->_internal_message(), target);
  }

  // optional int32 sequence_number = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_sequence_number(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:securegcm.DeviceToDeviceMessage)
  return target;
}

size_t DeviceToDeviceMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:securegcm.DeviceToDeviceMessage)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    // optional bytes message = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_message());
    }

    // optional int32 sequence_number = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_sequence_number());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void DeviceToDeviceMessage::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const DeviceToDeviceMessage*>(
      &from));
}

void DeviceToDeviceMessage::MergeFrom(const DeviceToDeviceMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:securegcm.DeviceToDeviceMessage)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_message(from._internal_message());
    }
    if (cached_has_bits & 0x00000002u) {
      sequence_number_ = from.sequence_number_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void DeviceToDeviceMessage::CopyFrom(const DeviceToDeviceMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:securegcm.DeviceToDeviceMessage)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool DeviceToDeviceMessage::IsInitialized() const {
  return true;
}

void DeviceToDeviceMessage::InternalSwap(DeviceToDeviceMessage* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &message_, lhs_arena,
      &other->message_, rhs_arena
  );
  swap(sequence_number_, other->sequence_number_);
}

std::string DeviceToDeviceMessage::GetTypeName() const {
  return "securegcm.DeviceToDeviceMessage";
}


// ===================================================================

class InitiatorHello::_Internal {
 public:
  using HasBits = decltype(std::declval<InitiatorHello>()._has_bits_);
  static const ::securemessage::GenericPublicKey& public_dh_key(const InitiatorHello* msg);
  static void set_has_public_dh_key(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_protocol_version(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

const ::securemessage::GenericPublicKey&
InitiatorHello::_Internal::public_dh_key(const InitiatorHello* msg) {
  return *msg->public_dh_key_;
}
void InitiatorHello::clear_public_dh_key() {
  if (public_dh_key_ != nullptr) public_dh_key_->Clear();
  _has_bits_[0] &= ~0x00000001u;
}
InitiatorHello::InitiatorHello(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:securegcm.InitiatorHello)
}
InitiatorHello::InitiatorHello(const InitiatorHello& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  if (from._internal_has_public_dh_key()) {
    public_dh_key_ = new ::securemessage::GenericPublicKey(*from.public_dh_key_);
  } else {
    public_dh_key_ = nullptr;
  }
  protocol_version_ = from.protocol_version_;
  // @@protoc_insertion_point(copy_constructor:securegcm.InitiatorHello)
}

inline void InitiatorHello::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&public_dh_key_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&protocol_version_) -
    reinterpret_cast<char*>(&public_dh_key_)) + sizeof(protocol_version_));
}

InitiatorHello::~InitiatorHello() {
  // @@protoc_insertion_point(destructor:securegcm.InitiatorHello)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void InitiatorHello::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  if (this != internal_default_instance()) delete public_dh_key_;
}

void InitiatorHello::ArenaDtor(void* object) {
  InitiatorHello* _this = reinterpret_cast< InitiatorHello* >(object);
  (void)_this;
}
void InitiatorHello::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void InitiatorHello::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void InitiatorHello::Clear() {
// @@protoc_insertion_point(message_clear_start:securegcm.InitiatorHello)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    GOOGLE_DCHECK(public_dh_key_ != nullptr);
    public_dh_key_->Clear();
  }
  protocol_version_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* InitiatorHello::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional .securemessage.GenericPublicKey public_dh_key = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          ptr = ctx->ParseMessage(_internal_mutable_public_dh_key(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional int32 protocol_version = 2 [default = 0];
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          _Internal::set_has_protocol_version(&has_bits);
          protocol_version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* InitiatorHello::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:securegcm.InitiatorHello)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional .securemessage.GenericPublicKey public_dh_key = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        1, _Internal::public_dh_key(this), target, stream);
  }

  // optional int32 protocol_version = 2 [default = 0];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_protocol_version(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:securegcm.InitiatorHello)
  return target;
}

size_t InitiatorHello::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:securegcm.InitiatorHello)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    // optional .securemessage.GenericPublicKey public_dh_key = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *public_dh_key_);
    }

    // optional int32 protocol_version = 2 [default = 0];
    if (cached_has_bits & 0x00000002u) {
      total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_protocol_version());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void InitiatorHello::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const InitiatorHello*>(
      &from));
}

void InitiatorHello::MergeFrom(const InitiatorHello& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:securegcm.InitiatorHello)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_mutable_public_dh_key()->::securemessage::GenericPublicKey::MergeFrom(from._internal_public_dh_key());
    }
    if (cached_has_bits & 0x00000002u) {
      protocol_version_ = from.protocol_version_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void InitiatorHello::CopyFrom(const InitiatorHello& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:securegcm.InitiatorHello)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool InitiatorHello::IsInitialized() const {
  if (_internal_has_public_dh_key()) {
    if (!public_dh_key_->IsInitialized()) return false;
  }
  return true;
}

void InitiatorHello::InternalSwap(InitiatorHello* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(InitiatorHello, protocol_version_)
      + sizeof(InitiatorHello::protocol_version_)
      - PROTOBUF_FIELD_OFFSET(InitiatorHello, public_dh_key_)>(
          reinterpret_cast<char*>(&public_dh_key_),
          reinterpret_cast<char*>(&other->public_dh_key_));
}

std::string InitiatorHello::GetTypeName() const {
  return "securegcm.InitiatorHello";
}


// ===================================================================

class ResponderHello::_Internal {
 public:
  using HasBits = decltype(std::declval<ResponderHello>()._has_bits_);
  static const ::securemessage::GenericPublicKey& public_dh_key(const ResponderHello* msg);
  static void set_has_public_dh_key(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_protocol_version(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

const ::securemessage::GenericPublicKey&
ResponderHello::_Internal::public_dh_key(const ResponderHello* msg) {
  return *msg->public_dh_key_;
}
void ResponderHello::clear_public_dh_key() {
  if (public_dh_key_ != nullptr) public_dh_key_->Clear();
  _has_bits_[0] &= ~0x00000001u;
}
ResponderHello::ResponderHello(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:securegcm.ResponderHello)
}
ResponderHello::ResponderHello(const ResponderHello& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  if (from._internal_has_public_dh_key()) {
    public_dh_key_ = new ::securemessage::GenericPublicKey(*from.public_dh_key_);
  } else {
    public_dh_key_ = nullptr;
  }
  protocol_version_ = from.protocol_version_;
  // @@protoc_insertion_point(copy_constructor:securegcm.ResponderHello)
}

inline void ResponderHello::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&public_dh_key_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&protocol_version_) -
    reinterpret_cast<char*>(&public_dh_key_)) + sizeof(protocol_version_));
}

ResponderHello::~ResponderHello() {
  // @@protoc_insertion_point(destructor:securegcm.ResponderHello)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void ResponderHello::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  if (this != internal_default_instance()) delete public_dh_key_;
}

void ResponderHello::ArenaDtor(void* object) {
  ResponderHello* _this = reinterpret_cast< ResponderHello* >(object);
  (void)_this;
}
void ResponderHello::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ResponderHello::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void ResponderHello::Clear() {
// @@protoc_insertion_point(message_clear_start:securegcm.ResponderHello)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    GOOGLE_DCHECK(public_dh_key_ != nullptr);
    public_dh_key_->Clear();
  }
  protocol_version_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* ResponderHello::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional .securemessage.GenericPublicKey public_dh_key = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          ptr = ctx->ParseMessage(_internal_mutable_public_dh_key(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional int32 protocol_version = 2 [default = 0];
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          _Internal::set_has_protocol_version(&has_bits);
          protocol_version_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* ResponderHello::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:securegcm.ResponderHello)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional .securemessage.GenericPublicKey public_dh_key = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        1, _Internal::public_dh_key(this), target, stream);
  }

  // optional int32 protocol_version = 2 [default = 0];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_protocol_version(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:securegcm.ResponderHello)
  return target;
}

size_t ResponderHello::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:securegcm.ResponderHello)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    // optional .securemessage.GenericPublicKey public_dh_key = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *public_dh_key_);
    }

    // optional int32 protocol_version = 2 [default = 0];
    if (cached_has_bits & 0x00000002u) {
      total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_protocol_version());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void ResponderHello::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const ResponderHello*>(
      &from));
}

void ResponderHello::MergeFrom(const ResponderHello& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:securegcm.ResponderHello)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_mutable_public_dh_key()->::securemessage::GenericPublicKey::MergeFrom(from._internal_public_dh_key());
    }
    if (cached_has_bits & 0x00000002u) {
      protocol_version_ = from.protocol_version_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void ResponderHello::CopyFrom(const ResponderHello& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:securegcm.ResponderHello)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool ResponderHello::IsInitialized() const {
  if (_internal_has_public_dh_key()) {
    if (!public_dh_key_->IsInitialized()) return false;
  }
  return true;
}

void ResponderHello::InternalSwap(ResponderHello* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(ResponderHello, protocol_version_)
      + sizeof(ResponderHello::protocol_version_)
      - PROTOBUF_FIELD_OFFSET(ResponderHello, public_dh_key_)>(
          reinterpret_cast<char*>(&public_dh_key_),
          reinterpret_cast<char*>(&other->public_dh_key_));
}

std::string ResponderHello::GetTypeName() const {
  return "securegcm.ResponderHello";
}


// ===================================================================

class EcPoint::_Internal {
 public:
  using HasBits = decltype(std::declval<EcPoint>()._has_bits_);
  static void set_has_curve(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_x(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_y(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static bool MissingRequiredFields(const HasBits& has_bits) {
    return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0;
  }
};

EcPoint::EcPoint(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:securegcm.EcPoint)
}
EcPoint::EcPoint(const EcPoint& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  x_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    x_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_x()) {
    x_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_x(), 
      GetArenaForAllocation());
  }
  y_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    y_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_y()) {
    y_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_y(), 
      GetArenaForAllocation());
  }
  curve_ = from.curve_;
  // @@protoc_insertion_point(copy_constructor:securegcm.EcPoint)
}

inline void EcPoint::SharedCtor() {
x_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  x_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
y_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  y_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
curve_ = 1;
}

EcPoint::~EcPoint() {
  // @@protoc_insertion_point(destructor:securegcm.EcPoint)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void EcPoint::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  x_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  y_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void EcPoint::ArenaDtor(void* object) {
  EcPoint* _this = reinterpret_cast< EcPoint* >(object);
  (void)_this;
}
void EcPoint::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void EcPoint::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void EcPoint::Clear() {
// @@protoc_insertion_point(message_clear_start:securegcm.EcPoint)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      x_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      y_.ClearNonDefaultToEmpty();
    }
    curve_ = 1;
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* EcPoint::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // required .securegcm.Curve curve = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::securegcm::Curve_IsValid(val))) {
            _internal_set_curve(static_cast<::securegcm::Curve>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(1, val, mutable_unknown_fields());
          }
        } else
          goto handle_unusual;
        continue;
      // required bytes x = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          auto str = _internal_mutable_x();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // required bytes y = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          auto str = _internal_mutable_y();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* EcPoint::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:securegcm.EcPoint)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // required .securegcm.Curve curve = 1;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      1, this->_internal_curve(), target);
  }

  // required bytes x = 2;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteBytesMaybeAliased(
        2, this->_internal_x(), target);
  }

  // required bytes y = 3;
  if (cached_has_bits & 0x00000002u) {
    target = stream->WriteBytesMaybeAliased(
        3, this->_internal_y(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:securegcm.EcPoint)
  return target;
}

size_t EcPoint::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:securegcm.EcPoint)
  size_t total_size = 0;

  if (_internal_has_x()) {
    // required bytes x = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_x());
  }

  if (_internal_has_y()) {
    // required bytes y = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_y());
  }

  if (_internal_has_curve()) {
    // required .securegcm.Curve curve = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_curve());
  }

  return total_size;
}
size_t EcPoint::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:securegcm.EcPoint)
  size_t total_size = 0;

  if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) {  // All required fields are present.
    // required bytes x = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_x());

    // required bytes y = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
        this->_internal_y());

    // required .securegcm.Curve curve = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_curve());

  } else {
    total_size += RequiredFieldsByteSizeFallback();
  }
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void EcPoint::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const EcPoint*>(
      &from));
}

void EcPoint::MergeFrom(const EcPoint& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:securegcm.EcPoint)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_x(from._internal_x());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_set_y(from._internal_y());
    }
    if (cached_has_bits & 0x00000004u) {
      curve_ = from.curve_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void EcPoint::CopyFrom(const EcPoint& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:securegcm.EcPoint)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool EcPoint::IsInitialized() const {
  if (_Internal::MissingRequiredFields(_has_bits_)) return false;
  return true;
}

void EcPoint::InternalSwap(EcPoint* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &x_, lhs_arena,
      &other->x_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &y_, lhs_arena,
      &other->y_, rhs_arena
  );
  swap(curve_, other->curve_);
}

std::string EcPoint::GetTypeName() const {
  return "securegcm.EcPoint";
}


// ===================================================================

class SpakeHandshakeMessage::_Internal {
 public:
  using HasBits = decltype(std::declval<SpakeHandshakeMessage>()._has_bits_);
  static void set_has_flow_number(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static const ::securegcm::EcPoint& ec_point(const SpakeHandshakeMessage* msg);
  static void set_has_ec_point(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_hash_value(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_payload(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
};

const ::securegcm::EcPoint&
SpakeHandshakeMessage::_Internal::ec_point(const SpakeHandshakeMessage* msg) {
  return *msg->ec_point_;
}
SpakeHandshakeMessage::SpakeHandshakeMessage(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
  SharedCtor();
  if (!is_message_owned) {
    RegisterArenaDtor(arena);
  }
  // @@protoc_insertion_point(arena_constructor:securegcm.SpakeHandshakeMessage)
}
SpakeHandshakeMessage::SpakeHandshakeMessage(const SpakeHandshakeMessage& from)
  : ::PROTOBUF_NAMESPACE_ID::MessageLite(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
  hash_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    hash_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_hash_value()) {
    hash_value_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_hash_value(), 
      GetArenaForAllocation());
  }
  payload_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
    payload_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
  #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
  if (from._internal_has_payload()) {
    payload_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_payload(), 
      GetArenaForAllocation());
  }
  if (from._internal_has_ec_point()) {
    ec_point_ = new ::securegcm::EcPoint(*from.ec_point_);
  } else {
    ec_point_ = nullptr;
  }
  flow_number_ = from.flow_number_;
  // @@protoc_insertion_point(copy_constructor:securegcm.SpakeHandshakeMessage)
}

inline void SpakeHandshakeMessage::SharedCtor() {
hash_value_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  hash_value_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
payload_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
  payload_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), "", GetArenaForAllocation());
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&ec_point_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&flow_number_) -
    reinterpret_cast<char*>(&ec_point_)) + sizeof(flow_number_));
}

SpakeHandshakeMessage::~SpakeHandshakeMessage() {
  // @@protoc_insertion_point(destructor:securegcm.SpakeHandshakeMessage)
  if (GetArenaForAllocation() != nullptr) return;
  SharedDtor();
  _internal_metadata_.Delete<std::string>();
}

inline void SpakeHandshakeMessage::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  hash_value_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  payload_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  if (this != internal_default_instance()) delete ec_point_;
}

void SpakeHandshakeMessage::ArenaDtor(void* object) {
  SpakeHandshakeMessage* _this = reinterpret_cast< SpakeHandshakeMessage* >(object);
  (void)_this;
}
void SpakeHandshakeMessage::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void SpakeHandshakeMessage::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void SpakeHandshakeMessage::Clear() {
// @@protoc_insertion_point(message_clear_start:securegcm.SpakeHandshakeMessage)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      hash_value_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000002u) {
      payload_.ClearNonDefaultToEmpty();
    }
    if (cached_has_bits & 0x00000004u) {
      GOOGLE_DCHECK(ec_point_ != nullptr);
      ec_point_->Clear();
    }
  }
  flow_number_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<std::string>();
}

const char* SpakeHandshakeMessage::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // optional int32 flow_number = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
          _Internal::set_has_flow_number(&has_bits);
          flow_number_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional .securegcm.EcPoint ec_point = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          ptr = ctx->ParseMessage(_internal_mutable_ec_point(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional bytes hash_value = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          auto str = _internal_mutable_hash_value();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // optional bytes payload = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) {
          auto str = _internal_mutable_payload();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<std::string>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* SpakeHandshakeMessage::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:securegcm.SpakeHandshakeMessage)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 flow_number = 1;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_flow_number(), target);
  }

  // optional .securegcm.EcPoint ec_point = 2;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(
        2, _Internal::ec_point(this), target, stream);
  }

  // optional bytes hash_value = 3;
  if (cached_has_bits & 0x00000001u) {
    target = stream->WriteBytesMaybeAliased(
        3, this->_internal_hash_value(), target);
  }

  // optional bytes payload = 4;
  if (cached_has_bits & 0x00000002u) {
    target = stream->WriteBytesMaybeAliased(
        4, this->_internal_payload(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
        static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:securegcm.SpakeHandshakeMessage)
  return target;
}

size_t SpakeHandshakeMessage::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:securegcm.SpakeHandshakeMessage)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    // optional bytes hash_value = 3;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_hash_value());
    }

    // optional bytes payload = 4;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize(
          this->_internal_payload());
    }

    // optional .securegcm.EcPoint ec_point = 2;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *ec_point_);
    }

    // optional int32 flow_number = 1;
    if (cached_has_bits & 0x00000008u) {
      total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32SizePlusOne(this->_internal_flow_number());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void SpakeHandshakeMessage::CheckTypeAndMergeFrom(
    const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
  MergeFrom(*::PROTOBUF_NAMESPACE_ID::internal::DownCast<const SpakeHandshakeMessage*>(
      &from));
}

void SpakeHandshakeMessage::MergeFrom(const SpakeHandshakeMessage& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:securegcm.SpakeHandshakeMessage)
  GOOGLE_DCHECK_NE(&from, this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_hash_value(from._internal_hash_value());
    }
    if (cached_has_bits & 0x00000002u) {
      _internal_set_payload(from._internal_payload());
    }
    if (cached_has_bits & 0x00000004u) {
      _internal_mutable_ec_point()->::securegcm::EcPoint::MergeFrom(from._internal_ec_point());
    }
    if (cached_has_bits & 0x00000008u) {
      flow_number_ = from.flow_number_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  _internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
}

void SpakeHandshakeMessage::CopyFrom(const SpakeHandshakeMessage& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:securegcm.SpakeHandshakeMessage)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool SpakeHandshakeMessage::IsInitialized() const {
  if (_internal_has_ec_point()) {
    if (!ec_point_->IsInitialized()) return false;
  }
  return true;
}

void SpakeHandshakeMessage::InternalSwap(SpakeHandshakeMessage* other) {
  using std::swap;
  auto* lhs_arena = GetArenaForAllocation();
  auto* rhs_arena = other->GetArenaForAllocation();
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &hash_value_, lhs_arena,
      &other->hash_value_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
      &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(),
      &payload_, lhs_arena,
      &other->payload_, rhs_arena
  );
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(SpakeHandshakeMessage, flow_number_)
      + sizeof(SpakeHandshakeMessage::flow_number_)
      - PROTOBUF_FIELD_OFFSET(SpakeHandshakeMessage, ec_point_)>(
          reinterpret_cast<char*>(&ec_point_),
          reinterpret_cast<char*>(&other->ec_point_));
}

std::string SpakeHandshakeMessage::GetTypeName() const {
  return "securegcm.SpakeHandshakeMessage";
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace securegcm
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::securegcm::DeviceToDeviceMessage* Arena::CreateMaybeMessage< ::securegcm::DeviceToDeviceMessage >(Arena* arena) {
  return Arena::CreateMessageInternal< ::securegcm::DeviceToDeviceMessage >(arena);
}
template<> PROTOBUF_NOINLINE ::securegcm::InitiatorHello* Arena::CreateMaybeMessage< ::securegcm::InitiatorHello >(Arena* arena) {
  return Arena::CreateMessageInternal< ::securegcm::InitiatorHello >(arena);
}
template<> PROTOBUF_NOINLINE ::securegcm::ResponderHello* Arena::CreateMaybeMessage< ::securegcm::ResponderHello >(Arena* arena) {
  return Arena::CreateMessageInternal< ::securegcm::ResponderHello >(arena);
}
template<> PROTOBUF_NOINLINE ::securegcm::EcPoint* Arena::CreateMaybeMessage< ::securegcm::EcPoint >(Arena* arena) {
  return Arena::CreateMessageInternal< ::securegcm::EcPoint >(arena);
}
template<> PROTOBUF_NOINLINE ::securegcm::SpakeHandshakeMessage* Arena::CreateMaybeMessage< ::securegcm::SpakeHandshakeMessage >(Arena* arena) {
  return Arena::CreateMessageInternal< ::securegcm::SpakeHandshakeMessage >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
