From afe128dd431367433c2eb6c5e7ab77696b2aa20f Mon Sep 17 00:00:00 2001 From: Dmytro Bogatov <dmytro@dbogatov.org> Date: Mon, 27 Nov 2017 18:10:32 -0500 Subject: [PATCH] Refactor examples. --- example/definitions.tex | 60 ++++++ sections/example.tex | 426 ++++++++++++++++++---------------------- 2 files changed, 255 insertions(+), 231 deletions(-) diff --git a/example/definitions.tex b/example/definitions.tex index 5ba1a86..066aef0 100644 --- a/example/definitions.tex +++ b/example/definitions.tex @@ -12,3 +12,63 @@ \newif\ifnodetwonew% \newif\ifnodethreenew% \newif\ifnodefournew% + +% +% 1 - caption +% +\newcommand% + {\drawTree} + [1] + { + \begin{figure} + \centering + + \input{example/tree} + \caption{#1} + \end{figure} + } + +% +% 1- map - default initial +% 2 - caption +% +\newcommand% + {\drawMap} + [2] + [initial] + { + \begin{figure} + \centering + + \input{example/#1-map} + \caption{#2} + \end{figure} + } + +% +% 1 - frame name +% 2 - settings +% 3 - upper block +% 4 - lower block +% 5 - notes +% +\newcommand% + {\exampleFrame} + [5] + { + \begin{frame}{#1} + + #2 + + #3 + + \vspace{-12pt} + + #4 + + \note{ + #5 + } + + \end{frame} + } diff --git a/sections/example.tex b/sections/example.tex index f0ebbac..00fad7a 100644 --- a/sections/example.tex +++ b/sections/example.tex @@ -4,234 +4,198 @@ \section{Example} - \begin{frame}{Initial state} - - \begin{figure} - \centering - - \input{example/tree} - \caption{Initial underlying tree} - \end{figure} - - \vspace{-12pt} - - \begin{figure} - \centering - - \input{example/initial-map} - \caption{Initial position map} - \end{figure} - - \end{frame} - - \begin{frame}{\textsc{Access}$(5)$} - - \selectedtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Select block with ID 5} - \end{figure} - - \vspace{-12pt} - - \begin{figure} - \centering - - \input{example/initial-map} - \caption{Find leaf for block with ID 5} - \end{figure} - - \end{frame} - - \begin{frame}{Read path} - - \selectedtrue% - \pathreadtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Select path $\mathcal{P}(6)$} - \end{figure} - - \vspace{-12pt} - - \begin{figure} - \centering - - \input{example/initial-map} - \caption{Find leaf for block with ID 5} - \end{figure} - - \end{frame} - - \begin{frame}{Remap block} - - \begin{block}{Stash} - - \begin{gather*} - S = \{ 10, 1, 2, \textcolor{red}{5}, 8, 7, 13, 15 \} \\ - data = \textsc{DecryptBlock}(\textcolor{red}{5}) \\ - \textcolor{blue}{5^\prime} \gets \textsc{EncryptData}(data^{\mbox{*}}) \\ - S = \{ 10, 1, 2, \textcolor{blue}{5^\prime}, 8, 7, 13, 15 \} - \end{gather*} - - \end{block} - - \begin{block}{Remap} - - Assign random leaf - - \[ - \text{position}[5] := 3 - \] - - \end{block} - - \end{frame} - - \begin{frame}{Write path back} - - \selectedtrue% - \pathreadtrue% - - \nodeonenewtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Write bucket on level $L = 3$} - \end{figure} - - \vspace{-12pt} - - \begin{block}{Stash} - - \begin{gather*} - S^\prime = \{ 8, 7, 1 \} \\ - S = \{ 10, 2, \textcolor{blue}{5}, 13, 15 \} - \end{gather*} - - \end{block} - - \end{frame} - - \begin{frame}{Write path back} - - \selectedtrue% - \pathreadtrue% - - \nodeonenewtrue% - \nodetwonewtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Write bucket on level $L - 1 = 2$} - \end{figure} - - \vspace{-12pt} - - \begin{block}{Stash} - - \begin{gather*} - S^\prime = \{ 2, 10, 15 \} \\ - S = \{ \textcolor{blue}{5}, 13 \} - \end{gather*} - - \end{block} - - \end{frame} - - \begin{frame}{Write path back} - - \selectedtrue% - \pathreadtrue% - - \nodeonenewtrue% - \nodetwonewtrue% - \nodethreenewtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Write bucket on level $L - 2 = 1$} - \end{figure} - - \vspace{-12pt} - - \begin{block}{Stash} - - \begin{gather*} - S^\prime = \{ 13 \} \\ - S = \{ \textcolor{blue}{5} \} - \end{gather*} - - \end{block} - - \end{frame} - - \begin{frame}{Write path back} - - \selectedtrue% - \pathreadtrue% - - \nodeonenewtrue% - \nodetwonewtrue% - \nodethreenewtrue% - \nodefournewtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Write bucket on level $0$} - \end{figure} - - \vspace{-12pt} - - \begin{block}{Stash} - - \begin{gather*} - S^\prime = \{ \textcolor{blue}{5} \} \\ - S = \varnothing - \end{gather*} - - \end{block} - - \end{frame} - - \begin{frame}{Final state} - - \selectedtrue% - \pathreadtrue% - - \nodeonenewtrue% - \nodetwonewtrue% - \nodethreenewtrue% - \nodefournewtrue% - - \begin{figure} - \centering - - \input{example/tree} - \caption{Tree after the execution} - \end{figure} - - \vspace{-12pt} - - \begin{figure} - \centering - - \input{example/final-map} - \caption{Position map after the execution} - \end{figure} - - \end{frame} + \exampleFrame% + {Initial state} + {} + {\drawTree{Initial underlying tree}} + {\drawMap{Initial position map}} + { + Here we see the initial state before we access an element. + Buckets are filled greedily from bottom to the top. + Leaves are numbered left to right. + Each number in the buckets corresponds to encrypted data block and each empty set symbol corresponds to dummy data block. + Position table shows the mapping from data blocks to leaves. + } + + \exampleFrame% + {\textsc{Access}$(5)$} + {\selectedtrue} + {\drawTree{Select block with ID 5}} + {\drawMap{Find leaf for block with ID 5}} + { + Let us access the data block with ID 5. + We first lookup position map to see, which leaf it corresponds to. + We see we need a path to the leaf number 6. + } + + \exampleFrame% + {Read path} + { + \selectedtrue% + \pathreadtrue% + } + {\drawTree{Select path $\mathcal{P}(6)$}} + {\drawMap{Find leaf for block with ID 5}} + { + We read the whole path from the root to the leaf number 6. + } + + \exampleFrame% + {Remap block} + {} + { + \begin{block}{Stash} + + \begin{gather*} + S = \{ 10, 1, 2, \textcolor{red}{5}, 8, 7, 13, 15 \} \\ + data = \textsc{DecryptBlock}(\textcolor{red}{5}) \\ + \textcolor{blue}{5^\prime} \gets \textsc{EncryptData}(data^{\mbox{*}}) \\ + S = \{ 10, 1, 2, \textcolor{blue}{5^\prime}, 8, 7, 13, 15 \} + \end{gather*} + + Re-encrypt all blocks in the stash. + + \end{block} + } + { + \begin{block}{Remap} + + Assign random leaf + + \[ + \text{position}[5] := 3 + \] + + \end{block} + } + { + Now all those data blocks appear in stash. + We now for a fact that our block of interest is there as well. + We extract it to data variable. + We change block's data and re-encrypt all data blocks. + We then put it back to stash. + + It is important that we also re-map the block. + Let say we assign it new leaf --- number 3. + + Now we need to write path back. + } + + \exampleFrame% + {Write path back} + { + \selectedtrue% + \pathreadtrue% + \nodeonenewtrue% + } + {\drawTree{Write bucket on level $L = 3$}} + { + \begin{block}{Stash} + + \begin{gather*} + S^\prime = \{ 8, 7, 1 \} \\ + S = \{ 10, 2, \textcolor{blue}{5}, 13, 15 \} + \end{gather*} + + \end{block} + } + { + We start filling buckets with data blocks greedily from leaves. + We pick those $Z = 3$ blocks from stash which can be placed on the level in path not breaking invariant. + If fewer than $Z$ blocks can be placed, we pad it with dummy blocks. + } + + \exampleFrame% + {Write path back} + { + \selectedtrue% + \pathreadtrue% + \nodeonenewtrue% + \nodetwonewtrue% + } + {\drawTree{Write bucket on level $L - 1 = 2$}} + { + \begin{block}{Stash} + + \begin{gather*} + S^\prime = \{ 2, 10, 15 \} \\ + S = \{ \textcolor{blue}{5}, 13 \} + \end{gather*} + + \end{block} + } + { + We repeat the process for the next level. + } + + \exampleFrame% + {Write path back} + { + \selectedtrue% + \pathreadtrue% + \nodeonenewtrue% + \nodetwonewtrue% + \nodethreenewtrue% + } + {\drawTree{Write bucket on level $L - 2 = 1$}} + { + \begin{block}{Stash} + + \begin{gather*} + S^\prime = \{ 13 \} \\ + S = \{ \textcolor{blue}{5} \} + \end{gather*} + + \end{block} + } + { + Now, only one data block can be placed not breaking the invariant, so we pad. + } + + \exampleFrame% + {Write path back} + { + \selectedtrue% + \pathreadtrue% + \nodeonenewtrue% + \nodetwonewtrue% + \nodethreenewtrue% + \nodefournewtrue% + } + {\drawTree{Write bucket on level $L - 3 = 0$ --- root}} + { + \begin{block}{Stash} + + \begin{gather*} + S^\prime = \{ \textcolor{blue}{5} \} \\ + S = \varnothing + \end{gather*} + + \end{block} + } + { + Finally, we put last block in the root, because it is the only place along the path where $\mathcal{P}(6)$ and $\mathcal{P}(3)$ intersect. + } + + \exampleFrame% + {Final state} + { + \selectedtrue% + \pathreadtrue% + \nodeonenewtrue% + \nodetwonewtrue% + \nodethreenewtrue% + \nodefournewtrue% + } + {\drawTree{Tree after the execution}} + {\drawMap[final]{Position map after the execution}} + { + That is how our tree looks like after the operation. + + Please note that the adversary only sees that we have read whole path and written whole path. + She is not able to see which data block was modified because we re-encrypted everything. + + Keep in mind that it is possible that stash is not empty at the end of operation. + It is unlikely to happen. + The stash is emptied during the next accesses. + } -- GitLab