github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/flip/prot.avdl (about)

     1  
     2  @namespace("flip")
     3  
     4  protocol flip {
     5    import idl "github.com/keybase/client/go/protocol/gregor1" as gregor1;
     6    import idl "github.com/keybase/client/go/protocol/chat1" as chat1;
     7  
     8    // Time in milliseconds since the epoch
     9    @typedef("long")
    10    record Time {}
    11  
    12    record Start {
    13      Time startTime;
    14      // How long the commitment window lasts
    15      long commitmentWindowMsec;
    16      // How long the reveal window lasts
    17      long revealWindowMsec;
    18      // How much slack to give before warning
    19      long slackMsec;
    20      // How long followers should wait for a commitment complete
    21      long commitmentCompleteWindowMsec;
    22      // Whether a shuffle, coin flip, etc.
    23      FlipParameters params;
    24    }
    25  
    26    record UserDevice {
    27      gregor1.DeviceID d;
    28      gregor1.UID u;
    29    }
    30  
    31    record GameMetadata {
    32      UserDevice initiator;
    33      chat1.ConversationID conversationID;
    34      chat1.FlipGameID gameID;
    35    }
    36  
    37    record CommitmentComplete {
    38      array<UserDeviceCommitment> players;
    39    }
    40  
    41    enum FlipType {
    42      BOOL_1,
    43      INT_2,
    44      BIG_3,
    45      SHUFFLE_4
    46    }
    47  
    48    variant FlipParameters switch (FlipType t) {
    49      case BOOL: void;
    50      case INT: long;
    51      case BIG: bytes;
    52      case SHUFFLE: long;
    53    }
    54  
    55    enum MessageType {
    56      START_1,
    57      COMMITMENT_2,
    58      COMMITMENT_COMPLETE_3,
    59      REVEAL_4,
    60      END_5
    61    }
    62  
    63    enum Stage {
    64      ROUND1_1,
    65      ROUND2_2
    66    }
    67  
    68    fixed Secret(32);
    69    fixed Commitment(32);
    70  
    71    record UserDeviceCommitment {
    72      UserDevice ud;
    73      Commitment c;
    74    }
    75  
    76    fixed Hash(32);
    77  
    78    record Reveal {
    79      Secret secret;
    80      Hash cch; // Hash of commitment complete (sent in prior round).
    81    }
    82  
    83    variant GameMessageBody switch (MessageType t) {
    84      case START: Start;
    85      case COMMITMENT: Commitment;
    86      case COMMITMENT_COMPLETE: CommitmentComplete;
    87      case REVEAL: Reveal;
    88      case END: void;
    89    }
    90  
    91    enum Version {
    92       V1_1
    93    }
    94  
    95    variant GameMessage switch (Version v) {
    96      case V1: GameMessageV1;
    97      default: void;
    98    }
    99  
   100    record GameMessageV1 {
   101      GameMetadata md;
   102      GameMessageBody body;
   103    }
   104  
   105  }