more comments
[iotcloud.git] / doc / iotcloud.tex
1 \documentclass[11pt]{article}\r
2 \newcommand{\tuple}[1]{\ensuremath \langle #1 \rangle}\r
3 \usepackage{color}\r
4 \usepackage{amsthm}\r
5 \newtheorem{theorem}{Theorem}\r
6 \newtheorem{defn}{Definition}\r
7 \newcommand{\note}[1]{{\color{red} \bf [[#1]]}}\r
8 \r
9 \begin{document}\r
10 \section{Approach}\r
11 \r
12 \subsection{Keys}\r
13 \r
14 Each device has: user id + password\r
15 \r
16 Server login is:\r
17 hash1(user id), hash1(password)\r
18 \r
19 Symmetric Crypto keys is:\r
20 hash2(user id | password)\r
21 \r
22 Server has finite length queue of entries + max\_entry\_identifier +\r
23 server login key\r
24 \r
25 \textbf{Login}\r
26 \note{Look at formal algorithm descriptions elsewhere, this is just informal prose...  It really needs to be more precise...}\r
27 \r
28 \begin{enumerate}\r
29 \item In the beginning, there are $d$ devices. Each of the \r
30 devices has a randomly/user-chosen self-generated $m$-bit user \r
31 identification $i$ and $n$-bit password $p$.\note{All devices being known in the beginning seems unreasonable...How about 1 device initially, and devices can be added at any time...}\r
32 \item Each device registers these $i$ and $p$ with the server. \r
33 The server appends ‘salt’ values, $k$-bit random strings $s1$ \r
34 and $s2$, and generate hash values $j=h(i+s1)$ and \r
35 $o=h(p+s2)$ for each $i$ and $p$. All $s1$, $s2$, $j$ and $o$ \r
36 are then stored in the database.\note{Are these the same $i$ and $p$ as below, if so, you just gave away the password}\r
37 \item Device to server validation is done by checking the hash values \r
38 $j\textsc{\char13}$ and $o\textsc{\char13}$ from $i\textsc{\char13}$ and \r
39 $p\textsc{\char13}$ that are given by users at login time against \r
40 $i$ and $p$ that are stored in the database.\r
41 \end{enumerate}\r
42 \r
43 \textbf{Symmetric Keys}\r
44 \note{The user uses the same username/key to log into all devices}\r
45 \begin{enumerate}\r
46 \item In the beginning, there are $d$ devices. Each of the \r
47 devices has a randomly/user-chosen self-generated $m$-bit user \r
48 identification $i$ and $n$-bit password $p$. These $i$ and $p$ \r
49 are used for device login on server.\r
50 \item All of $d$ agree on a hash function $h$ that is not known by \r
51 the server.\note{Doesn't make sense to agree on a hash function...People have a shared key.}\r
52 \item A symmetric key for each device is generated by applying $h$\r
53 to the value $(i + p)$ that gives $SK=h(i + p)$.\r
54 \item This value $SK$ is pre-known and pre-stored by all other \r
55 devices prior to operation of the data structure.\r
56 \end{enumerate}\r
57 \r
58 \textbf{Data Structure on Server}\r
59 \note{Define server state as an appropriate tuple and then give pseudocode here for updating that tuple...}\r
60 \begin{enumerate}\r
61 \item Server maintains a finite length $q$-entry FIFO queue \r
62 $Q=\{0, 1, …, q-1\}$. It has a head and a tail pointers that keep track \r
63 of head and tail slots.\r
64 \item Server records a max entry identifier $max$ as a limit for $q$. \r
65 It keeps track that $q \leq max$ at all times. When $q=max$, the queue \r
66 mechanism allows this sequence of events when there is a new slot added:\r
67 \begin{enumerate}\r
68 \item Pointer for entry $0$ now points to entry $1$, making it the new \r
69 entry $0$.\r
70 \item Entry $0$ is expunged from the queue.\r
71 \item New entry is added to the end of the queue, making it entry $q$.\r
72 \item Pointer for entry $q-1$ is advanced to entry $q$, making it the new \r
73 entry $q-1$.\r
74 \end{enumerate}\r
75 \item For client login, server maintains a table with values $i$, $p$,\r
76 $s1$, and $s2$ that are generated when device registers itself on server \r
77 for the first time.\r
78 \end{enumerate}\r
79 \r
80 \subsection{Entry layout}\r
81 Each entry has:\r
82 \begin{enumerate}\r
83 \item Sequence identifier\r
84 \item Random IV (if needed by crypto algorithm)\r
85 \item Encrypted payload\r
86 \end{enumerate}\r
87 \r
88 Payload has:\r
89 \begin{enumerate}\r
90 \item Sequence identifier\r
91 \item Machine id (most probably something like a 64-bit random number \r
92 that is self-generated by client)\r
93 \item HMAC of previous slot\r
94 \item Data entries\r
95 \item HMAC of current slot\r
96 \end{enumerate}\r
97 \r
98 A data entry can be one of these:\r
99 \begin{enumerate}\r
100 \item All or part of a Key-value entry\r
101 \item Slot sequence entry: Machine id + last message identifier \r
102 \newline {The purpose of this is to keep the record of the last slot \r
103 from a certain client if a client's update has to expunge that other \r
104 client's last entry from the queue. This is kept in the slot until \r
105 the entry owner inserts a newer update into the queue.}\r
106 \item Queue state entry: Includes queue size \newline {The purpose \r
107 of this is for the client to tell if the server lies about the number \r
108 of slots in the queue, e.g. if there are 2 queue state entry in the queue, \r
109 e.g. 50 and 70, the client knows that when it sees 50, it should expect \r
110 at most 50 slots in the queue and after it sees 70, it should expect \r
111 50 slots before that queue state entry slot 50 and at most 70 slots. \r
112 The queue state entry slot 70 is counted as slot number 51 in the queue.}\r
113 \end{enumerate}\r
114 \r
115 \subsection{Live status}\r
116 \r
117 Live status of entries:\r
118 \begin{enumerate}\r
119 \item Key-Value Entry is dead if either (a) there is a newer key-value pair or (b) it is incomplete.\r
120         \r
121 \item Slot sequence number (of either a message version data\r
122 or user-level data) is dead if there is a newer slot from the same machine.\r
123 \r
124 \item Queue state entry is dead if there is a newer queue state entry.\r
125 {In the case of queue state entries 50 and 70, this means that queue state \r
126 entry 50 is dead and 70 is live. However, not until the number of slotes reaches \r
127 70 that queue state entry 50 will be expunged from the queue.}\r
128 \end{enumerate}\r
129 \r
130 When data is at the end of the queue ready to expunge, if:\r
131 \begin{enumerate}\r
132 \item The key-value entry is not dead, it must be reinserted at the\r
133 beginning of the queue.\r
134 \r
135 \item If the slot sequence number is not dead, then a message sequence\r
136 entry must be inserted.\r
137 \r
138 \item If the queue state entry is not dead, it must be reinserted at the\r
139 beginning of the queue.\r
140 \end{enumerate}\r
141 \r
142 \r
143 \paragraph{Reads:}\r
144 Client sends a sequence number.  Server replies with either: all data\r
145 entries or all newer data entries.\r
146 \r
147 \paragraph{Writes:}\r
148 Client sends slot, server verifies that sequence number is valid,\r
149 checks entry hash, and replies with an accept message if all checks\r
150 pass.  On success, client updates its sequence number.  On failure,\r
151 server sends updates slots to client and client validates those slots.\r
152 \r
153 \paragraph{Local state on each client:}\r
154 A list of machines and the corresponding latest sequence numbers.\r
155 \r
156 \paragraph{Validation procedure on client:}\r
157 \begin{enumerate}\r
158 \item Decrypt each new slot in order.\r
159 \item For each slot:\r
160     (a) check its HMAC, and\r
161     (b) check that the previous entry HMAC field matches the previous\r
162     entry.\r
163 \item Check that the last message version for our machine matches our\r
164 last message sent.\r
165 \item For all other machines, check that the latest sequence number is\r
166 at least as large (never goes backwards).\r
167 \item That the queue has a current queue state entry.\r
168 \item That the number of entries received is consistent with the size\r
169 specified in the queue state entry.\r
170 \end{enumerate}\r
171 \r
172 Key-value entries can span multiple slots.  They aren't valid until\r
173 they are complete.\r
174 \r
175 \subsection{Resizing Queue}\r
176 Client can make a request to resize the queue. This is done as a write that combines:\r
177   (a) a slot with the message, and\r
178         (b) a request to the server\r
179 \r
180 \subsection{Formal Guarantees}\r
181 \r
182 \textit{To be completed ...}\r
183 \r
184 \begin{defn}[System Execution]\r
185 Formalize a system execution as a sequence of slot updates...  There\r
186 is a total order of all slot updates.\r
187 \end{defn}\r
188 \r
189 \begin{defn}[Transitive Closure]\r
190 Define transitive closure relation for slot updates...  There is an\r
191 edge from a slot update to a slot receive event if the receive event\r
192 reads from the update event.\r
193 \end{defn}\r
194 \r
195 \begin{defn}[Suborder]\r
196 Define suborder of total order.  It is a sequence of contiguous slots\r
197 updates (as observed by a given device).\r
198 \end{defn}\r
199 \r
200 \begin{defn}[Prefix of a suborder]\r
201 Given a sub order $o=u_{i},u_{i+1},...,u_j, u_{j+i},..., u', ...$ and\r
202 a slot update $u'$ in $o$, the prefix of $o$ is a sequence of all\r
203 updates that occur before $u'$ and $u'$.\r
204 \end{defn}\r
205 \r
206 \begin{defn}[Consistency between a suborder and a total order]\r
207 A suborder $o$ is consistent with a total order $t$, if all updates in $o$ appear in $t$ and they appear in the same order.\r
208 \end{defn}\r
209 \r
210 \begin{defn}[Consistency between suborders]\r
211 Define notion of consistency between suborders...  Two suborders U,V\r
212 are consistent if there exist a total order T such that both U and V\r
213 are suborders of T.\r
214 \end{defn}\r
215 \r
216 \begin{defn}[Error-free execution]\r
217 Define error-free execution --- execution for which the client does\r
218 not flag any errors...\r
219 \end{defn}\r
220 \r
221 \begin{theorem} Error-free execution of algorithm ensures that the suborder\r
222 for node n is consistent with the prefix suborder for all other nodes\r
223 that are in the transitive closure.\r
224 \end{theorem}\r
225 \begin{proof}\r
226 \textit{TODO}\r
227 \end{proof}\r
228 \r
229 \begin{defn}[State of Data Structure]\r
230 Define in terms of playing all updates sequentially onto local data\r
231 structure.\r
232 \end{defn}\r
233 \r
234 \begin{theorem}\r
235 Algorithm gives consistent view of data structure.\r
236 \end{theorem}\r
237 \begin{proof}\r
238 \textit{TODO}\r
239 \end{proof}\r
240 \r
241 \subsection{Future Work}\r
242 \paragraph{Support Messages}\r
243   A message is dead once receiving machine sends an entry with a newer\r
244   sequence identifier\r
245 \r
246 \paragraph{Persistent data structures}\r
247         Root object w/ fields\r
248         Other objects can be reachable from root\r
249         Each object has its own entries\r
250         Dead objects correspond to dead \r
251 \r
252 \paragraph{Multiple App Sharing}\r
253 \r
254 Idea is to separate subspace of entries...  Shared with other cloud...\r
255 \end{document}\r