You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
6.5 KiB

  1. \documentclass{article}
  2. \usepackage[utf8]{inputenc}
  3. \usepackage{amsfonts}
  4. \usepackage{amsthm} % theorems structure
  5. \usepackage{enumerate}
  6. \usepackage{hyperref} % links
  7. \usepackage{tikz} % diagrams
  8. \usepackage{pgf-umlsd} % diagrams
  9. \usepackage{amsmath} % arrows
  10. \theoremstyle{definition}
  11. \newtheorem{example}{Example}[section]
  12. \title{Sigma protocol and OR proofs - notes}
  13. \author{arnaucube}
  14. \date{March 2022}
  15. \begin{document}
  16. \maketitle
  17. \begin{abstract}
  18. This document contains the notes taken during the \emph{Cryptography Seminars} given by \href{https://github.com/rbkhmrcr}{Rebekah Mercer}.
  19. \end{abstract}
  20. \tableofcontents
  21. \section{Sigma protocol}
  22. \subsection{The protocol}
  23. Let $q$ be a prime, $q$ a prime divisor in $p-1$, and $g$ and element of order $q$ in $\mathbb{Z}_p^a$. Then we have $G = \langle g \rangle$.
  24. \\
  25. We assume that computationally for a given $A$ it's hard to find $a \in \mathbb{F}$ such that $A = g^a$.
  26. \\
  27. Alice wants to prove that knows the \emph{witness} $w \in \mathbb{F}$, such that the \emph{statement} $X = g^w$, without revealing $w$.
  28. \begin{enumerate}[1.]
  29. \item Alice generates a random $a \xleftarrow{r} \mathbb{F}$, and computes $A=g^a$. And sends $A$ to Bob.
  30. \item Bob generates a challenge $c \xleftarrow{r} \mathbb{F}$, and sends it to Alice.
  31. \item Alice computes $z=a + c \cdot w$, and sends it to Bob.
  32. \item Bob verifies it by checking that $g^z == X^c \cdot A$.
  33. \end{enumerate}
  34. We can unfold Bob's verification and see that:
  35. $$g^z == X^c \cdot A$$
  36. $$g^{a+cw} == g^{wc} g^a$$
  37. $$g^{a+cw} == g^{wc+a}$$
  38. \begin{center}
  39. \begin{sequencediagram}
  40. \newinst[1]{a}{Alice}
  41. \newinst[3]{b}{Bob}
  42. \mess[0]{a}{$A$}{b}
  43. \mess[2]{b}{$c$}{a}
  44. \mess[2]{a}{$z$}{b}
  45. \mess[0]{b}{$ok$}{a}
  46. \end{sequencediagram}
  47. \end{center}
  48. Properties:
  49. \begin{enumerate}[i.]
  50. \item \emph{correctness/completness}: if Alice know the witness for the statement, then they can create a valid proof.
  51. \item \emph{soundness}: if someone does not have knowledge of the witness, can not form a valid proof (verifier will always reject).
  52. \item \emph{zero knowledge}: nobody gains knowledge of anything new with the proof. prior knowledge + proof = prior knowledge
  53. \end{enumerate}
  54. \subsection{Non interactive protocol}
  55. With the \emph{Fiat-Shamir Heuristic}, we model a hash function as a random oracle, thus we can replace Bob's role by a hash function in order to obtain the challenge $c \in \mathbb{F}$.
  56. \\
  57. So, we replace the step 2 from the described protocol by $c = H(X || A)$ (where $H$ is a known hash function).
  58. \subsection{What could go wrong (Simulator)}
  59. If the verifier (Bob) sends $c \in \mathbb{F}$, prior to the prover committed to $A$, the prover could create a proof about a public key which they don't know $w$.
  60. \begin{enumerate}[1.]
  61. \item Bob sends $c \xleftarrow{r} \mathbb{F}$ to Alice
  62. \item Alice generates $z \xleftarrow{r} \mathbb{F}$
  63. \item Alice then computes $A = g^z X^{-c}$, and sends $z, A$ to Bob
  64. \item Bob would check that $g^z == X^c A$ and it would pass the verification, as $g^z== X^c \cdot A \Rightarrow g^z==X^c \cdot g^z X^{-c} \Rightarrow g^z == g^z$.
  65. \end{enumerate}
  66. As we've seen, it's really important the order of the steps, so Alice must commit to $A$ before knowing $c$.\\
  67. This 'fake' proof generation is often called the \emph{simulator} and used for further constructions.
  68. \section{OR proof}
  69. \emph{OR proofs} allows the prover to prove that they know the witness $w$ of one of the two known \emph{public keys} $X_0, X_1 \in \mathbb{F}$, without revealing which one. It uses the construction seen in the \emph{sigma protocols} together with the idea of the \emph{simulator}.
  70. A similar construction is used for $n$ statements in the \emph{ring signatures} scheme (used for example in \emph{Monero}). In our case, we will work with $n=2$.
  71. \subsection{The protocol}
  72. \subsubsection{Simulator}
  73. We can assume that the simulator is a box that for given the inputs $(g, X)$, it will output $(A_s, c_s, z_s)$, such that verification succeeds ($g^{z_s}==X^{c_s} \cdot A_s$).
  74. \begin{center}
  75. \begin{tikzpicture}
  76. \node [draw,
  77. minimum width=2cm,
  78. minimum height=1.2cm,
  79. right=1cm
  80. ] (simulator) {simulator};
  81. \draw[-stealth] ++(-1,0) -- (simulator.west)
  82. node[midway,above]{$g, X$};
  83. \draw[-stealth] (simulator.east) -- ++(+2,0)
  84. node[midway,above]{$A_s, c_s, z_s$};
  85. \end{tikzpicture}
  86. \end{center}
  87. Internally, the simulator computes
  88. $$z_s \xleftarrow{r} \mathbb{F},~c_s \xleftarrow{r} \mathbb{F},~A_s = g^{z_s} \cdot X^{c_s}$$
  89. \subsection{Flow}
  90. For two known \emph{public keys} $X_0, X_1 \in G$, Alice knows $w_b \in \mathbb{F}$, for $b \in \{0, 1\}$, such that $g^{w_b} = X_0$ or $g^{w_b} = X_1$. As we don't know if Alice controls $0$ or $1$, from now on, we will use $b$ and $1-b$.
  91. \\
  92. So, Alice knows $w_b \in \mathbb{F}$ such that $X_b = g^{w_b}$, and does not know $w_{1-b}$ for $X_{1-b}=g^{w_{1-b}}$.
  93. \begin{enumerate}
  94. \item First of all, as in the \emph{Sigma protocol}, Alice generates a random \emph{commitment} $a_b \xleftarrow{r} \mathbb{F}$, and computes $A_b = g^{a_b}$.
  95. \item Then, Alice will run the \emph{simulator} for $1-b$.
  96. \begin{list}{}
  97. \item Sets a random $c_{1-b} \xleftarrow{r} \mathbb{F}$, and runs the simulator with inputs\\$(c_{1-b}, X_{1-b})$, and outputs $(A_{1-b}, c_{1-b}, z_{1-b})$.
  98. \item Remember that internally the \emph{simulator} will set random\\
  99. $z_{1-b}, c_{1-b} \xleftarrow{r} \mathbb{F}$, and compute an $A_{1-b}$ such that\\
  100. $A_{1-b} = g^{z_{1-b}} \cdot X_{1-b}^{c_{1-b}}$.
  101. \end{list}
  102. \item Now, Alice sends $A_b, A_{1-b}$ to Bob
  103. \item And Bob sends back the \emph{challenge} $s \xleftarrow{r} \mathbb{F}$.
  104. \item Alice then splits the challenge $s$ into $c_b, c_{1-b}$, by $s = c_{1-b} \oplus c_b$. So Alice can compute $c_b = s \oplus c_{1-b}$.
  105. \item Then Alice computes $z_b = a_b \cdot w_b + c_b$. And sends to Bob $(c_b, c_{1-b}, z_b, z_{1-b})$.
  106. \item Bob can perform the verification by checking that:
  107. \begin{enumerate}[i.]
  108. \item $s == c_b \oplus c_{1-b}$
  109. \item $g_{z_{1-b}} == A_{1-b} \cdot X_{1-b}^{-c_{1-b}}$
  110. \item $g_{z_b} == A_b \cdot X_b^{-c_b}$
  111. \end{enumerate}
  112. \end{enumerate}
  113. \begin{center}
  114. \begin{sequencediagram}
  115. \newinst[1]{a}{Alice}
  116. \newinst[3]{b}{Bob}
  117. \mess[1]{a}{$A_b, A_{1-b}$}{b}
  118. \mess[1]{b}{$s$}{a}
  119. \mess[1]{a}{$c_b, c_{1-b}, z_b, z_{1-b}$}{b}
  120. \end{sequencediagram}
  121. \end{center}
  122. \section{Resources}
  123. \begin{enumerate}
  124. \item \href{https://cs.au.dk/~ivan/Sigma.pdf}{https://cs.au.dk/~ivan/Sigma.pdf}
  125. \item \emph{Cryptography Made Simple}, Nigel Smart. Section 21.3.
  126. \end{enumerate}
  127. \end{document}