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.

268 lines
16 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta name="description" content="In this notes, we will cover the scheme proposed at 'New Blind Signature Schemes Based on the (Elliptic Curve) Discrete Logarithm Problem' paper by Hamid Mala & Nafiseh Nezhadansari." />
  5. <meta charset="utf-8">
  6. <title> Notes on blind signatures over elliptic curves - arnaucube - blog</title>
  7. <meta name="title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog">
  8. <meta name="description" content="In this notes, we will cover the scheme proposed at 'New Blind Signature Schemes Based on the (Elliptic Curve) Discrete Logarithm Problem' paper by Hamid Mala & Nafiseh Nezhadansari.">
  9. <meta property="og:title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog" />
  10. <meta property="og:description" content="In this notes, we will cover the scheme proposed at 'New Blind Signature Schemes Based on the (Elliptic Curve) Discrete Logarithm Problem' paper by Hamid Mala & Nafiseh Nezhadansari." />
  11. <meta property="og:url" content="https://arnaucube.com/blog/blind-signatures-ec.html" />
  12. <meta property="og:type" content="article" />
  13. <meta property="og:image" content="https://arnaucube.com/blog/img/posts/blind-signatures-ec/flow1.png" />
  14. <meta name="twitter:title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog">
  15. <meta name="twitter:description" content="In this notes, we will cover the scheme proposed at 'New Blind Signature Schemes Based on the (Elliptic Curve) Discrete Logarithm Problem' paper by Hamid Mala & Nafiseh Nezhadansari.">
  16. <meta name="twitter:image" content="https://arnaucube.com/blog/img/posts/blind-signatures-ec/flow1.png">
  17. <meta name="twitter:card" content="summary_large_image">
  18. <meta name="author" content="arnaucube">
  19. <link rel="icon" type="image/png" href="img/logoArnauCubeFavicon.png">
  20. <meta name="viewport" content="width=device-width, initial-scale=1">
  21. <link href="css/bootstrap.min.css" rel="stylesheet">
  22. <link rel="stylesheet" href="css/style.css">
  23. <!-- highlightjs -->
  24. <!-- <link rel="stylesheet" href="js/highlightjs/atom-one-dark.css"> -->
  25. <link rel="stylesheet" href="js/highlightjs/atom-one-light.css">
  26. <!-- <link rel="stylesheet" href="js/highlightjs/gruvbox-dark.css"> -->
  27. <script src="js/highlightjs/highlight.pack.js"></script>
  28. <!-- katex -->
  29. <link rel="stylesheet" href="js/katex/katex.min.css">
  30. </head>
  31. <body>
  32. <!-- o_gradient_background" -->
  33. <nav id="mainNav" class="navbar navbar-default navbar-fixed-top"
  34. style="height:50px;font-size:130%;">
  35. <div class="container">
  36. <div style="float:left;">
  37. <a href="/blog" style="color:#000;display:inline-block;">Blog index</a>
  38. <span style="margin-right:20px; margin-left:20px;">|</span>
  39. <a href="/blog/notes.html" style="font-size:90%;color:#000;display:inline-block;">other-notes</a>
  40. </div>
  41. <div style="float:right;">
  42. <a href="/" style="color:#000;display:inline-block;">arnaucube.com</a>
  43. <div class="onoffswitch" style="margin:10px;display:inline-block;" title="change theme">
  44. <input onclick="switchTheme()" type="checkbox" name="onoffswitch" class="onoffswitch-checkbox"
  45. id="themeSwitcher">
  46. <label class="onoffswitch-label" for="themeSwitcher"></label>
  47. </div>
  48. </div>
  49. </div>
  50. <img style="height:5px; width:100%; margin-top:8px;" src="img/gradient-line.jpg" />
  51. </nav>
  52. <div class="container" style="margin-top:40px;max-width:800px;">
  53. <h1>Notes on blind signatures over elliptic curves</h1>
  54. <p><em>2021-07-30</em></p>
  55. <blockquote>
  56. <p><strong>Warning</strong>: I want to state clearly that I&rsquo;m not a mathematician, I&rsquo;m just an amateur on math studying in my free time, and this article is just an attempt to try to sort the notes that I took while reading about the blind signatures over elliptic curves.</p>
  57. </blockquote>
  58. <h4>Blind signatures</h4>
  59. <p>Few years ago I read about the RSA blind signatures scheme (thanks to <a href="https://futur.upc.edu/JuanBautistaHernandezSerrano">Juan Hernández</a> who discovered it to me) and I was amazed on such thing being possible. You can read the step by step of the <em>RSA blind signatures</em> scheme in <a href="https://en.wikipedia.org/wiki/Blind_signature#Blind_RSA_signatures">this Wikipedia article</a>.
  60. The main idea is that one party has a message and blinds it, then sends the blinded message to a signer. The signer generates a signature of that blinded message, who sends it to the initial party, who unblinds the signature, obtaining a valid signature for the original message, while the signer does not know what it is signing, but the signature can be verified for the original message for the signer&rsquo;s public key.</p>
  61. <p><div style="text-align:center; font-size:80%;">
  62. <img style="padding:50px;max-width:100%;" src="img/posts/blind-signatures-ec/flow0.png" />
  63. <i>Diagram showing the described steps.</i>
  64. </div>
  65. <br></p>
  66. <p>This has many applications, one of them could be to authenticate users in a &lsquo;traditional&rsquo; way (by user&amp;password, or by public key &amp; signature) in the Certification Authority (CA), and once the user is authenticated, the user can create a new key pair (ephemeral key), for which public key gets blinded and sent to the CA. The CA performs a blind signature on it, and sends the result back to the user. Then, the user can unblind the signature, and as result has their public key signed by the CA, but the CA does not know which is the public key (but the CA knows that the user while being authenticated by their &lsquo;traditional&rsquo; login, generated a new identity (key pair) and sent the public key blinded to the CA, who blindly signed it and returned the signature back to the user). Then the user has the ephemeral public key which is signed by the CA, and can use it to enter the system authenticating that they are an approved user without revealing which user they are.</p>
  67. <p>As most of the current ongoing protocols are using <em>elliptic curve</em> cryptography instead of <em>RSA</em>, the mentioned <em>RSA blind signatures</em> scheme is not much plugable in the existing systems that use <em>elliptic curve</em> keys. That&rsquo;s why I got interested into reading and learning about schemes that provide blind signatures over <em>elliptic curve</em>.</p>
  68. <h4>The scheme</h4>
  69. <p>In this notes, we will cover the scheme proposed at <em>&ldquo;<a href="https://sci-hub.do/10.1109/ICCKE.2013.6682844">New Blind Signature Schemes Based on the (Elliptic Curve) Discrete Logarithm Problem</a>&rdquo;</em> paper by Hamid Mala &amp; Nafiseh Nezhadansari (thanks to <a href="https://twitter.com/feministPLT">Daira Hopwood</a> who mentioned this paper in a Telegram group).</p>
  70. <p>First of all, the <em>signer</em> generates their key pair by generating a random scalar <span class="math inline">\(d \in \mathbb{Z}_n\)</span> (where <span class="math inline">\(\mathbb{Z}_n\)</span> is the elliptic curve field), which will be the <em>private key</em>. From <span class="math inline">\(d\)</span> they can compute the <em>public key</em> by <span class="math inline">\(Q = dG\)</span>, where <span class="math inline">\(G\)</span> is the generator point of <span class="math inline">\(\mathbb{G}\)</span> (the elliptic curve group).</p>
  71. <p>Appart from their key pair, the <em>signer</em> will generate for each request of signature another random value <span class="math inline">\(k \in \mathbb{Z}_n\)</span>, and its respective <span class="math inline">\(R'=kG\)</span>.</p>
  72. <p>The <em>user</em> has a message <em>m</em> that which they want to get signed by the <em>signer</em> (without the <em>signer</em> knowing the content of <em>m</em>). In order to achieve that, the user will generate a coupe of random values <span class="math inline">\(a, b \in \mathbb{Z}_n\)</span>, and from these parameters will compute the <em>blinding factor</em> <span class="math inline">\(R=aR' + bG = (ak + b)G\)</span>, and as <span class="math inline">\(R\)</span> is a point we can get <span class="math inline">\(R = (x, y)\)</span>.
  73. The user can <em>blind</em> the message by computing <span class="math inline">\(m' = a^{-1} \cdot x \cdot h(m)\)</span>, where <span class="math inline">\(h(m)\)</span> is the hash of the message.</p>
  74. <p>Then, the <em>user</em> sends the <em>blinded message</em> (<span class="math inline">\(m'\)</span>) to the <em>signer</em>, who will perform the <em>blind signature</em> by computing <span class="math inline">\(s' = d m' + k\)</span>, which is sent back to the <em>user</em>.</p>
  75. <p>The <em>user</em> can unblind the signature by <span class="math inline">\(s = a s' + b\)</span>, and the complete signature will be <span class="math inline">\((R, s)\)</span>.</p>
  76. <p>And now, we are in a point where the signature can be verified by a third party for the <em>signer</em>&rsquo;s public key by checking <span class="math inline">\(sG == R + x h(m) Q\)</span>.</p>
  77. <p><div style="text-align:center; font-size:80%;">
  78. <img style="padding:50px;max-width:100%;" src="img/posts/blind-signatures-ec/flow1.png" />
  79. <i>The previous diagram but with the operations from each step.</i>
  80. </div>
  81. <br></p>
  82. <p>From the verification <span class="math inline">\(sG == R + x h(m) Q\)</span>, we can unroll it and check that:</p>
  83. <p><span class="math display">\[
  84. \fbox{sG} = (a s' + b) G = (a (d m' + k) + b) G\newline
  85. = (a d m' + ak + b) G = ((a d (a^{-1} x h(m))) + ak + b) G\newline
  86. = (d x h(m) + ak + b) G\newline
  87. = dG x h(m) + (ak + b)G = \fbox{R + x h(m) Q}
  88. \]</span></p>
  89. <h4>Code</h4>
  90. <p>Here is an example of how this scheme on the <a href="https://en.bitcoin.it/wiki/Secp256k1">secp256k1</a> curve could be used using the implementation from <a href="https://github.com/arnaucube/go-blindsecp256k1">go-blindsecp256k1</a>.</p>
  91. <pre><code class="language-go">import (
  92. [...]
  93. &quot;github.com/arnaucube/go-blindsecp256k1&quot;
  94. )
  95. func main() {
  96. // signer: create new signer key pair
  97. sk := blindsecp256k1.NewPrivateKey()
  98. signerPubK := sk.Public()
  99. // signer: when user requests new R parameter to blind a new msg,
  100. // create new signerR (public) with its secret k
  101. k, signerR := blindsecp256k1.NewRequestParameters()
  102. // user: blinds the msg using signer's R
  103. msg := new(big.Int).SetBytes([]byte(&quot;test&quot;))
  104. msgBlinded, userSecretData, err := blindsecp256k1.Blind(msg, signerR)
  105. if err != nil {
  106. panic(err)
  107. }
  108. // signer: signs the blinded message using its private key &amp; secret k
  109. sBlind, err := sk.BlindSign(msgBlinded, k)
  110. if err != nil {
  111. panic(err)
  112. }
  113. // user: unblinds the blinded signature
  114. sig := blindsecp256k1.Unblind(sBlind, userSecretData)
  115. // signature can be verified with signer PublicKey
  116. verified := blindsecp256k1.Verify(msg, sig, signerPubK)
  117. if !verified {
  118. fmt.Println(&quot;verification failed&quot;)
  119. } else {
  120. fmt.Println(&quot;blind signature verified&quot;)
  121. }
  122. }
  123. </code></pre>
  124. <h4>Conclusions</h4>
  125. <p>Blind signatures are an interesting concept, which can be used in some use cases specially on voting systems. As we&rsquo;ve seen, the math background behind it&rsquo;s not quite complex compared for example to zkSNARKs, and it does not require <a href="https://medium.com/qed-it/diving-into-the-snarks-setup-phase-b7660242a0d7">trusted setups</a>. Although, for most of the cases zkSNARKs have more flexibility, and we could cover similar use cases by proving that the user knows some <em>private key</em> for which the corresponding <em>public key</em> is placed in a leaf of a <em>Merkle Tree</em> for a certain <em>Merkle Root</em> (but this would be out of scope for the current notes).</p>
  126. <p>An implementation of this scheme in Go can be found in: <a href="https://github.com/arnaucube/go-blindsecp256k1">https://github.com/arnaucube/go-blindsecp256k1</a> (and a compatible Typescript implementation <a href="https://github.com/arnaucube/blindsecp256k1-js">blindsecp256k1-js</a>). A next iteration could be to abstract the curve &amp; keys structures, to use the generic Go ones, so other curves and already existing keys could be used with the same code.</p>
  127. <p><em>Special thanks to <a href="https://github.com/dhole">@dhole</a> for reviewing this text.</em></p>
  128. </div>
  129. <footer style="text-align:center; margin-top:100px;margin-bottom:50px;">
  130. <div class="container">
  131. <br>
  132. <a href="/blog">Go to main</a>
  133. <br><br>
  134. <div class="row">
  135. <ul class="list-inline">
  136. <li><a href="https://twitter.com/arnaucube"
  137. style="color:gray;text-decoration:none;"
  138. target="_blank">twitter.com/arnaucube</a>
  139. </li>
  140. <li><a href="https://github.com/arnaucube"
  141. style="color:gray;text-decoration:none;"
  142. target="_blank">github.com/arnaucube</a>
  143. </li>
  144. </ul>
  145. </div>
  146. <div class="row" style="display:inline-block;">
  147. Blog made with <a href="http://github.com/arnaucube/blogo/"
  148. target="_blank" style="color: gray;text-decoration:none;">Blogo</a>
  149. </div>
  150. </div>
  151. </footer>
  152. <script>
  153. </script>
  154. <script src="js/external-links.js"></script>
  155. <script>hljs.initHighlightingOnLoad();</script>
  156. <script defer src="js/katex/katex.min.js"></script>
  157. <script defer src="js/katex/auto-render.min.js"></script>
  158. <script>
  159. document.addEventListener("DOMContentLoaded", function() {
  160. renderMathInElement(document.body, {
  161. displayMode: false,
  162. // customised options
  163. // • auto-render specific keys, e.g.:
  164. delimiters: [
  165. {left: '$$', right: '$$', display: true},
  166. {left: '$', right: '$', display: false},
  167. {left: "\\[", right: "\\]", display: true},
  168. {left: "\\(", right: "\\)", display: false},
  169. {left: "\\begin{equation}", right: "\\end{equation}", display: true}
  170. ],
  171. // • rendering keys, e.g.:
  172. throwOnError : true
  173. });
  174. });
  175. ///
  176. let theme = localStorage.getItem("theme");
  177. if ((theme === "light-theme")||(theme==null)) {
  178. theme = "light-theme";
  179. document.getElementById("themeSwitcher").checked = false;
  180. } else if (theme === "dark-theme") {
  181. theme = "dark-theme";
  182. document.getElementById("themeSwitcher").checked = true;
  183. }
  184. document.body.className = theme;
  185. localStorage.setItem("theme", theme);
  186. function switchTheme() {
  187. theme = localStorage.getItem("theme");
  188. if (theme === "light-theme") {
  189. theme = "dark-theme";
  190. document.getElementById("themeSwitcher").checked = true;
  191. } else {
  192. theme = "light-theme";
  193. document.getElementById("themeSwitcher").checked = false;
  194. }
  195. document.body.className = theme;
  196. localStorage.setItem("theme", theme);
  197. console.log(theme);
  198. }
  199. </script>
  200. <script>
  201. function tagLinks(tagName) {
  202. var tags = document.getElementsByTagName(tagName);
  203. for (var i=0, hElem; hElem = tags[i]; i++) {
  204. if (hElem.parentNode.className=="row postThumb") {
  205. continue;
  206. }
  207. hElem.id = hElem.innerHTML.toLowerCase().replace(" ", "-");
  208. hElem.innerHTML = "<a style='text-decoration:none;color:black;' href='#"+hElem.id+"'>"+hElem.innerHTML+"</a>";
  209. }
  210. }
  211. tagLinks("h2");
  212. tagLinks("h3");
  213. tagLinks("h4");
  214. tagLinks("h5");
  215. </script>
  216. <script src="js/mermaid.min.js"></script>
  217. </body>
  218. </html>