handouts/ho06.tex
changeset 422 abe178b3197e
parent 419 667a39dda86e
child 423 11b46fa92a85
equal deleted inserted replaced
421:38ddbc59325a 422:abe178b3197e
    27 loose as one of a series or forming part of a bound volume,
    27 loose as one of a series or forming part of a bound volume,
    28 which is numbered on the recto or front side only.''
    28 which is numbered on the recto or front side only.''
    29 \end{quote}
    29 \end{quote}
    30 
    30 
    31 \noindent
    31 \noindent
    32 Take the first non-article word in this definition,
    32 Take the first non-small word\footnote{Let's say the, a, an,
       
    33 or, and \ldots fall into the category of small words.} in this definition,
    33 in this case \textit{individual}, and look up the definition
    34 in this case \textit{individual}, and look up the definition
    34 of this word, say
    35 of this word, say
    35 
    36 
    36 \begin{quote}
    37 \begin{quote}
    37 ``a single \textit{human} being as distinct from a group''
    38 ``a single \textit{human} being as distinct from a group''
    38 \end{quote}
    39 \end{quote}
    39 
    40 
    40 \noindent 
    41 \noindent 
    41 In this definition take the second non-article word, that
    42 In this definition take the second non-small word, that
    42 is \textit{human}, and again look up the definition of this 
    43 is \textit{human}, and again look up the definition of this 
    43 word. This will yield
    44 word. This will yield
    44 
    45 
    45 \begin{quote}
    46 \begin{quote}
    46 ``relating to \textit{or} characteristic of humankind''
    47 ``relating to or \textit{characteristic} of humankind''
    47 \end{quote}
    48 \end{quote}
    48 
    49 
    49 \noindent 
    50 \noindent 
    50 You could go on looking up the definition of the third
    51 You could go on looking up the definition of the third
    51 non-article in this definition and so on. But let us assume
    52 non-small word in this definition and so on. But let us assume
    52 you agreed with Bob to stop after three iterations with the
    53 you agreed with Bob to stop after three iterations with the
    53 third non-article word in the last definition, that is
    54 third non-article word in the last definition, that is
    54 \textit{or}. Now, instead of sending to Bob the solution
    55 \textit{or}. Now, instead of sending to Bob the solution
    55 \textit{folio}, you send to him \textit{or}. 
    56 \textit{folio}, you send to him \textit{characteristic}. 
    56 
    57 
    57 How can Bob verify that you know the solution? Well, once he
    58 How can Bob verify that you know the solution? Well, once he
    58 solved it himself, he can use the dictionary and follow the
    59 solved it himself, he can use the dictionary and follow the
    59 same ``trail'' as you did. If the final word agrees with what
    60 same ``trail'' as you did. If the final word agrees with what
    60 you had sent him, he must infer you knew the solution earlier than
    61 you had sent him, he must infer you knew the solution earlier
    61 him. This protocol works like a one-way hash function because
    62 than him. This protocol works like a one-way hash function
    62 \textit{or} does not give any hint as to what was the first
    63 because \textit{characteristic} does not give any hint as to
    63 word was. I leave you to think why this protocol avoids
    64 what was the first word was. I leave you to think why this
    64 articles? 
    65 protocol avoids small words? 
    65 
    66 
    66 After Bob found his solution and verified that according to
    67 After Bob found his solution and verified that according to
    67 the protocol it ``maps'' also to \textit{or}, can he be
    68 the protocol it ``maps'' also to \textit{characteristic}, can
    68 entirely sure no cheating is going on? Not with 100\%
    69 he be entirely sure no cheating is going on? Not with 100\%
    69 certainty. It could have been possible that he was
    70 certainty. It could have been possible that he was given
    70 given \textit{or} as the word, but it derived from a
    71 \textit{characteristic} as the word, but it derived from a
    71 different word. This might seem very unlikely, but at
    72 different word. This might seem very unlikely, but at least
    72 least theoretical it is a possibility. Protocols based on
    73 theoretical it is a possibility. Protocols based on
    73 zero-knowledge proofs will produce a similar result---they
    74 zero-knowledge proofs will produce a similar result---they
    74 give an answer that might be erroneous in a very small number
    75 give an answer that might be erroneous in a very small number
    75 of cases. The point is to iterate them long enough so that
    76 of cases. The point is to iterate them long enough so that the
    76 the theoretical possibility of cheating is negligibly small. 
    77 theoretical possibility of cheating is negligibly small. 
    77 
    78 
    78 By the way, the authors of the paper ``Dismantling Megamos
    79 By the way, the authors of the paper ``Dismantling Megamos
    79 Crypto: Wirelessly Lockpicking a Vehicle Immobilizer'' who
    80 Crypto: Wirelessly Lockpicking a Vehicle Immobilizer'' who
    80 were barred from publishing their results used also a hash to
    81 were barred from publishing their results used also a hash to
    81 prove they did the work and (presumably) managed to get into
    82 prove they did the work and (presumably) managed to get into
    86 method is: yes, we can hide the secret temporarily, but if
    87 method is: yes, we can hide the secret temporarily, but if
    87 somebody else wants to verify it, then the secret has to be
    88 somebody else wants to verify it, then the secret has to be
    88 made public. Bob needs to know that \textit{folio} is the
    89 made public. Bob needs to know that \textit{folio} is the
    89 solution before he can verify the claim of Alice that she had
    90 solution before he can verify the claim of Alice that she had
    90 the solution first. Similarly with the car-crypto paper: we
    91 the solution first. Similarly with the car-crypto paper: we
    91 need to wait until the authors are finally allowed to publish
    92 needed to wait until September 2015 when the authors were
    92 their findings in order to verify the hash. This might happen
    93 finally able to publish their findings in order to verify the
    93 at some point, but equally it might never happen (what for
    94 hash. Zero-knowledge proofs, in contrast, can be immediately
    94 example happens if the authors lose their copy of the paper
    95 checked, even if the secret is not public yet and perhaps
    95 because of a disk failure?). Zero-knowledge proofs, in
    96 never will be.
    96 contrast, can be immediately checked, even if the secret is
       
    97 not public yet and perhaps never will be.
       
    98 
    97 
    99 \begin{figure}
    98 \begin{figure}
   100 \begin{center}
    99 \begin{center}
   101 \addtolength{\fboxsep}{4mm}
   100 \addtolength{\fboxsep}{4mm}
   102 \fbox{\includegraphics[scale=0.4]{../pics/Dismantling_Megamos_Crypto.png}}
   101 \fbox{\includegraphics[scale=0.4]{../pics/Dismantling_Megamos_Crypto.png}}
   155 for example the $B$-segment of the tunnel. If now Bob says she
   154 for example the $B$-segment of the tunnel. If now Bob says she
   156 should emerge from $B$, she is lucky. But if he says she
   155 should emerge from $B$, she is lucky. But if he says she
   157 should emerge from $A$ then Alice is in trouble: Bob will find
   156 should emerge from $A$ then Alice is in trouble: Bob will find
   158 out she does not actually know the secret. So in order to fool
   157 out she does not actually know the secret. So in order to fool
   159 Bob she needs to anticipate his call, and already go into the
   158 Bob she needs to anticipate his call, and already go into the
   160 corresponding tunnel. This of course also does not work.
   159 corresponding tunnel. This of course also does not work, since
   161 Consequently in order to find out whether Alice cheats, Bob
   160 Bob can make any call he wants. Consequently in order to find
   162 just needs to repeat this protocol many times. Each time Alice
   161 out whether Alice cheats, Bob just needs to repeat this
   163 has a chance of $\frac{1}{2}$ to be lucky or being found out.
   162 protocol many times. Each time Alice has a chance of
   164 Iterating this $n$ times means she must be right every time
   163 $\frac{1}{2}$ to be lucky or being found out. Iterating this
   165 and when cheating the probability for this is $\frac{1}{2}^n$.
   164 $n$ times means she must be right every time and when
       
   165 cheating: the probability for this is $\frac{1}{2}^n$, number
       
   166 that for already relatively small $n$, say 10, is incredibly 
       
   167 small.
   166 
   168 
   167 
   169 
   168 There are some interesting observations we can make about 
   170 There are some interesting observations we can make about 
   169 Alibaba's cave and the ZKP protocol between Alice and Bob:
   171 Alibaba's cave and the ZKP protocol between Alice and Bob:
   170 
   172 
   259 graphs, say $G_1$ and $G_2$, using the same idea as in the
   261 graphs, say $G_1$ and $G_2$, using the same idea as in the
   260 example with Alibaba's cave. For this Alice and Bob must
   262 example with Alibaba's cave. For this Alice and Bob must
   261 follow the following protocol:
   263 follow the following protocol:
   262 
   264 
   263 \begin{enumerate}
   265 \begin{enumerate}
   264 \item Alice generates an isomorphic graph $H$ which she
   266 \item Alice generates an isomorphic graph $H$ which she sends 
   265       sends to Bob. 
   267       to Bob (in each iteration she needs to generate a 
   266 \item After receiving $H$, Bob asks Alice either for an
   268       different $H$). 
       
   269 \item
       
   270       After receiving $H$, Bob asks Alice either for an      
   267       isomorphism between $G_1$ and $H$, or $G_2$ and $H$.
   271       isomorphism between $G_1$ and $H$, or $G_2$ and $H$.
   268 \item Alice and Bob repeat this procedure $n$ times.
   272 \item Alice and Bob repeat this procedure $n$ times.
   269 \end{enumerate}
   273 \end{enumerate}
   270 
   274 
   271 \noindent In Step 1 it is important that Alice always 
   275 \noindent In Step 1 it is important that Alice always 
   272 generates a fresh isomorphic graph. As said before, 
   276 generates a fresh isomorphic graph. I let you think what
   273 this is relatively easy to generate by consistently
   277 would happen if Alice sends out twice the same graph $H$.
   274 relabelling nodes. If she started from $G_1$, Alice will 
   278 
   275 have generated
   279 As said before, this is relatively easy to generate by
       
   280 consistently relabelling nodes. If she started from $G_1$,
       
   281 Alice will have generated
   276 
   282 
   277 \begin{equation}
   283 \begin{equation}
   278 H = \sigma'(G_1)\label{hiso}
   284 H = \sigma'(G_1)\label{hiso}
   279 \end{equation}
   285 \end{equation}
   280  
   286  
   321 \end{tabular}
   327 \end{tabular}
   322 \end{center}
   328 \end{center}
   323 
   329 
   324 \noindent As can be seen the protocol runs for some
   330 \noindent As can be seen the protocol runs for some
   325 agreed number of iterations. The $H_i$ Alice needs to 
   331 agreed number of iterations. The $H_i$ Alice needs to 
   326 produce, need to be all distinct. I let you think why?
   332 produce, need to be all distinct. I hope you now know
       
   333 why?
   327 
   334 
   328 It is also crucial that in each iteration, Alice first sends
   335 It is also crucial that in each iteration, Alice first sends
   329 $H_i$ and then Bob can decide which isomorphism he wants:
   336 $H_i$ and then Bob can decide which isomorphism he wants:
   330 either $G_1 \leftrightarrow H_i$ or $G_2 \leftrightarrow H_i$.
   337 either $G_1 \leftrightarrow H_i$ or $G_2 \leftrightarrow H_i$.
   331 If somehow Alice can find out before she committed to $H_i$,
   338 If somehow Alice can find out before she committed to $H_i$,
   352 \begin{enumerate}
   359 \begin{enumerate}
   353 \item Alice generates $n$ isomorphic graphs
   360 \item Alice generates $n$ isomorphic graphs
   354       $H_{1..n}$ (they need to be all distinct)
   361       $H_{1..n}$ (they need to be all distinct)
   355 \item she feeds the $H_{1..n}$ into a hashing function
   362 \item she feeds the $H_{1..n}$ into a hashing function
   356       (for example encoded as as matrix)
   363       (for example encoded as as matrix)
   357 \item she takes the first $n$ bits of the output:
   364 \item she takes the first $n$ bits of the output of the hashing
       
   365       function:
   358       whenever the output is $0$, she shows an isomorphism
   366       whenever the output is $0$, she shows an isomorphism
   359       with $G_1$; for $1$ she shows an isomorphism
   367       with $G_1$; for $1$ she shows an isomorphism
   360       with $G_2$
   368       with $G_2$
   361 \end{enumerate}
   369 \end{enumerate}
   362 
   370 
   363 \noindent The reason why this works and achieves the same
   371 \noindent The reason why this works and achieves the same
   364 goal as the interactive variant is that Alice has no
   372 goal as the interactive variant is that Alice has no
   365 control over the hashing functions. It would be 
   373 control over the hashing function. It would be 
   366 computationally just too hard to assemble a set of
   374 computationally just too hard to assemble a set of
   367 $H_{1..n}$ such that she can force where $0$s and $1$s
   375 $H_{1..n}$ such that she can force where $0$s and $1$s
   368 in the hash values are such that it would pass an external
   376 in the hash values are such that it would pass an external
   369 test. The point is that Alice can publish all this data
   377 test. The point is that Alice can publish all this data
   370 on the comfort of her own web-page, for example, and 
   378 on the comfort of her own web-page, for example, and 
   376 that encoding any secret into a graph-isomorphism, while
   384 that encoding any secret into a graph-isomorphism, while
   377 possible, is awkward. The good news is that in fact
   385 possible, is awkward. The good news is that in fact
   378 any NP problem can be used as part of a ZKP protocol.  
   386 any NP problem can be used as part of a ZKP protocol.  
   379 
   387 
   380 
   388 
   381 \subsubsection*{Using Modular Arithmetic for ZKP Protocols}
   389 \subsubsection*{Using Modular Logarithms for ZKP Protocols}
   382 
   390 
   383 While information can be encoded into graph isomorphisms, it
   391 While information can be encoded into graph isomorphisms, it
   384 is not the most convenient carrier of information. Clearly it
   392 is not the most convenient carrier of information. Clearly it
   385 is much easier to encode information into numbers. Let us look
   393 is much easier to encode information into numbers. Let us look
   386 at zero-knowledge proofs that use numbers as secrets. For this
   394 at zero-knowledge proofs that use numbers as secrets. For this
   391 \begin{center}
   399 \begin{center}
   392 $A^x \equiv B\; mod\; p$
   400 $A^x \equiv B\; mod\; p$
   393 \end{center} 
   401 \end{center} 
   394 
   402 
   395 \noindent holds. The secret Alice tries to keep secret is $x$.
   403 \noindent holds. The secret Alice tries to keep secret is $x$.
   396 \bigskip
   404 The point of the modular logarithm is that it is very hard 
       
   405 from the public data to calculate $x$ (for large primes). 
       
   406 Now the protocol proceeds in three stages:
       
   407 
       
   408 \begin{itemize}
       
   409 \item {\bf Commitment Stage}
       
   410   \begin{enumerate}
       
   411     \item Alice generates $z$ random numbers $r_1, \ldots, r_z$, 
       
   412       all less than $p - 1$. Alice then sends Bob for all 
       
   413       $i = 1,\ldots, z$:
       
   414       \[ h_i = A^{r_i}\; mod\; p\]
       
   415     \item Bob generates $z$ random bits, say $b_1,\ldots, b_z$. He can do this 
       
   416        by flipping $z$ times a coin, for example.
       
   417     \item For each bit $b_i$, Alice sends Bob an $s_i$ where
       
   418 
       
   419       \begin{center}
       
   420       \begin{tabular}{ll}
       
   421       if $b_i = 0$: & $s_i = r_i$\\
       
   422       if $b_i = 1$: & $s_i = (r_i - r_j) \;mod\; (p -1)$\\
       
   423       \end{tabular}
       
   424       \end{center}
       
   425 
       
   426       where $r_j$ is the lowest $j$ where $b_j = 1$.
       
   427  
       
   428     \end{enumerate}
       
   429  \end{itemize}   
       
   430     
       
   431 \noindent For understanding the last step, let $z$ be just 4.
       
   432 We have four random values $r_i$ chosen by Alice and four
       
   433 random bits $b_i$ chosen subsequently by Bob, for example
       
   434   
       
   435   \begin{center}
       
   436   \begin{tabular}{lcccc}
       
   437   $r_i$:\; & 4 & 9 & 1 & 3\\ 
       
   438   $b_i$:\; & 0 & 1 & 0 & 1\\
       
   439   & & $\uparrow$ \\
       
   440   & & $j$
       
   441   \end{tabular}             
       
   442   \end{center}         
       
   443     
       
   444   \noindent The highlighted column is the lowest where $b_i = 
       
   445   1$ (counted from the left). That means $r_j = 9$. The reason
       
   446   for letting Alice choose the random numbers $r_1, \ldots, r_z$
       
   447   will become clear shortly. Next is the confirmation 
       
   448   phase where Bob essentially checks whether Alice has sent
       
   449   him ``correct'' $s_i$ and $h_i$.
       
   450     
       
   451 \begin{itemize}   
       
   452 \item {\bf Confirmation Stage}
       
   453   \begin{enumerate}
       
   454   \item For each $b_i$ Bob checks whether $s_i$ 
       
   455   conform to the protocol
       
   456 
       
   457   \begin{center}
       
   458   \begin{tabular}{ll}
       
   459   if $b_i = 0$: & $A^{s_i} \stackrel{?}{\equiv} h_i\;mod\;p$\\
       
   460   if $b_i = 1$: & $A^{s_i} \stackrel{?}{\equiv} h_i * h_j^{-1}  \;mod\; p$\\
       
   461   \end{tabular}
       
   462   \end{center}
       
   463   \end{enumerate}
       
   464 \end{itemize}
       
   465 
       
   466 \noindent To understand the case for $b_i = 1$, you have 
       
   467 to do the following calculation: 
       
   468 
       
   469 \begin{center}
       
   470 \begin{tabular}{r@{\hspace{1mm}}c@{\hspace{1mm}}l}
       
   471 $A^{s_i}$ & $=$ & $A^{r_i - r_j}$\\ 
       
   472           & $=$ & $A^{r_i} * A^{-r_j}$\\
       
   473           & $=$ & $h_{r_i} * h_{r_j}^{-1}\;mod\;p$   
       
   474 \end{tabular}
       
   475 \end{center}
       
   476 
       
   477 \noindent What is interesting that so far nothing has been 
       
   478 sent about $x$, which is the secret Alice has. Also notice 
       
   479 that Bob does not know $r_j$. He received 
       
   480 
       
   481 \begin{center}
       
   482 $r_j - r_j$,  $r_m - r_j$, \ldots, $r_p - r_j \;mod \;p - 1$ 
       
   483 \end{center}
       
   484 
       
   485 \noindent whenever his corresponding bits were $1$. So Bob
       
   486 does not know $r_j$ and also does not know any $r_i$ where the
       
   487 bit was $1$. Information about the $x$ is sent in the next
       
   488 stage (obviously not revealing $x$).
       
   489 
       
   490 \begin{itemize}   
       
   491 \item {\bf Proving Stage}
       
   492 
       
   493 \begin{enumerate}
       
   494 \item Alice proves she knows $x$, the discrete log of $B$,
       
   495 by sending
       
   496 
       
   497 \begin{center}
       
   498 $s_{z+1} = x - r_j\;mod\;p-1$
       
   499 \end{center}
       
   500 
       
   501 \item Bob confirms
       
   502 
       
   503 \begin{center}
       
   504 $A^{s_{z+1}} \stackrel{?}{\equiv} B * h_j^{-1} \;mod \; p$
       
   505 \end{center}
       
   506 \end{enumerate}
       
   507 \end{itemize}
       
   508 
       
   509 \noindent To understand the last step, you have to do the trick
       
   510 again that 
       
   511 
       
   512 \[A^{s_{z+1}} = A^{x-r_j} = \ldots
       
   513 \]
   397 
   514 
   398 \noindent
   515 \noindent
   399 \ldots still to be completed (for example can be attacked by
   516 which I leave to you.
   400 MITM attacks)
   517 
       
   518 Now the question is how can Alice cheat? In order to cheat she
       
   519 has to coordinate what she sends as $h_i$ in step 1 and $s_i$
       
   520 in step 3 of the commitment stage, and also what to send as
       
   521 $s_{z+1}$ in the proving stage. For the latter of course 
       
   522 Alice does not know $x$, so she just chooses some random 
       
   523 number for $s_{z+1}$ and calculates 
       
   524 
       
   525 \[A^{s_{z+1}}\]
       
   526 
       
   527 \noindent
       
   528 and then solves the equation
       
   529 
       
   530 \[A^{s_{z+1}} \equiv B * y \;mod\;p\]
       
   531 
       
   532 \noindent for $y$. This is easy since no logarithm needs to be
       
   533 computed. If Alice can guess the $j$ where the first 1 will
       
   534 appear in Bob's bit vector, then she sends the inverse of $y$
       
   535 as $h_j$ and 0 as $s_j$. However, notice that when she
       
   536 calculates a solution for $y$ she does not know $r_j$. For this she
       
   537 would need to calculate the modular logarithm
       
   538 
       
   539 
       
   540 \[
       
   541 y \equiv A^{r_j}\;mod\;p
       
   542 \] 
       
   543 
       
   544 \noindent which is hard (see step 1 in the commitment stage).
       
   545 
       
   546 Having settled on what $h_j$ should be, now what should Alice
       
   547 send as the other $h_i$ and other $s_i$? If the $b_i$ happens
       
   548 to be a 1, then the $h_i$ and other $s_i$ need to satisfy the 
       
   549 test
       
   550 
       
   551 \[A^{s_i} \stackrel{?}{\equiv} h_i * h_j^{-1}  \;mod\; p\]
       
   552 
       
   553 \noindent where she has already settled on the value of 
       
   554 $h_j^{-1}$. Lets say she choses $s_i$ at random, then she just 
       
   555 needs to solve
       
   556 
       
   557 \[A^{s_i} \equiv z * h_j^{-1}  \;mod\; p\] 
       
   558 
       
   559 \noindent for $z$. Again that is easy, but it does not allow 
       
   560 us to know $r_i$, because then we would again need to solve
       
   561 a modular logarithm problem. Let us call an $h_i$ which was 
       
   562 solved the easy way as \emph{bogus}. Alice has to produce
       
   563 bogus $h_i$ for all bits that are going to be $1$ in advance!
       
   564 This means she has to guess all the bits correctly. (Yes?)
       
   565 
       
   566 Let us see what happens if she guesses wrongly: Suppose the
       
   567 bit $b_i = 1$ where she thought she will get a 0. Then she has
       
   568 already sent an $h_i$ and $h_j$ and now must find an $s_i$
       
   569 such that 
       
   570 
       
   571 \[A^{s_i} \equiv h_i * h_j^{-1}  \;mod\; p\]
       
   572 
       
   573 \noindent holds. For this remember in calculating $h_i$, she
       
   574 just chose a random $s_i$. Now she has to send a genuine one.
       
   575 But this is of course too hard. If she knew the genuine $r_i$
       
   576 and $r_j$ for $h_i$ and $h_j$, it would be easy (in this case
       
   577 $s_i = r_i - r_j$). But she does not. So she will be found
       
   578 out. If $b_i = 0$, but she thought she will get a 1, then 
       
   579 she has to send a $s_i$ which satisfies
       
   580 
       
   581 \[A^{s_i} \equiv h_i\;mod\;p\]
       
   582 
       
   583 \noindent Again she does not know $r_i$. So it is a too hard 
       
   584 task and she will be found out again.
       
   585 
       
   586 To sum up, in order for Alice to successfully cheat Bob, she
       
   587 needs to guess \emph{all} bits correctly. She has only a
       
   588 $\frac{1}{2^z}$ chance of doing this.
   401 
   589 
   402 \subsubsection*{Further Reading}
   590 \subsubsection*{Further Reading}
   403 
   591 
   404 Make sure you understand what NP problems
   592 Make sure you understand what NP problems
   405 are.\footnote{\url{http://en.wikipedia.org/wiki/NP_(complexity)}} They
   593 are.\footnote{\url{http://en.wikipedia.org/wiki/NP_(complexity)}}
   406 are the building blocks for zero-knowledge proofs.
   594 They are the building blocks for zero-knowledge proofs.
       
   595 Zero-Knowldege proofs are not yet widely used in production
       
   596 systems, but it is slowly gaining ground. One application
       
   597 where they pop up are crypto currencies.
       
   598 
       
   599 If you want to brush up on the modular logarithm problem,
       
   600 the Khan Academy has a nice video:
       
   601 
       
   602 \begin{center}
       
   603 \url{https://www.khanacademy.org/video/discrete-logarithm-problem}
       
   604 \end{center}
   407 
   605 
   408 \end{document}
   606 \end{document}
   409 
   607 
   410 http://blog.cryptographyengineering.com/2014/11/zero-knowledge-proofs-illustrated-primer.html
   608 http://blog.cryptographyengineering.com/2014/11/zero-knowledge-proofs-illustrated-primer.html
   411 
   609