Fixing SM list mechanism as it is checked against cr entries
[iotcloud.git] / doc / iotcloud.tex
index bffd87e5931e474ad6e7efe473476354db973b66..ad52a697213b05a5b0f52519faac1913544858c9 100644 (file)
@@ -215,15 +215,15 @@ $slot_s = \tuple{s, E(Dat_s)} =
 \textit{$MS_g$ = set MS to save all $\tuple{id, s_{last}}$ pairs while\r
 traversing DT after a request to server (initially empty)} \\\r
 \textit{SK = Secret Key} \\\r
-\textit{$SM$ = associative array of $\tuple{s, id}$ of all slots in a previous read\r
+\textit{$SM$ = associative array of $\tuple{s, id}$ of all slots in previous reads\r
 (initially empty)} \\ \\\r
 \textbf{Helper Functions} \\\r
 $MaxSlot(SL_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv}\r
-\in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \geq s_s$ \\\r
+       \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \geq s_s$ \\\r
 $MinSlot(SL_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv} \r
-\in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \leq s_s$ \\\r
+       \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s \leq s_s$ \\\r
 $Slot(SL_s,s_s)= \tuple{s, sv}$ \textit{such that} $\tuple{s, sv} \r
-\in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s = s_s$ \\\r
+       \in SL_s \wedge \forall \tuple{s_s, sv_s} \in SL_s, s = s_s$ \\\r
 $SeqN(\tuple{s, sv})=s$ \\\r
 $SlotVal(\tuple{s, sv})=sv$ \\\r
 $CreateLastSL(s,sv,id)=\tuple{s,sv,id}=sl_{last}$ \\\r
@@ -235,11 +235,11 @@ $GetPrevHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_p$ \\
 $GetCurrHmac(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=hmac_c$ \\\r
 $GetDatEnt(Dat_s = \tuple{s,id,hmac_p,DE,hmac_c})=DE$ \\\r
 $GetLiveSS(SS_{live},ss_s)= ss$ \textit{such that} $ss \in SS_{live} \r
-\wedge \forall ss_s \in SS_{live}, ss = ss_s$ \\\r
+       \wedge \forall ss_s \in SS_{live}, ss = ss_s$ \\\r
 $GetLiveCR(CR_{live},cr_s)= cr$ \textit{such that} $cr \in CR_{live} \r
-\wedge \forall cr_s \in CR_{live}, cr = cr_s$ \\\r
+       \wedge \forall cr_s \in CR_{live}, cr = cr_s$ \\\r
 $GetLivEntLastS(LV_s,kv_s)= s$ \textit{such that} $\tuple{kv, s} \in LV_s \r
-\wedge \forall \tuple{kv_s, s_s} \in LV_s, kv_s = kv$ \\\r
+       \wedge \forall \tuple{kv_s, s_s} \in LV_s, kv_s = kv$ \\\r
 $GetKV($key-value data entry$)=\tuple{k_s,v_s} = kv_s$ \\\r
 $GetSS($slot-sequence data entry$)=\tuple{id_s,s_{s_{last}}} = ss_s$ \\\r
 $GetQS($queue-state data entry$)=qs_s$ \\\r
@@ -251,11 +251,13 @@ $GetSLast(ss = \tuple{id, s_{last}})=s_{last}$ \\
 $GetS(cr = \tuple{s, id})=s$ \\\r
 $GetId(cr = \tuple{s, id})=id$ \\\r
 $GetKeyVal(DT_s,k_s)= \tuple{k, v}$ \textit{such that} $\tuple{k, v} \r
-\in DT_s \wedge \forall \tuple{k_s, v_s} \in DT_s, k = k_s$ \\\r
+       \in DT_s \wedge \forall \tuple{k_s, v_s} \in DT_s, k = k_s$ \\\r
 $MaxLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \r
-\wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, s_{last} \geq s_{s_{last}}$ \\\r
+       \wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, s_{last} \geq s_{s_{last}}$ \\\r
 $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s \r
-\wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, s_{last} \leq s_{s_{last}}$ \\\r
+       \wedge \forall \tuple{id_s, s_{s_{last}}} \in MS_s, s_{last} \leq s_{s_{last}}$ \\\r
+$MinCRSeqN(CR_s)= s$ \textit{such that} $\tuple{s, id} \in CR_s \r
+       \wedge \forall \tuple{s_s, id_s} \in CR_s, s \leq s_s$ \\\r
 \r
 \begin{algorithmic}[1]\r
 \Procedure{Error}{$msg$}\r
@@ -347,8 +349,8 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
 \end{algorithmic}\r
 \r
 \begin{algorithmic}[1]\r
-\Function{AddCRLivEnt}{$CR_{s_{live}},de_s$}\r
-\State $cr_s \gets GetCR(de_s)$\r
+\Function{AddCRLivEnt}{$CR_{s_{live}},cr_s$}\r
+%\State $cr_s \gets GetCR(de_s)$\r
 \State $cr_t \gets GetLiveCR(CR_{s_{live}},cr_s)$\r
 \If{$cr_t = \emptyset$}\r
        \State $CR_{s_{live}} \gets CR_{s_{live}} \cup \{cr_s\}$\Comment{First occurrence}\r
@@ -383,6 +385,15 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
 \EndFunction\r
 \end{algorithmic}\r
 \r
+\begin{algorithmic}[1]\r
+\Function{UpdateSM}{$SM_s,CR_s$}\Comment{Remove if dead}\r
+\State $s_{cr_{min}} \gets MinCRSeqN(CR_s)$\r
+       \State $SM_s \gets SM_s - \{\tuple{s_s,id_s} \mid \tuple{s_s,id_s}\r
+               \in SM_s \wedge s_s < s_{cr_{min}}\}$\r
+\State \Return{$CR_{s_{live}}$}\r
+\EndFunction\r
+\end{algorithmic}\r
+\r
 \begin{algorithmic}[1]\r
 \Procedure{CheckLastSeqN}{$MS_s,MS_t$}\r
 \For {$\tuple{id, s_t}$ in $MS_t$}\Comment{Check $MS_t$ based on the newer $MS_s$}\r
@@ -407,22 +418,15 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
        \State $id_s \gets GetId(cr_s)$\r
        \State $s_{s_{last}} \gets GetLastSeqN(MS_s,id_s)$\r
        \If{$s_{s_{last}} < s_s$}\r
-               \State $\Call{CheckColRes}{SM_s,cr_s}$\r
+               \State $id_t \gets SM_s[s_s]$\r
+               \If{$id_s \neq id_t$}\r
+                       \State \Call{Error}{'Invalid $id$ for this slot update'}\r
+               \EndIf\r
        \EndIf\r
 \EndIf\r
 \EndProcedure\r
 \end{algorithmic}\r
 \r
-\begin{algorithmic}[1]\r
-\Procedure{CheckColRes}{$SM_s,cr_t$}\Comment{Check $id_s$ in $SM_s$}\r
-\State $s_t \gets GetS(cr_t)$\r
-\State $id_s \gets SM_s[s_t]$\r
-\If{$id_s \neq id_t$}\r
-       \State \Call{Error}{'Invalid $id$ for this slot update'}\r
-\EndIf\r
-\EndProcedure\r
-\end{algorithmic}\r
-\r
 \begin{algorithmic}[1]\r
 \Function{StoreLastSlot}{$MS_s,sl_l,s_s,sv_s,id_s$}\r
 \State $s_{min} \gets MinLastSeqN(MS_s)$\r
@@ -455,14 +459,16 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
 \begin{algorithmic}[1]\r
 \Procedure{ProcessSL}{$SL_g$}\r
 \State $MS_g \gets \emptyset$\r
-\State $SM_{curr} \gets \emptyset$\r
+%\State $SM_{curr} \gets \emptyset$\r
 \State $\tuple{s_{g_{min}},sv_{g_{min}}} \gets MinSlot(SL_g)$\r
 \State $\tuple{s_{g_{max}},sv_{g_{max}}} \gets MaxSlot(SL_g)$\r
 \For{$s_g \gets s_{g_{min}}$ \textbf{to} $s_{g_{max}}$}\Comment{Process slots \r
        in $SL_g$ in order}\r
        \State $\tuple{s_g,sv_g} \gets Slot(SL_g,s_g)$\r
-       \State $SM_{curr} \gets SM_{curr} \cup \{\tuple{s_g,sv_g}\}$\r
        \State $Dat_g \gets Decrypt(SK,sv_g)$\r
+       \State $id_g \gets GetMacId(Dat_g)$\r
+       %\State $SM_{curr} \gets SM_{curr} \cup \{\tuple{s_g,id_g}\}$\r
+       \State $SM \gets SM \cup \{\tuple{s_g,id_g}\}$\r
        \State $s_{g_{in}} \gets GetSeqN(Dat_g)$\r
     \If{$s_g \neq s_{g_{in}}$}\r
                \State \Call{Error}{'Invalid sequence number'}\r
@@ -498,13 +504,14 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
                \ForAll{$de_{g_{cr}} \in DE_{g_{cr}}$}\r
                        \State $cr_g \gets GetCR(de_{g_{cr}})$\r
                        \State $\Call{CheckCollision}{MS,SM,cr_g}$\r
-                       \State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},de_{g_{cr}}}$\r
+                       %\State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},de_{g_{cr}}}$\r
+                       \State $CR_{live} \gets \Call{AddCRLivEnt}{CR_{live},cr_g}$\r
                \EndFor\r
        \EndIf\r
        \State $sl_{last} \gets \Call{StoreLastSlot}{MS,sl_{last},s_g,sv_g,id_g}$\r
        \State $DT \gets \Call{UpdateDT}{DT,DE_g,LV,s_g}$\r
 \EndFor\r
-\State $SM \gets SM_{curr}$\r
+%\State $SM \gets SM_{curr}$\r
 \If{$m + |SL_g| \leq max_g$}\Comment{Check actual size against $max_g$}\r
        \State $m \gets m + |SL_g|$\r
 \Else\r
@@ -513,6 +520,7 @@ $MinLastSeqN(MS_s)= s_{last}$ \textit{such that} $\tuple{id, s_{last}} \in MS_s
 \State $\Call{CheckLastSeqN}{MS_g,MS}$\r
 \State $\Call{UpdateSSLivEnt}{SS_{live},MS}$\r
 \State $\Call{UpdateCRLivEnt}{CR_{live},MS}$\r
+\State $\Call{UpdateSM}{SM,CR_{live}}$\r
 \EndProcedure\r
 \end{algorithmic}\r
 \r
@@ -1018,7 +1026,7 @@ starting before $\mathsf{r_1}$ and ending before $p$.
 \item Case 2.2.1: Some message in $\mathsf{X}$ was accepted. Let $\mathsf{s_{w_J}}$ \r
 be the greatest sequence number of the messages that client $\mathsf{J}$ sent in \r
 the path of message $\mathsf{w}$. In this case, before sending $\mathsf{p}$, \r
-$\mathsf{J}$'s value in $\mathsf{SM_J}$ for its own latest sequence number would \r
+$\mathsf{J}$'s value in $\mathsf{MS_J}$ for its own latest sequence number would \r
 be strictly greater than $\mathsf{s_{q_J}}$. If there is a sequence of messages with \r
 contiguous sequence numbers that $\mathsf{J}$ receives between $\mathsf{r_1}$ and \r
 $\mathsf{p}$, $\mathsf{J}$ throws an error for a similar reason as Case 1.1. Otherwise, \r