1package textsecure;
2
3option java_package = "org.whispersystems.libsignal.state";
4option java_outer_classname = "StorageProtos";
5
6message SessionStructure {
7    message Chain {
8        optional bytes senderRatchetKey = 1;
9        optional bytes senderRatchetKeyPrivate = 2;
10
11        message ChainKey {
12            optional uint32 index = 1;
13            optional bytes  key   = 2;
14        }
15
16        optional ChainKey chainKey = 3;
17
18        message MessageKey {
19            optional uint32 index     = 1;
20            optional bytes  cipherKey = 2;
21            optional bytes  macKey    = 3;
22            optional bytes  iv        = 4;
23        }
24
25        repeated MessageKey messageKeys = 4;
26    }
27
28    message PendingKeyExchange {
29        optional uint32 sequence                 = 1;
30        optional bytes  localBaseKey             = 2;
31        optional bytes  localBaseKeyPrivate      = 3;
32        optional bytes  localRatchetKey          = 4;
33        optional bytes  localRatchetKeyPrivate   = 5;
34        optional bytes  localIdentityKey         = 7;
35        optional bytes  localIdentityKeyPrivate  = 8;
36    }
37
38    message PendingPreKey {
39        optional uint32 preKeyId       = 1;
40        optional int32  signedPreKeyId = 3;
41        optional bytes  baseKey        = 2;
42    }
43
44    optional uint32 sessionVersion      = 1;
45    optional bytes localIdentityPublic  = 2;
46    optional bytes remoteIdentityPublic = 3;
47
48    optional bytes rootKey              = 4;
49    optional uint32 previousCounter     = 5;
50
51    optional Chain senderChain          = 6;
52    repeated Chain receiverChains       = 7;
53
54    optional PendingKeyExchange pendingKeyExchange = 8;
55    optional PendingPreKey      pendingPreKey      = 9;
56
57    optional uint32 remoteRegistrationId = 10;
58    optional uint32 localRegistrationId  = 11;
59
60    optional bool needsRefresh = 12;
61    optional bytes aliceBaseKey = 13;
62}
63
64message RecordStructure {
65    optional SessionStructure currentSession   = 1;
66    repeated SessionStructure previousSessions = 2;
67}
68
69message PreKeyRecordStructure {
70    optional uint32 id        = 1;
71    optional bytes  publicKey = 2;
72    optional bytes  privateKey = 3;
73}
74
75message SignedPreKeyRecordStructure {
76    optional uint32  id         = 1;
77    optional bytes   publicKey  = 2;
78    optional bytes   privateKey = 3;
79    optional bytes   signature  = 4;
80    optional fixed64 timestamp  = 5;
81}
82
83message IdentityKeyPairStructure {
84    optional bytes publicKey  = 1;
85    optional bytes privateKey = 2;
86}
87
88message SenderKeyStateStructure {
89    message SenderChainKey {
90        optional uint32 iteration = 1;
91        optional bytes  seed      = 2;
92    }
93
94    message SenderMessageKey {
95        optional uint32 iteration = 1;
96        optional bytes  seed      = 2;
97    }
98
99    message SenderSigningKey {
100        optional bytes public  = 1;
101        optional bytes private = 2;
102    }
103
104    optional uint32           senderKeyId       = 1;
105    optional SenderChainKey   senderChainKey    = 2;
106    optional SenderSigningKey senderSigningKey  = 3;
107    repeated SenderMessageKey senderMessageKeys = 4;
108}
109
110message SenderKeyRecordStructure {
111    repeated SenderKeyStateStructure senderKeyStates = 1;
112}