syntax = "proto3";

package relay;

import "protobuf/sync.proto";

// Relay packet.
message RelayPacket {
  // Packet header.
  RelayHeader header = 1;
  // Packet payload.
  RelayPayload payload = 2;
}

// Relay header.
message RelayHeader {
  // Public key of the recipient.
  bytes to_public_key = 1;
  // Public key of the sender.
  bytes from_public_key = 2;
}

// Relay type.
enum RelayType {
  // Handshake type.
  Handshake = 0;
  // Transport type.
  Transport = 1;
}

// Relay payload.
message RelayPayload {
  // Type of this payload.
  RelayType kind = 1;
  // Payload body.
  RelayBody body = 2;
}

// Relay body.
message RelayBody {
  // Length of the data.
  uint32 length = 1;
  // Body contents.
  bytes contents = 2;
}

// Ready to start pairing.
message PairingReady {}

// Request to pair.
message PairingRequest {
  // Meta data of the device making the request.
  bytes device_meta_data = 1;
  // Account identifier.
  string account_id = 2;
}

// Pairing confirmed.
message PairingConfirm {
  // Signing key of the account (deprecated).
  // bytes account_signing_key = 1;

  // Signing key for the new device being paired.
  bytes device_signing_key = 2;
  // Vault containing the device signing key.
  bytes device_vault = 3;
  // Collection of server origins.
  repeated sync.WireOrigin servers = 4;
  // Account identifier.
  string account_id = 5;
  // Account name.
  string account_name = 6;
}

// Message for the pairing protocol.
message PairingMessage {
  // Inner message.
  oneof inner {
    // Noise handshake is completed and the 
    // participant is ready to begin.
    PairingReady ready = 1;
    // Request to pair with another device.
    PairingRequest request = 2;
    // Confirm a pairing request.
    PairingConfirm confirm = 3;
  }
}
