arnaucube
arnaucube/arnaucube.comPublic Self-hosted repository
arnaucube.com/blog/blind-signatures-ec.html
blog/blind-signatures-ec.htmlRaw
  1<!DOCTYPE html>
  2<html lang="en">
  3
  4  <head>
  5    <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." />
  6    <meta charset="utf-8">
  7    <title> Notes on blind signatures over elliptic curves - arnaucube - blog</title>
  8    <meta name="title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog">
  9    <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.">
 10
 11    <meta property="og:title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog" />
 12    <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." />
 13    <meta property="og:url" content="https://arnaucube.com/blog/blind-signatures-ec.html" />
 14    <meta property="og:type" content="article" />
 15    <meta property="og:image" content="https://arnaucube.com/blog/img/posts/blind-signatures-ec/flow1.png" />
 16    <meta name="twitter:title" content=" Notes on blind signatures over elliptic curves - arnaucube - blog">
 17    <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.">
 18    <meta name="twitter:image" content="https://arnaucube.com/blog/img/posts/blind-signatures-ec/flow1.png">
 19    <meta name="twitter:card" content="summary_large_image">
 20    <meta name="author" content="arnaucube">
 21
 22    <link rel="icon" type="image/png" href="img/logoArnauCubeFavicon.png">
 23
 24    <meta name="viewport" content="width=device-width, initial-scale=1">
 25
 26    <link href="css/bootstrap.min.css" rel="stylesheet">
 27    <link rel="stylesheet" href="css/style.css">
 28
 29    <!-- highlightjs -->
 30    <!-- <link rel="stylesheet" href="js/highlightjs/atom-one-dark.css"> -->
 31    <link rel="stylesheet" href="js/highlightjs/atom-one-light.css">
 32    <!-- <link rel="stylesheet" href="js/highlightjs/gruvbox-dark.css"> -->
 33    <script src="js/highlightjs/highlight.pack.js"></script>
 34
 35    <!-- katex -->
 36    <link rel="stylesheet" href="js/katex/katex.min.css">
 37  <link rel="alternate" type="application/rss+xml" title="arnaucube - blog RSS" href="https://arnaucube.com/blog/rss.xml">
 38</head>
 39
 40  <body>
 41
 42    <!-- o_gradient_background" -->
 43    <nav id="mainNav" class="navbar navbar-default navbar-fixed-top"
 44                      style="height:50px;font-size:100%;">
 45      <div class="container">
 46        <div style="float:left;">
 47        <a href="/blog" style="color:#000;display:inline-block;">blog</a>
 48        <span style="margin-right:20px; margin-left:20px;">|</span>
 49        <a href="/blog/notes.html" style="font-size:90%;color:#000;display:inline-block;">notes</a>
 50        </div>
 51        <div style="float:right;">
 52          <a href="/" style="color:#000;display:inline-block;margin-right:10px;">arnaucube.com</a>
 53          <a href="/blog/rss.xml" target="_blank"
 54            type="application/rss+xml" title="subscribe via RSS" aria-label="subscribe via RSS">
 55              <img width="12px;" src="img/rss.png" />
 56          </a>
 57          <div class="onoffswitch" style="margin-left:0px;display:inline-block;" title="change theme">
 58            <input onclick="switchTheme()" type="checkbox" name="onoffswitch" class="onoffswitch-checkbox"
 59              id="themeSwitcher">
 60            <label class="onoffswitch-label" for="themeSwitcher"></label>
 61          </div>
 62        </div>
 63      </div>
 64      <!-- <img style="height:5px; width:100%; margin-top:8px;" src="img/gradient-line.jpg" /> -->
 65    </nav>
 66
 67
 68
 69    <div class="container" style="margin-top:0px;max-width:800px;">
 70      <h1>Notes on blind signatures over elliptic curves</h1>
 71
 72<p><em>2021-07-30</em></p>
 73
 74<blockquote>
 75<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>
 76</blockquote>
 77
 78<h4>Blind signatures</h4>
 79
 80<p>Few years ago I read about the RSA blind signatures scheme (thanks to <a href="https://futur.upc.edu/JuanHernandezSerrano">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>.
 81The 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>
 82
 83<p><div style="text-align:center; font-size:80%;">
 84    <img style="padding:50px;max-width:100%;" src="img/posts/blind-signatures-ec/flow0.png" />
 85    <i>Diagram showing the described steps.</i>
 86</div>
 87<br></p>
 88
 89<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>
 90
 91<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>
 92
 93<h4>The scheme</h4>
 94
 95<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>
 96
 97<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>
 98
 99<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>
100
101<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>.
102The 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>
103
104<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>
105
106<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>
107
108<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>
109
110<p><div style="text-align:center; font-size:80%;">
111    <img style="padding:50px;max-width:100%;" src="img/posts/blind-signatures-ec/flow1.png" />
112    <i>The previous diagram but with the operations from each step.</i>
113</div>
114<br></p>
115
116<p>From the verification <span class="math inline">\(sG == R + x h(m) Q\)</span>, we can unroll it and check that:</p>
117<p><span class="math display">\[
118\fbox{sG} = (a s' + b) G = (a (d m' + k) + b) G\newline
119= (a d m' + ak + b) G = ((a d (a^{-1} x h(m))) + ak + b) G\newline
120= (d x h(m) + ak + b) G\newline
121= dG x h(m) + (ak + b)G = \fbox{R + x h(m) Q}
122\]</span></p>
123<h4>Code</h4>
124
125<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>
126
127<pre><code class="language-go">import (
128	[...]
129	&quot;github.com/arnaucube/go-blindsecp256k1&quot;
130)
131
132func main() {
133    // signer: create new signer key pair
134    sk := blindsecp256k1.NewPrivateKey()
135    signerPubK := sk.Public()
136
137    // signer: when user requests new R parameter to blind a new msg,
138    // create new signerR (public) with its secret k
139    k, signerR := blindsecp256k1.NewRequestParameters()
140
141    // user: blinds the msg using signer's R
142    msg := new(big.Int).SetBytes([]byte(&quot;test&quot;))
143    msgBlinded, userSecretData, err := blindsecp256k1.Blind(msg, signerR)
144    if err != nil {
145	panic(err)
146    }
147
148    // signer: signs the blinded message using its private key &amp; secret k
149    sBlind, err := sk.BlindSign(msgBlinded, k)
150    if err != nil {
151	panic(err)
152    }
153
154    // user: unblinds the blinded signature
155    sig := blindsecp256k1.Unblind(sBlind, userSecretData)
156
157    // signature can be verified with signer PublicKey
158    verified := blindsecp256k1.Verify(msg, sig, signerPubK)
159    if !verified {
160	fmt.Println(&quot;verification failed&quot;)
161    } else {
162	fmt.Println(&quot;blind signature verified&quot;)
163    }
164}
165</code></pre>
166
167<h4>Conclusions</h4>
168
169<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>
170
171<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>
172
173<p><em>Special thanks to <a href="https://github.com/dhole">@dhole</a> for reviewing this text.</em></p>
174
175<h3>Update 2022-10-29: Schnorr Blind Signatures</h3>
176
177<p><em>2022-10-29</em></p>
178
179<p><a href="https://sites.google.com/site/vincenzoiovinoit/">Vincenzo Iovino</a> recently showed me the paper <a href="https://eprint.iacr.org/2019/877">https://eprint.iacr.org/2019/877</a>, which describes the <em>Blind Schnorr Signature</em>. This subsection describes it. The concepts and parties are the same, the difference is in the values computed.</p>
180
181<p>The public parameters consist of a group <span class="math inline">\(\mathbb{G}\)</span> of order <span class="math inline">\(p\)</span> and generator <span class="math inline">\(G\)</span>, and a cryptographic hash function <span class="math inline">\(\mathcal{H} : \{0,1\}^* \rightarrow \mathbb{Z}_p\)</span>.</p>
182
183<p>The private key of the Signer is a random scalar <span class="math inline">\(x \in \mathbb{Z}_p\)</span> and the corresponding public key is <span class="math inline">\(X = xG\)</span>.</p>
184
185<p>Any User who wants to obtain a signature for some message <span class="math inline">\(m\)</span> without disclosing the content of that message to the Signer proceeds as follows:</p>
186
187<ol>
188<li>The User sends a signing request to the Signer. This request will typically be signed; thus the Signer knows whether the request is legitimate or not.</li>
189<li>If the request is legitimate, the Signer generates a random <span class="math inline">\(r \in \mathbb{Z}_p\)</span>, computes <span class="math inline">\(R = rG\)</span> and sends <span class="math inline">\(R\)</span> to the User.</li>
190<li>The User selects random scalars <span class="math inline">\(\alpha, \beta \in \mathbb{Z}_p\)</span>, computes the \emph{blinding factor} <span class="math inline">\(R' = R + \alpha G + \beta X\)</span>, sets <span class="math inline">\(c = \mathcal{H}(R', m) + \beta \bmod{p}\)</span> and sends <span class="math inline">\(c\)</span> to the Signer.</li>
191<li>The Signer computes <span class="math inline">\(s = r + cx \bmod{p}\)</span> and sends <span class="math inline">\(s\)</span> to the User.</li>
192<li>The User verifies that the value <span class="math inline">\(s\)</span> received is correct by verifying that <span class="math inline">\(sG = R + cX\)</span>. Setting <span class="math inline">\(s' = s + \alpha \bmod{p}\)</span>, the signature of the message <span class="math inline">\(m\)</span> is then <span class="math inline">\(\sigma = (R', s')\)</span>.</li>
193</ol>
194
195<p>Anyone can then verify the validity of the signature by checking the equality <span class="math inline">\(s'G \stackrel{?}{=} R' + \mathcal{H}(R', m)X\)</span>. To see why this must hold, we can unroll the equation:</p>
196<p><span class="math display">\[
197s'G = sG + \alpha G \\
198    = rG + cxG + \alpha G \\
199    = rG + (\mathcal{H}(R', m) + \beta) X + \alpha G \\
200    = R + \alpha G + \beta X + \mathcal{H}(R', m) X \\
201    = R' + \mathcal{H}(R', m) X
202\]</span></p><p>Note that blind Schnorr signatures can be subject to so-called ROS (Random inhomogeneities in a Overdetermined Solvable system of linear equations) attacks, but these attacks can be defended against by forbidding parallel sessions.</p>
203
204<p>An implementation of this scheme in Rust and also in R1CS circuits can be found at <a href="https://github.com/aragonzkresearch/ark-ec-blind-signatures">github.com/aragonzkresearch/ark-ec-blind-signatures</a> . We used this scheme in the <a href="https://github.com/aragonzkresearch/research/blob/main/blind-ovote/blind-ovote.pdf">Blind-OVOTE</a> project, a L2 validity rollup, which uses blind signatures over elliptic curves inside zkSNARK, to provide offchain anonymous voting with onchain binding execution on Ethereum.</p>
205
206    </div>
207
208    <footer style="text-align:center; margin-top:100px;margin-bottom:50px;">
209      <div class="container">
210        <br>
211        <a href="/blog">Go to main</a>
212        <br><br>
213        <div class="row">
214          <ul class="list-inline">
215            <li><a href="https://twitter.com/arnaucube"
216                   style="color:gray;text-decoration:none;"
217                   target="_blank">twitter.com/arnaucube</a>
218            </li>
219            <li><a href="https://github.com/arnaucube"
220                   style="color:gray;text-decoration:none;"
221                   target="_blank">github.com/arnaucube</a>
222            </li>
223          </ul>
224        </div>
225        <div class="row" style="display:inline-block;">
226          Blog made with <a href="http://github.com/arnaucube/blogo/"
227                            target="_blank" style="color: gray;text-decoration:none;">Blogo</a>
228        </div>
229      </div>
230    </footer>
231
232    <script>
233    </script>
234    <script src="js/external-links.js"></script>
235    <script>hljs.initHighlightingOnLoad();</script>
236    <script defer src="js/katex/katex.min.js"></script>
237    <script defer src="js/katex/auto-render.min.js"></script>
238    <script>
239      document.addEventListener("DOMContentLoaded", function() {
240        renderMathInElement(document.body, {
241          displayMode: false,
242          // customised options
243          // • auto-render specific keys, e.g.:
244          delimiters: [
245            {left: '$$', right: '$$', display: true},
246            {left: '$', right: '$', display: false},
247            {left: "\\[", right: "\\]", display: true},
248            {left: "\\(", right: "\\)", display: false},
249            {left: "\\begin{equation}", right: "\\end{equation}", display: true}
250          ],
251          // • rendering keys, e.g.:
252          throwOnError : true
253        });
254      });
255
256      ///
257      let theme = localStorage.getItem("theme");
258      if ((theme === "light-theme")||(theme==null)) {
259          theme = "light-theme";
260          document.getElementById("themeSwitcher").checked = false;
261      } else if (theme === "dark-theme") {
262          theme = "dark-theme";
263          document.getElementById("themeSwitcher").checked = true;
264      }
265      document.body.className = theme;
266      localStorage.setItem("theme", theme);
267
268      function switchTheme() {
269        theme = localStorage.getItem("theme");
270        if (theme === "light-theme") {
271          theme = "dark-theme";
272          document.getElementById("themeSwitcher").checked = true;
273        } else {
274          theme = "light-theme";
275          document.getElementById("themeSwitcher").checked = false;
276        }
277        document.body.className = theme;
278        localStorage.setItem("theme", theme);
279
280        console.log(theme);
281      }
282    </script>
283    <script>
284    function tagLinks(tagName) {
285      var tags = document.getElementsByTagName(tagName);
286      for (var i=0, hElem; hElem =  tags[i]; i++) {
287        if (hElem.parentNode.className=="row postThumb") {
288          continue;
289        }
290        hElem.id = hElem.innerHTML.toLowerCase().replace(" ", "-");
291        hElem.innerHTML = "<a style='color:black!important;' href='#"+hElem.id+"'>"+hElem.innerHTML+"</a>";
292      }
293    }
294    tagLinks("h2");
295    tagLinks("h3");
296    tagLinks("h4");
297    tagLinks("h5");
298    </script>
299    <script>
300function generateTOC(tocContainerId = "toc") {
301    const tocContainer = document.getElementById(tocContainerId);
302    if (!tocContainer) return;
303
304    const headings = document.querySelectorAll("h2, h3, h4, h5, h6");
305    if (!headings.length) return;
306
307    // Generate IDs if missing
308    headings.forEach((heading, index) => {
309        if (!heading.id) {
310            heading.id =
311                heading.textContent
312                    .trim()
313                    .toLowerCase()
314                    .replace(/[^\w\s-]/g, "")
315                    .replace(/\s+/g, "-") +
316                "-" +
317                index;
318        }
319    });
320
321    const toc = document.createElement("ul");
322    let currentLevel = 1;
323    let currentList = toc;
324    const stack = [toc];
325
326    headings.forEach((heading) => {
327        const level = parseInt(heading.tagName.substring(1), 10);
328
329        const li = document.createElement("li");
330        const a = document.createElement("a");
331
332        a.href = "#" + heading.id;
333        a.textContent = heading.textContent;
334
335        li.appendChild(a);
336
337        if (level > currentLevel) {
338            for (let i = currentLevel; i < level; i++) {
339                const nestedList = document.createElement("ul");
340
341                const lastLi =
342                    currentList.lastElementChild ||
343                    currentList.appendChild(document.createElement("ul"));
344
345                lastLi.appendChild(nestedList);
346
347                stack.push(nestedList);
348                currentList = nestedList;
349            }
350        } else if (level < currentLevel) {
351            for (let i = currentLevel; i > level; i--) {
352                stack.pop();
353            }
354            currentList = stack[stack.length - 1];
355        }
356
357        currentList.appendChild(li);
358        currentLevel = level;
359    });
360
361    tocContainer.innerHTML = "";
362    tocContainer.appendChild(toc);
363}
364
365document.addEventListener("DOMContentLoaded", () => {
366    generateTOC();
367});
368    </script>
369    <script src="js/mermaid.min.js"></script>
370
371  </body>
372</html>
373