{"componentChunkName":"component---src-templates-post-js","path":"/blog/crypto-club-rewinding-the-prover","result":{"data":{"prevPost":{"html":"<p>So let's talk about digital signatures. Maybe a lot of you have heard what they are, but the key idea is I have some secret, and that secret basically identifies me, you could say. And if I create something using that secret, people are able to know, with some good level of certainty, that I was the one who created that new thing, because only I have that secret.</p>\n<p>If we bring it back to the technical terms: you have a sender. The sender has a secret key. The sender uses the secret key to sign a message, and this produces a signature, and anyone with the sender's public key can verify that the message was signed by the sender.</p>\n<p>There are a few properties that digital signatures preserve.</p>\n<ol>\n<li>Non-repudiation is a big thing. If I do an action, I'm not able to take it back. If I sign something, I can't say that I never signed this. This is pretty important in banks.</li>\n<li>Authenticity. Because only I have the secret key, you can be convinced that this message came from me.</li>\n<li>Integrity. The public key can verify that the message was signed by the sender, so it means that during the process the signature was not changed, because the secret key is tied to the public key.</li>\n</ol>\n<h2 id=\"three-algorithms\" style=\"position:relative;\"><a href=\"#three-algorithms\" aria-label=\"three algorithms permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Three algorithms</h2>\n<p>If we look at how to define the scheme, you can think of it in terms of three algorithms.</p>\n<ul>\n<li>The first algorithm is called a key gen algorithm, or a key generation algorithm, which takes as input the security parameter: how many bits of security we're using in order to generate the public key and the secret key. Let's keep it abstract for now. You get a public key and a secret key.</li>\n<li>Your second algorithm is a signing algorithm. This takes as input the secret key and the message, and the output is a signature.</li>\n<li>Our third algorithm is called verify. Verify takes in the public key, which was generated in the key gen step, and it takes the message, which is also public, because we want to know if this message corresponds to this signature. It outputs either accept or reject.</li>\n</ul>\n<div class=\"dpw-formula\">KeyGen(1<sup>&lambda;</sup>) &rarr; (pk, sk) &nbsp;&nbsp; Sign(sk, m) &rarr; &sigma; &nbsp;&nbsp; Verify(pk, m, &sigma;) &rarr; accept / reject</div>\n<p>When we pass verify the public key, the message, and the output of the signing algorithm on the secret key and that message, the result is accept. This must hold true for any digital signature scheme to be correct. If you are not getting that, then you don't have a correct digital signature scheme.</p>\n<div class=\"dpw-formula\">Verify(pk, m, Sign(sk, m)) = accept</div>\n<h2 id=\"the-more-power-the-adversary-gets-the-more-secure-the-scheme\" style=\"position:relative;\"><a href=\"#the-more-power-the-adversary-gets-the-more-secure-the-scheme\" aria-label=\"the more power the adversary gets the more secure the scheme permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The more power the adversary gets, the more secure the scheme</h2>\n<p>Our goal for a digital signature scheme is that it should not be possible to forge signatures. We have many standards for what a digital signature scheme is secure against. The strongest standard, which gives the adversary the most power to do many things, is called existential unforgeability under chosen message attack (EUF-CMA).</p>\n<p>The more power you give the adversary while still being able to defend against that very powerful adversary, the more secure your scheme is. If our scheme was only secure against an adversary that is not able to do a lot of things, then that's less secure than a scheme where an adversary is able to basically test out, or play around with, this scheme many times and still not be able to break it. That's an important intuition to understand, which carries on for all protocols.</p>\n<h2 id=\"the-game\" style=\"position:relative;\"><a href=\"#the-game\" aria-label=\"the game permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The game</h2>\n<p>Power is usually defined with an interactive game. It's basically how much information we give the adversary and how much information we continue giving.</p>\n<ol>\n<li>It starts between a challenger and an adversary. The challenger calls the KeyGen algorithm and gets the secret key and public key, and he gives the adversary the public key. The adversary has the public key. The challenger keeps the secret key.</li>\n<li>The adversary creates a message, and the challenger signs that message with the secret key and sends back the signature for that message. The adversary is able to do this as many times as they want, but it has to be a different message every time.</li>\n<li>Imagine the adversary has created this whole dossier of messages and signatures. Now, to win, the adversary has to find a new message, which is not one of these, and output a valid signature for that new message. If this gives accept, then the scheme is broken. The adversary wins.</li>\n</ol>\n<p>Without any interaction from the challenger, they have to create another message, which cannot be the same message that already has a signature, and they have to create a valid signature. Now, they can do this however they want. They can even guess. So if you're guessing, that's okay. You have like one in a billion chance of getting it correct, but there's a chance. It's not zero. It's very close to zero. That is what \"not with more than negligible probability\" means. How close to zero depends on the security parameter.</p>\n<div class=\"dpw\" id=\"cc7-guess\">\n  <div class=\"dpw-q\">How lucky would an adversary who just guesses have to be?</div>\n  <div class=\"dpw-controls\">\n    <label class=\"dpw-label\">Security parameter &lambda; (bits) &nbsp; <span class=\"dpw-val\" id=\"cc7g-l\">128</span>\n      <input type=\"range\" id=\"cc7g-s\" min=\"8\" max=\"256\" step=\"1\" value=\"128\" /></label>\n    <label class=\"dpw-label\">Guesses per second &nbsp; <span class=\"dpw-val\" id=\"cc7g-r\">10<sup>12</sup></span>\n      <input type=\"range\" id=\"cc7g-rs\" min=\"0\" max=\"21\" step=\"1\" value=\"12\" /></label>\n  </div>\n  <div class=\"dpw-line\"><span>chance one guess verifies</span><span><b id=\"cc7g-p\"></b></span></div>\n  <div class=\"dpw-line\"><span>expected time to land one forgery</span><span><b id=\"cc7g-t\"></b></span></div>\n  <div class=\"dpw-line\"><span>chance of success within the age of the universe</span><span><b id=\"cc7g-u\"></b></span></div>\n  <div class=\"dpw-verdict\" id=\"cc7g-v\"></div>\n  <div class=\"dpw-hint\">The adversary only gets one call to Verify in the real game. This widget is generous: it lets them keep guessing. Age of the universe taken as 1.38 &times; 10<sup>10</sup> years.</div>\n</div>\n<p>Just think of it like signing checks at a bank. You do a signature and then you deposit the check or take money out. What I have the ability to do is look at that check as many times as I want, basically study your signature. And then the hundredth time I forge your signature and I go to the bank and pretend I'm you. If I'm able to do that, then I basically forged your signature, which is the whole point of the scheme. I should not be able to forge signatures.</p>\n<h2 id=\"the-adversary-doesnt-need-your-secret-key\" style=\"position:relative;\"><a href=\"#the-adversary-doesnt-need-your-secret-key\" aria-label=\"the adversary doesnt need your secret key permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The adversary doesn't need your secret key</h2>\n<p>I don't need to have your secret key, because if you look at this verify function, it only requires the public key, which is public knowledge, and the message-signature pair. If I can make these message-signature pairs follow the same distribution as the ones that are correct, then I win. I don't even need to know your secret key.</p>\n<p>Notice here the requirement was not \"when you create this signature, you have to use sign.\" I never said that. I'll just create some other function, fake sign, that takes in all my knowledge about what I learned from all of your interactions. The adversary just needs to create a valid message-signature pair. Like I said, they could even guess it. We don't care if they actually use sign.</p>\n<p>There are two ways this could be accepted. One is the secret key was compromised. That's one case where I can always create valid signatures. The other way is: forget about the secret key. Learn about message-signature pairs enough to create your own message-signature pair.</p>\n<p>You shouldn't take it for granted or assume that once a private key is generated, it's always safe and secure. There are ways to learn maybe bits of information about the private key, or maybe break it down into easier problems, and then solve for the private key.</p>\n<h2 id=\"a-forgery-against-a-scheme-where-signatures-add-up\" style=\"position:relative;\"><a href=\"#a-forgery-against-a-scheme-where-signatures-add-up\" aria-label=\"a forgery against a scheme where signatures add up permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>A forgery against a scheme where signatures add up</h2>\n<p>Someone in the room gave an example of the second way: suppose the scheme has the property that the signature of m<sub>1</sub> + m<sub>2</sub> is σ<sub>1</sub> + σ<sub>2</sub>. That's a much better explanation. If I just recap:</p>\n<p>Step 1. We got two messages. Adversary said, \"Hey, sign this message,\" and the challenger signed it. Adversary said, \"Hey, sign this message,\" and the challenger signed it.</p>\n<p>Step 2. Knowing these message-signature pairs, I tried to basically calculate: what could the formula actually be, where our signatures are created? So I try adding up the messages, and I realized that if I also add up the signatures, the sum of the signatures is the signature of the sum of the messages. This is my hypothesis.</p>\n<p>Step 3. So now I ask for signature three with the challenger, and he gives me signature three, and I check this against what I hypothesized. And indeed it turns out that it was what I thought it was going to be.</p>\n<p>Step 4. So now I can stop the interaction here. I can cut off my interaction with the challenger, and I can say, \"Hey, I'm ready for the test.\" For the message, I'm going to choose m<sub>4</sub>, which, if you notice, we never chose. We chose m<sub>1</sub>, m<sub>2</sub> and m<sub>3</sub>. Those are the only three messages we asked about. So m<sub>4</sub> = m<sub>1</sub> + m<sub>3</sub>, and σ<sub>4</sub> = σ<sub>1</sub> + σ<sub>3</sub>.</p>\n<div class=\"dpw-formula\">Verify(pk, m<sub>1</sub> + m<sub>3</sub>, &sigma;<sub>1</sub> + &sigma;<sub>3</sub>) &rarr; accept</div>\n<p>So here we didn't even calculate anything ourselves. We just gave the addition of things we already had stored. And this should give accept.</p>\n<div class=\"dpw\" id=\"cc7-forge\">\n  <div class=\"dpw-q\">If signatures add up, how many messages can you sign after asking for only a few?</div>\n  <div class=\"dpw-detail-b\">You are the adversary. The challenger holds a secret key and signs with a scheme where &sigma;(a + b) = &sigma;(a) + &sigma;(b). Ask for signatures on messages from 1 to 99, then sit the test.</div>\n  <div class=\"dpw-toggle-row\" style=\"margin-top:12px\">\n    <input class=\"dpw-input\" id=\"cc7f-m\" type=\"number\" min=\"1\" max=\"99\" value=\"7\" aria-label=\"message to query\" />\n    <button class=\"dpw-toggle\" id=\"cc7f-ask\">ask challenger to sign</button>\n    <button class=\"dpw-toggle\" id=\"cc7f-rand\">ask a random one</button>\n    <button class=\"dpw-toggle\" id=\"cc7f-reset\">new key</button>\n  </div>\n  <div class=\"dpw-cap\" style=\"margin-top:8px\">your dossier (m &rarr; &sigma;)</div>\n  <div class=\"dpw-chips\" id=\"cc7f-dos\"></div>\n  <div class=\"dpw-readout\">\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc7f-q\">0</span><span class=\"dpw-cap\">signatures asked for</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc7f-n\">0</span><span class=\"dpw-cap\">new messages you can now sign</span></div>\n  </div>\n  <div class=\"dpw-cap\" style=\"margin-top:10px\">messages you never asked about, but can sign by adding</div>\n  <div class=\"dpw-chips\" id=\"cc7f-forge\"></div>\n  <div class=\"dpw-toggle-row\" style=\"margin-top:12px\">\n    <span class=\"dpw-toggle-cap\">The test: pick a new message and forge its signature without the challenger</span>\n    <input class=\"dpw-input\" id=\"cc7f-t\" type=\"number\" min=\"1\" value=\"10\" aria-label=\"message to forge\" />\n    <button class=\"dpw-toggle\" id=\"cc7f-go\">forge &amp; verify</button>\n  </div>\n  <div class=\"dpw-verdict dpw-neutral\" id=\"cc7f-v\">Ask for a few signatures first.</div>\n  <div class=\"dpw-hint\">Messages are combined by adding distinct messages from your dossier, each at most once, exactly like m<sub>4</sub> = m<sub>1</sub> + m<sub>3</sub>. With n queries there are up to 2<sup>n</sup> &minus; 1 &minus; n new sums, so every signature you ask for roughly doubles what you can forge.</div>\n</div>\n<p>Here I'm just saying secret key and public key, but we'll look at actual digital signature protocols, with real formulas.</p>\n<style>\n.dpw-formula { text-align: center; font-family: 'Inconsolata', monospace; font-size: 17px;\n  color: #1b2228; margin: 22px 0; letter-spacing: .01em; line-height: 1.6; overflow-x: auto; }\n.dpw-formula sup, .dpw-formula sub { font-size: 11px; }\n.dpw {\n  --ink: #1b2228; --ink2: #5b7085; --line: #dae4ed;\n  --maroon: #a72e2b; --maroon-d: #6a1d1b; --rose: #f2cdcc; --green: #3f8f5b; --slate: #8ba2b8;\n  border: 1px solid var(--line); border-radius: 6px; padding: 20px;\n  margin: 32px 0; background: #fff; font-family: 'Open Sans', sans-serif; color: var(--ink);\n}\n.dpw * { box-sizing: border-box; }\n.dpw-q { font-family: 'Josefin Sans', sans-serif; font-size: 14px; text-transform: uppercase; letter-spacing: .04em;\n  color: var(--maroon-d); margin: 0 0 12px; line-height: 1.4; }\n.dpw-controls { margin-bottom: 14px; display: grid; gap: 12px; }\n.dpw-label { display: block; font-size: 13px; color: var(--ink2); }\n.dpw-label input[type=range] { display: block; width: 100%; margin: 8px 0 0; accent-color: var(--maroon); }\n.dpw-val { color: var(--maroon-d); font-family: 'Inconsolata', monospace; font-weight: 700; }\n.dpw-hint { font-size: 12px; color: var(--ink2); margin-top: 10px; font-style: italic; line-height: 1.55; }\n.dpw-svg { width: 100%; height: auto; display: block; margin: 6px 0 4px;\n  background: linear-gradient(180deg, #fbfcfe, #f4f7fa); border-radius: 4px; }\n.dpw-verdict { margin: 10px 0 4px; padding: 8px 12px; border-radius: 4px; font-size: 13px; font-weight: 700;\n  background: var(--rose); color: var(--maroon-d); text-align: center; font-family: 'Inconsolata', monospace; }\n.dpw-verdict.dpw-ok { background: #dcefe3; color: var(--green); }\n.dpw-verdict.dpw-neutral { background: #e3ecf4; color: #3d566b; }\n.dpw-readout { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }\n.dpw-stat { display: flex; flex-direction: column; }\n.dpw-num { font-family: 'Josefin Sans', sans-serif; font-size: 23px; color: var(--maroon-d); line-height: 1.15; }\n.dpw-cap { font-size: 11px; color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; }\n/* variable names keep their case inside the upper-cased captions */\n.dpw-cap .dpw-var { text-transform: none; font-size: inherit; line-height: inherit; font-family: inherit; }\n.dpw-toggle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }\n.dpw-toggle-cap { width: 100%; margin-bottom: 3px; font-size: 12px; color: var(--ink2); }\n.dpw-toggle { font-family: 'Inconsolata', monospace; font-size: 12px; border: 1px solid var(--line);\n  background: #fff; color: var(--ink2); padding: 5px 9px; border-radius: 4px; cursor: pointer; transition: all .15s; }\n.dpw-toggle[data-on=true] { background: var(--maroon); color: #fff; border-color: var(--maroon); }\n.dpw-toggle:disabled { opacity: .45; cursor: default; }\n.dpw-detail { border: 1px solid var(--line); border-radius: 5px; padding: 13px 14px; margin-top: 10px; }\n.dpw-detail-h { font-family: 'Josefin Sans', sans-serif; font-size: 13px; text-transform: uppercase;\n  letter-spacing: .04em; color: var(--maroon-d); margin-bottom: 7px; }\n.dpw-detail-b { font-size: 13px; color: var(--ink2); line-height: 1.6; }\n.dpw-line { font-size: 13px; color: var(--ink2); margin: 9px 0; display: flex; justify-content: space-between;\n  align-items: baseline; gap: 10px; flex-wrap: wrap; }\n.dpw-line b { font-family: 'Inconsolata', monospace; font-size: 15px; color: var(--ink); font-weight: 700; }\n.dpw-mono { font-family: 'Inconsolata', monospace; }\n.dpw-input { font-family: 'Inconsolata', monospace; font-size: 14px; border: 1px solid var(--line); border-radius: 4px;\n  padding: 5px 8px; width: 80px; color: var(--ink); }\n.dpw-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }\n.dpw-chip { font-family: 'Inconsolata', monospace; font-size: 12px; padding: 3px 7px; border-radius: 3px;\n  background: #f4f7fa; border: 1px solid var(--line); color: var(--ink); }\n.dpw-chip.dpw-chip-hot { background: #dcefe3; border-color: #b9dcc5; color: var(--green); }\n.dpw-chip.dpw-chip-bad { background: var(--rose); border-color: #e7b3b1; color: var(--maroon-d); }\n.dpw-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n.dpw-table { width: 100%; border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; }\n.dpw-table td, .dpw-table th { padding: 5px 6px; border-bottom: 1px solid #eef3f7; text-align: left; }\n/* table headers hold maths: f(3) must not become F(3) */\n.dpw-table th { font-size: 11px; color: var(--ink2); text-transform: none; letter-spacing: .04em; font-weight: 600; }\n.dpw-table td.dpw-mono { white-space: nowrap; }\n@media (max-width: 560px) { .dpw { padding: 14px; } .dpw-grid2 { grid-template-columns: 1fr; } .dpw-readout { gap: 16px; } }\n@media (prefers-reduced-motion: reduce) { .dpw * { transition: none !important; } }\n</style>\n<script>\n(function () {\n  var root = document.getElementById('cc7-guess');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var $ = function (id) { return root.querySelector('#' + id); };\n  var LOG10_2 = Math.log10(2), YEAR = 3.156e7, UNIVERSE = 1.38e10;\n  function pow10(e) {\n    if (e > -4 && e < 6) { var v = Math.pow(10, e); return v >= 100 ? Math.round(v).toLocaleString() : v.toPrecision(3); }\n    var ex = Math.floor(e), m = Math.pow(10, e - ex);\n    return m.toFixed(1) + ' &times; 10<sup>' + ex + '</sup>';\n  }\n  function dur(log10s) {\n    var u = [['seconds', 0], ['minutes', Math.log10(60)], ['hours', Math.log10(3600)], ['days', Math.log10(86400)], ['years', Math.log10(YEAR)]];\n    var pick = u[0];\n    u.forEach(function (x) { if (log10s >= x[1]) pick = x; });\n    return pow10(log10s - pick[1]) + ' ' + pick[0];\n  }\n  function draw() {\n    var l = +$('cc7g-s').value, r = +$('cc7g-rs').value;\n    $('cc7g-l').textContent = l;\n    $('cc7g-r').innerHTML = r === 0 ? '1' : '10<sup>' + r + '</sup>';\n    var lp = -l * LOG10_2;\n    $('cc7g-p').innerHTML = '2<sup>&minus;' + l + '</sup> &asymp; ' + pow10(lp);\n    var lt = (l - 1) * LOG10_2 - r;\n    $('cc7g-t').innerHTML = dur(lt);\n    var lu = Math.log10(UNIVERSE * YEAR) + r + lp;\n    $('cc7g-u').innerHTML = lu >= -0.0001 ? 'essentially certain' : pow10(lu);\n    var v = $('cc7g-v');\n    var years = lt - Math.log10(YEAR);\n    if (years < 0) { v.className = 'dpw-verdict'; v.innerHTML = 'broken: a guesser forges in under a year'; }\n    else if (years < Math.log10(UNIVERSE)) { v.className = 'dpw-verdict'; v.innerHTML = 'too small: a patient guesser gets there'; }\n    else { v.className = 'dpw-verdict dpw-ok'; v.innerHTML = 'negligible: guessing is not a strategy'; }\n  }\n  on($('cc7g-s'), 'input', draw); on($('cc7g-rs'), 'input', draw);\n  draw();\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc7-forge');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var $ = function (id) { return root.querySelector('#' + id); };\n  var sk, dos, sums;\n  function sign(m) { return sk * m; }\n  function reset() {\n    sk = 101 + Math.floor(Math.random() * 800);\n    dos = []; recompute();\n    var v = $('cc7f-v'); v.className = 'dpw-verdict dpw-neutral'; v.innerHTML = 'Ask for a few signatures first.';\n  }\n  function recompute() {\n    // every sum of distinct dossier messages, remembering which ones it used\n    sums = {};\n    var asked = {};\n    dos.forEach(function (d) { asked[d.m] = true; });\n    var n = dos.length;\n    for (var mask = 1; mask < (1 << n); mask++) {\n      var m = 0, s = 0, parts = [];\n      for (var i = 0; i < n; i++) if (mask & (1 << i)) { m += dos[i].m; s += dos[i].s; parts.push(i); }\n      if (!asked[m] && !(m in sums)) sums[m] = { s: s, parts: parts };\n    }\n    var keys = Object.keys(sums).map(Number).sort(function (a, b) { return a - b; });\n    $('cc7f-q').textContent = n;\n    $('cc7f-n').textContent = keys.length;\n    $('cc7f-dos').innerHTML = dos.length ? dos.map(function (d) {\n      return '<span class=\"dpw-chip\">' + d.m + ' &rarr; ' + d.s + '</span>'; }).join('') : '<span class=\"dpw-hint\">empty</span>';\n    var shown = keys.slice(0, 120);\n    $('cc7f-forge').innerHTML = keys.length ? shown.map(function (k) { return '<span class=\"dpw-chip dpw-chip-hot\">' + k + '</span>'; }).join('') +\n      (keys.length > shown.length ? '<span class=\"dpw-chip\">+' + (keys.length - shown.length) + ' more</span>' : '') :\n      '<span class=\"dpw-hint\">nothing yet: you need at least two signatures to add</span>';\n  }\n  function ask(m) {\n    m = Math.round(m);\n    if (!(m >= 1 && m <= 99)) return;\n    if (dos.some(function (d) { return d.m === m; })) {\n      var v = $('cc7f-v'); v.className = 'dpw-verdict dpw-neutral';\n      v.innerHTML = 'Already in your dossier. The game wants a different message every time.'; return;\n    }\n    if (dos.length >= 12) { var w = $('cc7f-v'); w.className = 'dpw-verdict dpw-neutral'; w.innerHTML = '12 queries is plenty for this demo.'; return; }\n    dos.push({ m: m, s: sign(m) }); recompute();\n  }\n  on($('cc7f-ask'), 'click', function () { ask(+$('cc7f-m').value); });\n  on($('cc7f-rand'), 'click', function () {\n    var tries = 0, m;\n    do { m = 1 + Math.floor(Math.random() * 99); tries++; } while (dos.some(function (d) { return d.m === m; }) && tries < 500);\n    $('cc7f-m').value = m; ask(m);\n  });\n  on($('cc7f-reset'), 'click', reset);\n  on($('cc7f-go'), 'click', function () {\n    var t = Math.round(+$('cc7f-t').value), v = $('cc7f-v');\n    if (!(t >= 1)) return;\n    if (dos.some(function (d) { return d.m === t; })) {\n      v.className = 'dpw-verdict dpw-neutral'; v.innerHTML = 'You asked for ' + t + ' already, so it does not count as a forgery.'; return;\n    }\n    if (t in sums) {\n      var f = sums[t];\n      var ms = f.parts.map(function (i) { return 'm=' + dos[i].m; }).join(' + ');\n      var ss = f.parts.map(function (i) { return dos[i].s; }).join(' + ');\n      var ok = f.s === sign(t);\n      v.className = ok ? 'dpw-verdict' : 'dpw-verdict dpw-ok';\n      v.innerHTML = '' + ms + ' = ' + t + ', so &sigma;* = ' + ss + ' = ' + f.s + '. Verify &rarr; ' + (ok ? 'ACCEPT. Forged, and you never touched the secret key.' : 'reject') + '';\n    } else {\n      var guess = 101 * t + Math.floor(Math.random() * 800 * t);\n      var hit = guess === sign(t);\n      v.className = hit ? 'dpw-verdict' : 'dpw-verdict dpw-ok';\n      v.innerHTML = '' + t + ' is not a sum of your messages, so you have to guess. Guessed &sigma;* = ' + guess + '. Verify &rarr; ' + (hit ? 'ACCEPT (lucky!)' : 'reject') + '';\n    }\n  });\n  reset();\n  [7, 12].forEach(ask);\n})();\n</script>","headings":[{"value":"Three algorithms","depth":2},{"value":"The more power the adversary gets, the more secure the scheme","depth":2},{"value":"The game","depth":2},{"value":"The adversary doesn't need your secret key","depth":2},{"value":"A forgery against a scheme where signatures add up","depth":2}],"frontmatter":{"date_created":"2026-09-18","path":"/blog/crypto-club-forging-without-the-key","tags":["Cryptography","Bitcoin","Digital Signatures"],"title":"Forging A Signature Without The Secret Key"}},"currPost":{"html":"<p>Notice how a lot of these schemes assume that this problem, the discrete log problem, is hard to solve. If someone comes up with an easy solution, then all of a sudden private keys can be computed easily. All of a sudden transactions can be signed easily, because we would be able to create a forgery of the signature.</p>\n<p>Before I talk about the actual signature scheme, we'll look at what was first discovered. The Schnorr digital signature scheme came after something called the Schnorr proof of knowledge. And this is modelled, again, as an interactive game, similar to how we saw this game between a challenger and an adversary. The goal is for a prover to prove to a verifier that they know a secret X without revealing X.</p>\n<h2 id=\"peter-and-veronica\" style=\"position:relative;\"><a href=\"#peter-and-veronica\" aria-label=\"peter and veronica permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Peter and Veronica</h2>\n<p>We have the discrete log problem, which is Y = G<sup>X</sup> mod P, where P is a prime. This Y will be our public key, and this X will be our secret key. And we basically want to prove to someone that we possess this X without showing them X. So you're proving that you have knowledge of X. You're not showing X, though.</p>\n<p>Q is a large prime, so that's public info. The generator, everyone knows. The generator is also a public parameter. Let's give them names: the prover is Peter, and V is Veronica.</p>\n<ol>\n<li>We randomly pick a secret value X from the set of integers up to Q, so this is from 0 to Q − 1. And then we calculate our public key, Y = G<sup>X</sup>. We know that if we just give Veronica a Y, it's very hard for her to get the X from this.</li>\n<li>Peter gives Veronica the output, Y. And he also creates another random value. Think of this as two steps. This random value is again from the same field. We're just going to create a random R as well, which also comes from Z<sub>Q</sub>. I'll just call this α = G<sup>R</sup>. And then we send both Y and α to Veronica.</li>\n<li>Veronica picks a random value C too, from the same field, and she sends it over to Peter.</li>\n<li>Then we just do this calculation: S = R + X·C mod Q. And then we send the output S to Veronica.</li>\n<li>What does she know right now? She knows Y, she knows α, and she just got S. So based on these values that she got, she checks if G<sup>S</sup> equals α · Y<sup>C</sup>.</li>\n</ol>\n<div class=\"dpw-formula\">s = r + x&middot;c mod q &nbsp;&nbsp;&nbsp;&nbsp; g<sup>s</sup> &#8799; &alpha; &middot; y<sup>c</sup></div>\n<p>Why does this work? If we try to expand this equation: α is G<sup>R</sup>, and Y is G<sup>X</sup>, so Y<sup>C</sup> is (G<sup>X</sup>)<sup>C</sup>. When we raise a power to a power, we multiply the exponents, and when we multiply powers of the same base, we add the exponents. So the right side becomes G<sup>R + XC</sup>. And if you notice, S was also exactly this, R + XC. So it's basically checking if G<sup>R + XC</sup> is equal to G<sup>R + XC</sup>. But obviously, they don't see this X. They're just computing on the actual output.</p>\n<p>R is supposed to be like a masking factor. If we didn't have R, and we just sent X·C mod Q, Veronica is the one who gave C, so she might be able to calculate what X is. But if we mask this whole equation with a random value, then X stays hidden, which is our secret key. We don't want Veronica to know the secret key. We just need her to know that I have this key.</p>\n<p>And why is she sending C? We need another party to send another random value. Otherwise, Peter could just create an equation that would satisfy this property without actually knowing X. So there has to be some input given to Peter that is not something he himself calculated. Both prover and verifier have skin in the game, because the verifier is the one who's controlling the C, and the prover is the one who's controlling these things.</p>\n<div class=\"dpw\" id=\"cc8-pok\">\n  <div class=\"dpw-q\">Run it: does Veronica's check pass, and does she ever see x?</div>\n  <div class=\"dpw-detail-b\">Toy parameters: p = 2039, q = 1019, g = 4 (g has order q mod p). Real Schnorr uses 256-bit numbers; the algebra is identical.</div>\n  <div class=\"dpw-toggle-row\" style=\"margin-top:12px\">\n    <button class=\"dpw-toggle\" id=\"cc8p-new\">new secret x</button>\n    <button class=\"dpw-toggle\" id=\"cc8p-show\" data-on=\"false\">peek at x</button>\n  </div>\n  <div class=\"dpw-grid2\">\n    <div>\n      <div class=\"dpw-cap\">Peter (prover)</div>\n      <div class=\"dpw-line\"><span>secret x</span><span><b id=\"cc8p-x\">hidden</b></span></div>\n      <div class=\"dpw-line\"><span>y = g<sup>x</sup> mod p</span><span><b id=\"cc8p-y\"></b></span></div>\n      <div class=\"dpw-line\"><span>mask r</span><span><b id=\"cc8p-r\">hidden</b></span></div>\n      <div class=\"dpw-line\"><span>&alpha; = g<sup>r</sup> mod p</span><span><b id=\"cc8p-a\"></b></span></div>\n    </div>\n    <div>\n      <div class=\"dpw-cap\">Veronica (verifier)</div>\n      <label class=\"dpw-label\">challenge c &nbsp; <span class=\"dpw-val\" id=\"cc8p-cv\"></span>\n        <input type=\"range\" id=\"cc8p-c\" min=\"0\" max=\"1018\" step=\"1\" value=\"300\" /></label>\n      <div class=\"dpw-line\"><span>s = r + x&middot;c mod q</span><span><b id=\"cc8p-s\"></b></span></div>\n      <div class=\"dpw-line\"><span>g<sup>s</sup> mod p</span><span><b id=\"cc8p-l\"></b></span></div>\n      <div class=\"dpw-line\"><span>&alpha;&middot;y<sup>c</sup> mod p</span><span><b id=\"cc8p-rr\"></b></span></div>\n    </div>\n  </div>\n  <div class=\"dpw-verdict dpw-ok\" id=\"cc8p-v\"></div>\n  <div class=\"dpw-hint\">Veronica only ever sees y, &alpha;, c and s. Drag the challenge: s moves all over the field, the check passes every time, and x is never sent.</div>\n</div>\n<h2 id=\"three-things-to-prove\" style=\"position:relative;\"><a href=\"#three-things-to-prove\" aria-label=\"three things to prove permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Three things to prove</h2>\n<p>With a proof of knowledge, we have to show three things.</p>\n<ul>\n<li>Completeness means an honest prover plus an honest verifier always pass the check. There shouldn't be a bug in the code where, even if we're always honest, sometimes it says you failed.</li>\n<li>Soundness means a dishonest prover, being someone who actually doesn't know X, fails the check every time, except with negligible probability. There might be a fluke once in a while, because all of these values are chosen randomly. So there is a chance of one over the order of the field that they might get it correct.</li>\n<li>Zero knowledge means that nothing about the private information, which is X in this case, leaks to the verifier. The whole point is for us to not show Veronica X.</li>\n</ul>\n<p>For completeness, I showed you how this check works during the honest case, which is the easy case.</p>\n<div class=\"dpw\" id=\"cc8-cheat\">\n  <div class=\"dpw-q\">How often does a Peter who does not know x get through?</div>\n  <div class=\"dpw-detail-b\">A cheating Peter's best move: guess the challenge c* in advance, pick any s, and send &alpha; = g<sup>s</sup>&middot;y<sup>&minus;c*</sup>. If Veronica happens to send c*, the check passes. Every run below is the real modular arithmetic.</div>\n  <div class=\"dpw-toggle-row\" style=\"margin-top:12px\">\n    <span class=\"dpw-toggle-cap\">group size q</span>\n    <button class=\"dpw-toggle\" data-q=\"11\" data-on=\"true\">q = 11</button>\n    <button class=\"dpw-toggle\" data-q=\"1019\" data-on=\"false\">q = 1019</button>\n    <button class=\"dpw-toggle\" data-q=\"big\" data-on=\"false\">q &asymp; 2<sup>256</sup></button>\n  </div>\n  <div class=\"dpw-toggle-row\">\n    <span class=\"dpw-toggle-cap\">who picks the challenge?</span>\n    <button class=\"dpw-toggle\" id=\"cc8c-v\" data-on=\"true\">Veronica, at random</button>\n    <button class=\"dpw-toggle\" id=\"cc8c-p\" data-on=\"false\">Peter, himself</button>\n  </div>\n  <div class=\"dpw-toggle-row\">\n    <button class=\"dpw-toggle\" id=\"cc8c-run\">run 10,000 cheating attempts</button>\n  </div>\n  <div class=\"dpw-readout\">\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc8c-n\">0</span><span class=\"dpw-cap\">attempts</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc8c-w\">0</span><span class=\"dpw-cap\">passed the check</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc8c-r\">&ndash;</span><span class=\"dpw-cap\">pass rate</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc8c-e\"></span><span class=\"dpw-cap\">1 / <span class=\"dpw-var\">q</span></span></div>\n  </div>\n  <div class=\"dpw-verdict dpw-neutral\" id=\"cc8c-vd\">Press run.</div>\n  <div class=\"dpw-hint\">When Peter picks c himself he passes every time without knowing x, which is why c has to come from someone else. The same trick, run with Veronica's real c, is what the zero-knowledge simulator does: it writes transcripts (y, &alpha;, c, s) that verify, and it never knew x.</div>\n</div>\n<h2 id=\"soundness-rewind-the-tape\" style=\"position:relative;\"><a href=\"#soundness-rewind-the-tape\" aria-label=\"soundness rewind the tape permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Soundness: rewind the tape</h2>\n<p>Initially, when I first learned it, I was also kind of confused, because it didn't make any practical sense. But I was told to just think of this as a mental experiment, and maybe you can also try to do the same. Hear me out, and then let's talk about it.</p>\n<p>X and R are both created from this field, and then we calculate Y = G<sup>X</sup> and α = G<sup>R</sup>, and we send both of these to the verifier. Now the verifier creates a random value, again from this field, and sends that over to the prover. We'll call this C<sub>1</sub>. And now the prover calculates this S value, I'll call it S<sub>1</sub>, which is R + C<sub>1</sub>X mod Q.</p>\n<div class=\"dpw-formula\">s<sub>1</sub> = r + c<sub>1</sub>x mod q</div>\n<p>Now what happens is we stop this game, and we rewind the tape. We rewind the program, the tape, the virtual machine, whatever you want to think of it. Basically, you go back in time to this point. And at this point, the α value is already calculated, and R is already calculated. Now what we can do is tell the prover to prove it again: \"Hey, you've done it once, do it again.\" So the verifier creates a C<sub>2</sub> and gives C<sub>2</sub> to the prover. But our random value is fixed, remember. So S<sub>2</sub> will now be the same random value plus C<sub>2</sub>X mod Q.</p>\n<div class=\"dpw-formula\">s<sub>2</sub> = r + c<sub>2</sub>x mod q</div>\n<p>We have the same R, the same X. We can subtract these equations, and the R will cancel out. R − R cancels out, and we can solve for X:</p>\n<div class=\"dpw-formula\">x = (s<sub>1</sub> &minus; s<sub>2</sub>) / (c<sub>1</sub> &minus; c<sub>2</sub>) mod q</div>\n<p>If we were able to give two challenges to a prover at this point in time, they must know X, because if they've created valid S values, then we can see that X is easily computable. And if a prover does not know X, then they would not be able to compute these S<sub>1</sub> and S<sub>2</sub> correctly, so this equation would not be possible.</p>\n<p>This is the idea behind the forking lemma. This is a point at which we forked and we fixed our random value, and then we consider two cases with the same random value. We go back, we rewind the tape, and then we look at two cases with our previous values fixed, to prove whatever we want to prove.</p>\n<div class=\"dpw\" id=\"cc8-fork\">\n  <div class=\"dpw-q\">Rewind Peter once. How much of his secret do two answers give away?</div>\n  <div class=\"dpw-detail-b\">Same toy group (p = 2039, q = 1019, g = 4). Peter commits to &alpha; once. Veronica asks c<sub>1</sub>, then the tape is rewound to just after &alpha; and she asks c<sub>2</sub>.</div>\n  <div class=\"dpw-controls\" style=\"margin-top:12px\">\n    <label class=\"dpw-label\">first challenge c<sub>1</sub> &nbsp; <span class=\"dpw-val\" id=\"cc8f-c1v\"></span>\n      <input type=\"range\" id=\"cc8f-c1\" min=\"0\" max=\"1018\" value=\"120\" /></label>\n    <label class=\"dpw-label\">second challenge c<sub>2</sub> (after rewinding) &nbsp; <span class=\"dpw-val\" id=\"cc8f-c2v\"></span>\n      <input type=\"range\" id=\"cc8f-c2\" min=\"0\" max=\"1018\" value=\"777\" /></label>\n  </div>\n  <div class=\"dpw-toggle-row\">\n    <button class=\"dpw-toggle\" id=\"cc8f-new\">new Peter (new x and r)</button>\n  </div>\n  <div class=\"dpw-line\"><span>&alpha; (fixed by the fork)</span><span><b id=\"cc8f-a\"></b></span></div>\n  <div class=\"dpw-line\"><span>s<sub>1</sub>, s<sub>2</sub> (both pass Veronica's check)</span><span><b id=\"cc8f-s\"></b></span></div>\n  <div class=\"dpw-line\"><span>(s<sub>1</sub> &minus; s<sub>2</sub>)&middot;(c<sub>1</sub> &minus; c<sub>2</sub>)<sup>&minus;1</sup> mod q</span><span><b id=\"cc8f-x\"></b></span></div>\n  <div class=\"dpw-line\"><span>Peter's actual secret x</span><span><b id=\"cc8f-xr\"></b></span></div>\n  <div class=\"dpw-verdict\" id=\"cc8f-v\"></div>\n  <div class=\"dpw-hint\">All of it. The only case that fails is c<sub>1</sub> = c<sub>2</sub>, where there is nothing to divide by.</div>\n</div>\n<p>Someone in the room connected this to signatures: if the same random value is used for two signatures, it cancels out and exposes the private key. That's the same algebra. Here the rewind is a thought experiment that proves soundness. In a signature scheme, reusing the random value by accident leaks the key.</p>\n<h2 id=\"zero-knowledge\" style=\"position:relative;\"><a href=\"#zero-knowledge\" aria-label=\"zero knowledge permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Zero knowledge</h2>\n<p>With zero knowledge, you basically want to rely on a simulator. And the simulator, imagine it's just a computer program. It should be able to simulate all of the important transcript values of the scheme without actually knowing X. Whatever it does, it should give us Y, α and S, which should be computationally indistinguishable from the real Y, α and S, which were created by the actual prover. Maybe we need a full session on this: what does it mean to be computationally indistinguishable? But if we can show that a program is able to produce this type of output, and it has no knowledge of X, then we can prove that it's zero knowledge.</p>\n<p>This is not a digital signature. This is just a proof of knowledge scheme, which came first. And then from this, Schnorr created a digital signature scheme. We'll talk about how to convert this interactive proof of knowledge into a non-interactive digital signature, and then how to turn that into an elliptic curve version, which is the one used in Bitcoin.</p>\n<style>\n.dpw-formula { text-align: center; font-family: 'Inconsolata', monospace; font-size: 17px;\n  color: #1b2228; margin: 22px 0; letter-spacing: .01em; line-height: 1.6; overflow-x: auto; }\n.dpw-formula sup, .dpw-formula sub { font-size: 11px; }\n.dpw {\n  --ink: #1b2228; --ink2: #5b7085; --line: #dae4ed;\n  --maroon: #a72e2b; --maroon-d: #6a1d1b; --rose: #f2cdcc; --green: #3f8f5b; --slate: #8ba2b8;\n  border: 1px solid var(--line); border-radius: 6px; padding: 20px;\n  margin: 32px 0; background: #fff; font-family: 'Open Sans', sans-serif; color: var(--ink);\n}\n.dpw * { box-sizing: border-box; }\n.dpw-q { font-family: 'Josefin Sans', sans-serif; font-size: 14px; text-transform: uppercase; letter-spacing: .04em;\n  color: var(--maroon-d); margin: 0 0 12px; line-height: 1.4; }\n.dpw-controls { margin-bottom: 14px; display: grid; gap: 12px; }\n.dpw-label { display: block; font-size: 13px; color: var(--ink2); }\n.dpw-label input[type=range] { display: block; width: 100%; margin: 8px 0 0; accent-color: var(--maroon); }\n.dpw-val { color: var(--maroon-d); font-family: 'Inconsolata', monospace; font-weight: 700; }\n.dpw-hint { font-size: 12px; color: var(--ink2); margin-top: 10px; font-style: italic; line-height: 1.55; }\n.dpw-svg { width: 100%; height: auto; display: block; margin: 6px 0 4px;\n  background: linear-gradient(180deg, #fbfcfe, #f4f7fa); border-radius: 4px; }\n.dpw-verdict { margin: 10px 0 4px; padding: 8px 12px; border-radius: 4px; font-size: 13px; font-weight: 700;\n  background: var(--rose); color: var(--maroon-d); text-align: center; font-family: 'Inconsolata', monospace; }\n.dpw-verdict.dpw-ok { background: #dcefe3; color: var(--green); }\n.dpw-verdict.dpw-neutral { background: #e3ecf4; color: #3d566b; }\n.dpw-readout { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }\n.dpw-stat { display: flex; flex-direction: column; }\n.dpw-num { font-family: 'Josefin Sans', sans-serif; font-size: 23px; color: var(--maroon-d); line-height: 1.15; }\n.dpw-cap { font-size: 11px; color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; }\n/* variable names keep their case inside the upper-cased captions */\n.dpw-cap .dpw-var { text-transform: none; font-size: inherit; line-height: inherit; font-family: inherit; }\n.dpw-toggle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }\n.dpw-toggle-cap { width: 100%; margin-bottom: 3px; font-size: 12px; color: var(--ink2); }\n.dpw-toggle { font-family: 'Inconsolata', monospace; font-size: 12px; border: 1px solid var(--line);\n  background: #fff; color: var(--ink2); padding: 5px 9px; border-radius: 4px; cursor: pointer; transition: all .15s; }\n.dpw-toggle[data-on=true] { background: var(--maroon); color: #fff; border-color: var(--maroon); }\n.dpw-toggle:disabled { opacity: .45; cursor: default; }\n.dpw-detail { border: 1px solid var(--line); border-radius: 5px; padding: 13px 14px; margin-top: 10px; }\n.dpw-detail-h { font-family: 'Josefin Sans', sans-serif; font-size: 13px; text-transform: uppercase;\n  letter-spacing: .04em; color: var(--maroon-d); margin-bottom: 7px; }\n.dpw-detail-b { font-size: 13px; color: var(--ink2); line-height: 1.6; }\n.dpw-line { font-size: 13px; color: var(--ink2); margin: 9px 0; display: flex; justify-content: space-between;\n  align-items: baseline; gap: 10px; flex-wrap: wrap; }\n.dpw-line b { font-family: 'Inconsolata', monospace; font-size: 15px; color: var(--ink); font-weight: 700; }\n.dpw-mono { font-family: 'Inconsolata', monospace; }\n.dpw-input { font-family: 'Inconsolata', monospace; font-size: 14px; border: 1px solid var(--line); border-radius: 4px;\n  padding: 5px 8px; width: 80px; color: var(--ink); }\n.dpw-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }\n.dpw-chip { font-family: 'Inconsolata', monospace; font-size: 12px; padding: 3px 7px; border-radius: 3px;\n  background: #f4f7fa; border: 1px solid var(--line); color: var(--ink); }\n.dpw-chip.dpw-chip-hot { background: #dcefe3; border-color: #b9dcc5; color: var(--green); }\n.dpw-chip.dpw-chip-bad { background: var(--rose); border-color: #e7b3b1; color: var(--maroon-d); }\n.dpw-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n.dpw-table { width: 100%; border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; }\n.dpw-table td, .dpw-table th { padding: 5px 6px; border-bottom: 1px solid #eef3f7; text-align: left; }\n/* table headers hold maths: f(3) must not become F(3) */\n.dpw-table th { font-size: 11px; color: var(--ink2); text-transform: none; letter-spacing: .04em; font-weight: 600; }\n.dpw-table td.dpw-mono { white-space: nowrap; }\n@media (max-width: 560px) { .dpw { padding: 14px; } .dpw-grid2 { grid-template-columns: 1fr; } .dpw-readout { gap: 16px; } }\n@media (prefers-reduced-motion: reduce) { .dpw * { transition: none !important; } }\n</style>\n<script>\n(function () {\n  var P = 2039n, Q = 1019n, G = 4n;\n  function mp(b, e, m) { b %= m; if (b < 0n) b += m; var r = 1n; while (e > 0n) { if (e & 1n) r = r * b % m; b = b * b % m; e >>= 1n; } return r; }\n  function rnd(n) { return BigInt(Math.floor(Math.random() * Number(n))); }\n  function md(a, m) { a %= m; return a < 0n ? a + m : a; }\n  window.__cc8 = { P: P, Q: Q, G: G, mp: mp, rnd: rnd, md: md };\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc8-pok');\n  if (!root || !window.__cc8) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var Z = window.__cc8, $ = function (id) { return root.querySelector('#' + id); };\n  var x, r, show = false;\n  function fresh() { x = 1n + Z.rnd(Z.Q - 1n); r = Z.rnd(Z.Q); draw(); }\n  function draw() {\n    var c = BigInt($('cc8p-c').value);\n    var y = Z.mp(Z.G, x, Z.P), a = Z.mp(Z.G, r, Z.P);\n    var s = Z.md(r + x * c, Z.Q);\n    var lhs = Z.mp(Z.G, s, Z.P), rhs = a * Z.mp(y, c, Z.P) % Z.P;\n    $('cc8p-x').textContent = show ? String(x) : 'hidden';\n    $('cc8p-r').textContent = show ? String(r) : 'hidden';\n    $('cc8p-y').textContent = String(y); $('cc8p-a').textContent = String(a);\n    $('cc8p-cv').textContent = String(c); $('cc8p-s').textContent = String(s);\n    $('cc8p-l').textContent = String(lhs); $('cc8p-rr').textContent = String(rhs);\n    var v = $('cc8p-v');\n    v.className = lhs === rhs ? 'dpw-verdict dpw-ok' : 'dpw-verdict';\n    v.innerHTML = '' + (lhs === rhs ? lhs + ' = ' + rhs + ' &rarr; Veronica accepts' : 'mismatch &rarr; reject') + '';\n  }\n  on($('cc8p-c'), 'input', draw);\n  on($('cc8p-new'), 'click', fresh);\n  on($('cc8p-show'), 'click', function () { show = !show; $('cc8p-show').setAttribute('data-on', String(show)); draw(); });\n  fresh();\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc8-cheat');\n  if (!root || !window.__cc8) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var Z = window.__cc8, $ = function (id) { return root.querySelector('#' + id); };\n  var GROUPS = { '11': { P: 23n, Q: 11n, G: 4n }, '1019': { P: 2039n, Q: 1019n, G: 4n } };\n  var qsel = '11', peterPicks = false, n = 0, w = 0;\n  var qbtns = root.querySelectorAll('[data-q]');\n  function resetCounts() { n = 0; w = 0; paint(); $('cc8c-vd').className = 'dpw-verdict dpw-neutral'; $('cc8c-vd').innerHTML = 'Press run.'; }\n  function paint() {\n    $('cc8c-n').textContent = n.toLocaleString(); $('cc8c-w').textContent = w.toLocaleString();\n    $('cc8c-r').textContent = n ? (100 * w / n).toFixed(2) + '%' : '–';\n    $('cc8c-e').innerHTML = qsel === 'big' ? '&asymp; 10<sup>&minus;77</sup>' : (100 / Number(qsel)).toFixed(2) + '%';\n  }\n  function run() {\n    var vd = $('cc8c-vd');\n    if (qsel === 'big') {\n      n += 10000;\n      if (peterPicks) w += 10000;\n      paint();\n      vd.className = peterPicks ? 'dpw-verdict' : 'dpw-verdict dpw-ok';\n      vd.innerHTML = peterPicks ? 'Peter picks c: he passes every time, and he never knew x.'\n        : 'Too big to simulate: the chance any of these 10,000 tries passes is about 10<sup>&minus;73</sup>.';\n      return;\n    }\n    var g = GROUPS[qsel], x = 1n + Z.rnd(g.Q - 1n), y = Z.mp(g.G, x, g.P); // Peter is given y but not x\n    var yinv = Z.mp(y, g.Q - 1n, g.P);\n    for (var i = 0; i < 10000; i++) {\n      var cs = Z.rnd(g.Q), s = Z.rnd(g.Q);\n      var alpha = Z.mp(g.G, s, g.P) * Z.mp(yinv, cs, g.P) % g.P;   // alpha = g^s * y^(-c*)\n      var c = peterPicks ? cs : Z.rnd(g.Q);\n      var ok = Z.mp(g.G, s, g.P) === alpha * Z.mp(y, c, g.P) % g.P;\n      n++; if (ok) w++;\n    }\n    paint();\n    vd.className = peterPicks ? 'dpw-verdict' : 'dpw-verdict dpw-ok';\n    vd.innerHTML = peterPicks ? 'Peter picks c: he passes every time, and he never knew x.'\n      : 'Pass rate tracks 1/q. Make q 2<sup>256</sup> and the fluke is negligible.';\n  }\n  [].forEach.call(qbtns, function (b) {\n    on(b, 'click', function () {\n      qsel = b.getAttribute('data-q');\n      [].forEach.call(qbtns, function (o) { o.setAttribute('data-on', String(o === b)); });\n      resetCounts();\n    });\n  });\n  on($('cc8c-v'), 'click', function () { peterPicks = false; $('cc8c-v').setAttribute('data-on', 'true'); $('cc8c-p').setAttribute('data-on', 'false'); resetCounts(); });\n  on($('cc8c-p'), 'click', function () { peterPicks = true; $('cc8c-p').setAttribute('data-on', 'true'); $('cc8c-v').setAttribute('data-on', 'false'); resetCounts(); });\n  on($('cc8c-run'), 'click', run);\n  resetCounts();\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc8-fork');\n  if (!root || !window.__cc8) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var Z = window.__cc8, $ = function (id) { return root.querySelector('#' + id); };\n  var x, r;\n  function fresh() { x = 1n + Z.rnd(Z.Q - 1n); r = Z.rnd(Z.Q); draw(); }\n  function draw() {\n    var c1 = BigInt($('cc8f-c1').value), c2 = BigInt($('cc8f-c2').value);\n    $('cc8f-c1v').textContent = String(c1); $('cc8f-c2v').textContent = String(c2);\n    var s1 = Z.md(r + c1 * x, Z.Q), s2 = Z.md(r + c2 * x, Z.Q);\n    $('cc8f-a').textContent = String(Z.mp(Z.G, r, Z.P));\n    $('cc8f-s').textContent = s1 + ', ' + s2;\n    $('cc8f-xr').textContent = String(x);\n    var v = $('cc8f-v');\n    if (c1 === c2) {\n      $('cc8f-x').textContent = 'divide by 0';\n      v.className = 'dpw-verdict dpw-ok'; v.innerHTML = 'Same challenge twice: s<sub>1</sub> = s<sub>2</sub>, nothing learned.'; return;\n    }\n    var inv = Z.mp(Z.md(c1 - c2, Z.Q), Z.Q - 2n, Z.Q);\n    var xr = Z.md((s1 - s2) * inv, Z.Q);\n    $('cc8f-x').textContent = String(xr);\n    v.className = 'dpw-verdict';\n    v.innerHTML = '' + (xr === x ? 'Extracted x = ' + xr + '. Two answers to the same &alpha; are the secret.' : 'mismatch') + '';\n  }\n  on($('cc8f-c1'), 'input', draw); on($('cc8f-c2'), 'input', draw); on($('cc8f-new'), 'click', fresh);\n  fresh();\n})();\n</script>","headings":[{"value":"Peter and Veronica","depth":2},{"value":"Three things to prove","depth":2},{"value":"Soundness: rewind the tape","depth":2},{"value":"Zero knowledge","depth":2}],"frontmatter":{"date_created":"2026-09-25","path":"/blog/crypto-club-rewinding-the-prover","tags":["Cryptography","Bitcoin","Digital Signatures","Zero Knowledge Proofs"],"title":"Rewinding The Prover"}},"nextPost":{"html":"<p>In Bitcoin, we're using two variations of signature schemes. You could have a Taproot transaction, or you could have the legacy transaction, and they both use different signature schemes. We've been talking about the Taproot example so far, which is the Schnorr signature scheme. Taproot is a Bitcoin upgrade, and its Schnorr signatures are specified in BIP-340. And the other version, that we haven't discussed much because it's quite messy, is ECDSA, which stands for elliptic curve digital signature algorithm.</p>\n<p>A digital signature scheme has three functions: a key generation algorithm, a signing algorithm, and lastly a verify algorithm. We'll talk about the digital signature scheme for both of these constructions: keygen, sign and verify.</p>\n<h2 id=\"schnorr\" style=\"position:relative;\"><a href=\"#schnorr\" aria-label=\"schnorr permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Schnorr</h2>\n<p>For Schnorr, it's quite simple. You have a private key, which is a scalar, which you randomly pick from 1 up to n − 1, where n is the order of the elliptic curve, specifically the secp256k1 elliptic curve. Then you compute your public key, which we'll call P = d·G. The generator G is a point, so it has x and y coordinates, and you add it to itself d times, where d is your private scalar value. And then your public key is another coordinate point on the secp256k1 curve. With Schnorr specifically, we only care about points where the y value is even.</p>\n<p>For signing:</p>\n<ol>\n<li>You pick a random value k, again from the scalar interval, and you compute the random nonce, which is R = k·G.</li>\n<li>To make it non-interactive, we need a hash function. Typically, this is something the verifier would have to give us. But we can actually compute the challenge ourselves, by hashing the x-coordinate of the public key, the x-coordinate of R, and the message. If you don't quite understand what's going on, just imagine we're hashing P and R.</li>\n<li>Finally, you calculate your equation, s, which is your random nonce plus your challenge times your private key, mod n.</li>\n</ol>\n<div class=\"dpw-formula\">R = k&middot;G &nbsp;&nbsp; c = H(x<sub>R</sub> &#8214; x<sub>P</sub> &#8214; m) &nbsp;&nbsp; s = k + c&middot;d mod n &nbsp;&nbsp; &sigma; = (x<sub>R</sub>, s)</div>\n<p>We spoke about what happens if we first have our challenge. From that, we could basically cheat and create a nonce R that cancels out the verification without us needing to know the private key. So this is why you first calculate R and then c. You can only find c by hashing the value of R, so there's no way you could calculate c before R.</p>\n<p>For verification, we calculate our own R by multiplying this s value with our generator, which is public, and then we subtract our challenge times P from that. They're checking if the x coordinate of this R that they found is equal to the x coordinate of the original R. For this c, they can recompute this themselves. They don't need the signer to send them this information, because x<sub>P</sub> is public, x<sub>R</sub> has been sent with the signature, and the message is a common thing between the prover and the verifier.</p>\n<div class=\"dpw-formula\">R&prime; = s&middot;G &minus; c&middot;P &nbsp;&nbsp;&nbsp; accept if x<sub>R&prime;</sub> = x<sub>R</sub></div>\n<h2 id=\"ecdsa\" style=\"position:relative;\"><a href=\"#ecdsa\" aria-label=\"ecdsa permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ECDSA</h2>\n<p>What about the elliptic curve digital signature algorithm? That's also being used, and that's an older signature scheme, and Bitcoin has since upgraded. So what is this, and why did we upgrade?</p>\n<p>For key generation, again, you pick your private key, and again, you compute your public key, P = d·G. For signing, again, we pick a random value k, a scalar value, and we find our nonce, R = k·G. Now the computation that we do for s is a little bit more involved, and not as nice to look at. You calculate the modular inverse of the k that you just picked, and you multiply it by the hash of the message plus the x coordinate of R times the private key d. And all of that is mod n, again.</p>\n<div class=\"dpw-formula\">s = k<sup>&minus;1</sup>(H(m) + x<sub>R</sub>&middot;d) mod n</div>\n<p>For verify, it will output accept or reject, and we have to compute our own R value as c (the hash of the message) times the modular inverse of s, times G, plus the x coordinate of R times, again, the modular inverse of s, times P. And what we're then checking is if the x coordinate of the R that we calculated is congruent to the x coordinate of the random nonce the signer sent to us, mod n.</p>\n<div class=\"dpw-formula\">R&prime; = H(m)&middot;s<sup>&minus;1</sup>&middot;G + x<sub>R</sub>&middot;s<sup>&minus;1</sup>&middot;P &nbsp;&nbsp;&nbsp; accept if x<sub>R&prime;</sub> &equiv; x<sub>R</sub> mod n</div>\n<h2 id=\"the-modular-inverse-makes-things-hard\" style=\"position:relative;\"><a href=\"#the-modular-inverse-makes-things-hard\" aria-label=\"the modular inverse makes things hard permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The modular inverse makes things hard</h2>\n<p>If we simply compare this with this, even if we say c equals the hash of the message, you can already see how this extra thing, this modular inverse, makes things hard. Why? It makes things hard for multisignatures.</p>\n<p>When multiple people have their own random nonce values, their own challenge values, their own private keys, we're able to do simple addition. We can just add nonce values, and the addition of those nonce values scales linearly, meaning it increases linearly as you add. But with a modular inverse, that's not the case. You can pick random numbers and try to do it yourself with two people.</p>\n<div class=\"dpw\" id=\"cc11-inv\">\n  <div class=\"dpw-q\">Is the inverse of a sum the sum of the inverses?</div>\n  <div class=\"dpw-controls\">\n    <label class=\"dpw-label\">Alice's nonce k<sub>A</sub> &nbsp; <span class=\"dpw-val\" id=\"cc11i-av\"></span>\n      <input type=\"range\" id=\"cc11i-a\" min=\"1\" max=\"66\" value=\"5\" /></label>\n    <label class=\"dpw-label\">Bob's nonce k<sub>B</sub> &nbsp; <span class=\"dpw-val\" id=\"cc11i-bv\"></span>\n      <input type=\"range\" id=\"cc11i-b\" min=\"1\" max=\"66\" value=\"9\" /></label>\n  </div>\n  <div class=\"dpw-grid2\">\n    <div>\n      <div class=\"dpw-cap\">Schnorr needs: add, then use</div>\n      <div class=\"dpw-line\"><span>k<sub>A</sub> + k<sub>B</sub></span><span><b id=\"cc11i-s1\"></b></span></div>\n      <div class=\"dpw-line\"><span>the aggregate nonce</span><span><b id=\"cc11i-s2\"></b></span></div>\n    </div>\n    <div>\n      <div class=\"dpw-cap\">ECDSA would need: invert</div>\n      <div class=\"dpw-line\"><span>(k<sub>A</sub> + k<sub>B</sub>)<sup>&minus;1</sup> mod 67</span><span><b id=\"cc11i-e1\"></b></span></div>\n      <div class=\"dpw-line\"><span>k<sub>A</sub><sup>&minus;1</sup> + k<sub>B</sub><sup>&minus;1</sup> mod 67</span><span><b id=\"cc11i-e2\"></b></span></div>\n    </div>\n  </div>\n  <div class=\"dpw-verdict\" id=\"cc11i-v\"></div>\n  <div class=\"dpw-line\" style=\"margin-top:14px\"><span>pairs (k<sub>A</sub>, k<sub>B</sub>) mod 67 where the two inverses agree</span><span><b id=\"cc11i-c\"></b></span></div>\n  <div class=\"dpw-hint\">Every nonzero pair is checked exhaustively. They agree only when k<sub>A</sub><sup>2</sup> + k<sub>A</sub>k<sub>B</sub> + k<sub>B</sub><sup>2</sup> &equiv; 0, which for n = 67 happens for 2 of every 66 choices of k<sub>B</sub>: an accident, not a rule anyone could build a multisig on.</div>\n</div>\n<h2 id=\"ecdsa-multisig-one-signature-per-key\" style=\"position:relative;\"><a href=\"#ecdsa-multisig-one-signature-per-key\" aria-label=\"ecdsa multisig one signature per key permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>ECDSA multisig: one signature per key</h2>\n<p>If you want to have five people be part of a transaction, and if you want all five to sign that transaction, and if the five people don't sign, then the transaction doesn't go through, to enable that sort of behaviour, you need multisignatures. For ECDSA, it's quite messy. For the ECDSA multisig setup, you have to first list out all the public keys that are part of the multisignature, P<sub>1</sub>, P<sub>2</sub>, all the way up to P<sub>u</sub>. And each of these will have its own signature: signature one, signature two, signature u.</p>\n<p>The problem with ECDSA is there's no easy way to combine these. It's not the case that signature one plus signature two is equal to their values added. It's not linear in that regard. So what the code has to do is verify each signature individually. First you would have to verify whether signature one came from P<sub>1</sub>, whether signature two came from P<sub>2</sub>, and then if all those verifications pass, then the multisignature passes. There's no one signature which you can run that just verifies everyone's signature altogether. You have to do it one by one.</p>\n<h2 id=\"schnorr-multisig-just-add\" style=\"position:relative;\"><a href=\"#schnorr-multisig-just-add\" aria-label=\"schnorr multisig just add permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Schnorr multisig: just add</h2>\n<p>With Schnorr, suppose we have two people, and let's call them Alice and Bob. They both have a private key, d<sub>A</sub> and d<sub>B</sub>, and they both have a public key, P<sub>A</sub> and P<sub>B</sub>. With Schnorr, the aggregate of the public keys is P<sub>A</sub> + P<sub>B</sub>, and the nonces can also just be added, so the aggregate will be R<sub>A</sub> + R<sub>B</sub>. That's not the case for ECDSA.</p>\n<div class=\"dpw-formula\">P<sub>agg</sub> = P<sub>A</sub> + P<sub>B</sub> &nbsp;&nbsp;&nbsp; R<sub>agg</sub> = R<sub>A</sub> + R<sub>B</sub> &nbsp;&nbsp;&nbsp; c = H(P<sub>agg</sub> &#8214; R<sub>agg</sub> &#8214; m)</div>\n<p>So we have a challenge value c, which is found from the aggregate of the public keys of Alice and Bob and the aggregate of the random nonce values. Now they can compute their s values. This would be a step that each of them would have to do, because they both have their own private keys. Alice would have to calculate her own s, because only she knows her private key.</p>\n<div class=\"dpw-formula\">s<sub>A</sub> = k<sub>A</sub> + c&middot;d<sub>A</sub> &nbsp;&nbsp;&nbsp; s<sub>B</sub> = k<sub>B</sub> + c&middot;d<sub>B</sub></div>\n<p>And now we can even find a combined signature s, which is s<sub>A</sub> + s<sub>B</sub>. If I move things around, I can factor out the c:</p>\n<div class=\"dpw-formula\">s = s<sub>A</sub> + s<sub>B</sub> = (k<sub>A</sub> + k<sub>B</sub>) + c&middot;(d<sub>A</sub> + d<sub>B</sub>)</div>\n<p>If you notice this equation, and if you notice the regular equation, which is s = k + c·d, you can see that as we are adding people, Alice and Bob in this case, we can just add the k's, and we can just add the private keys too. And c is a shared challenge value between all the people who are doing the signatures. Here it does scale linearly. By linearly, I mean if this is two and this is two, then the final answer is four. With modular inverse, that's not true.</p>\n<p>How do we find the verification now? It's exactly the same as this verify. What we're verifying is if s·G is equal to R<sub>agg</sub> + c·P<sub>agg</sub>. If I isolate R, then R<sub>agg</sub> = s·G − c·P<sub>agg</sub>.</p>\n<div class=\"dpw-formula\">R<sub>agg</sub> = s&middot;G &minus; c&middot;P<sub>agg</sub></div>\n<div class=\"dpw\" id=\"cc11-add\">\n  <div class=\"dpw-q\">Add Alice's and Bob's signatures. Does the sum verify as one signature?</div>\n  <div class=\"dpw-detail-b\">Toy curve y<sup>2</sup> = x<sup>3</sup> + 7 over F<sub>79</sub>, the same equation as secp256k1. It has 67 points, a prime, so n = 67. The hash is a toy hash reduced mod n.</div>\n  <div class=\"dpw-toggle-row\" style=\"margin-top:12px\">\n    <button class=\"dpw-toggle\" id=\"cc11a-new\">new keys and nonces</button>\n    <label class=\"dpw-label\" style=\"display:flex;align-items:center;gap:8px\">message m\n      <input class=\"dpw-input\" id=\"cc11a-m\" type=\"number\" value=\"21\" /></label>\n  </div>\n  <table class=\"dpw-table\" style=\"margin-top:8px\">\n    <tr><th></th><th>Alice</th><th>Bob</th></tr>\n    <tr><td>private key d</td><td class=\"dpw-mono\" id=\"cc11a-da\"></td><td class=\"dpw-mono\" id=\"cc11a-db\"></td></tr>\n    <tr><td>public key P = d&middot;G</td><td class=\"dpw-mono\" id=\"cc11a-pa\"></td><td class=\"dpw-mono\" id=\"cc11a-pb\"></td></tr>\n    <tr><td>nonce k, R = k&middot;G</td><td class=\"dpw-mono\" id=\"cc11a-ra\"></td><td class=\"dpw-mono\" id=\"cc11a-rb\"></td></tr>\n  </table>\n  <div class=\"dpw-grid2\" style=\"margin-top:12px\">\n    <div>\n      <div class=\"dpw-cap\">Schnorr</div>\n      <div class=\"dpw-line\"><span>c = H(P<sub>agg</sub>, R<sub>agg</sub>, m)</span><span><b id=\"cc11a-sc\"></b></span></div>\n      <div class=\"dpw-line\"><span>s<sub>A</sub>, s<sub>B</sub></span><span><b id=\"cc11a-ss\"></b></span></div>\n      <div class=\"dpw-line\"><span>s = s<sub>A</sub> + s<sub>B</sub></span><span><b id=\"cc11a-s\"></b></span></div>\n      <div class=\"dpw-line\"><span>s&middot;G &minus; c&middot;P<sub>agg</sub></span><span><b id=\"cc11a-sr\"></b></span></div>\n      <div class=\"dpw-line\"><span>R<sub>agg</sub></span><span><b id=\"cc11a-sra\"></b></span></div>\n      <div class=\"dpw-verdict\" id=\"cc11a-sv\"></div>\n    </div>\n    <div>\n      <div class=\"dpw-cap\">ECDSA</div>\n      <div class=\"dpw-line\"><span>H(m)</span><span><b id=\"cc11a-ec\"></b></span></div>\n      <div class=\"dpw-line\"><span>s<sub>A</sub>, s<sub>B</sub> (each verifies alone)</span><span><b id=\"cc11a-es\"></b></span></div>\n      <div class=\"dpw-line\"><span>s = s<sub>A</sub> + s<sub>B</sub></span><span><b id=\"cc11a-e\"></b></span></div>\n      <div class=\"dpw-line\"><span>x of R&prime; from s, P<sub>agg</sub></span><span><b id=\"cc11a-er\"></b></span></div>\n      <div class=\"dpw-line\"><span>x of R<sub>agg</sub></span><span><b id=\"cc11a-era\"></b></span></div>\n      <div class=\"dpw-verdict\" id=\"cc11a-ev\"></div>\n    </div>\n  </div>\n  <div class=\"dpw-readout\">\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc11a-rs\">0 / 0</span><span class=\"dpw-cap\">Schnorr sums that verified</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc11a-re\">0 / 0</span><span class=\"dpw-cap\">ECDSA sums that verified</span></div>\n  </div>\n  <div class=\"dpw-hint\">Keep pressing \"new keys and nonces\". The Schnorr sum verifies every time. The ECDSA sum only passes when the x-coordinates collide by luck, about 1 time in 30 on this 67-point curve (each x-coordinate belongs to two points), and essentially never on secp256k1.</div>\n</div>\n<h2 id=\"doesnt-that-make-it-easier-for-the-attacker-too\" style=\"position:relative;\"><a href=\"#doesnt-that-make-it-easier-for-the-attacker-too\" aria-label=\"doesnt that make it easier for the attacker too permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>\"Doesn't that make it easier for the attacker too?\"</h2>\n<p>Someone asked: if we make verification easier by making it linear, don't we make it easier for an attacker as well, and which scheme is safer?</p>\n<p>What I have on the screen right now is not safe, and you are right to doubt it. With the Schnorr one, there's a very big problem here. If we have five people who are doing a multisignature, with this scheme right now, I could just disregard the signatures of all the other four, and I could be the only one providing signatures, and verification would pass. Let me first write this, otherwise people would think this is correct: this is not safe.</p>\n<p>How one signer does that, the rogue-key attack, and how MuSig2 keeps the addition while stopping it, is next week.</p>\n<style>\n.dpw-formula { text-align: center; font-family: 'Inconsolata', monospace; font-size: 17px;\n  color: #1b2228; margin: 22px 0; letter-spacing: .01em; line-height: 1.6; overflow-x: auto; }\n.dpw-formula sup, .dpw-formula sub { font-size: 11px; }\n.dpw {\n  --ink: #1b2228; --ink2: #5b7085; --line: #dae4ed;\n  --maroon: #a72e2b; --maroon-d: #6a1d1b; --rose: #f2cdcc; --green: #3f8f5b; --slate: #8ba2b8;\n  border: 1px solid var(--line); border-radius: 6px; padding: 20px;\n  margin: 32px 0; background: #fff; font-family: 'Open Sans', sans-serif; color: var(--ink);\n}\n.dpw * { box-sizing: border-box; }\n.dpw-q { font-family: 'Josefin Sans', sans-serif; font-size: 14px; text-transform: uppercase; letter-spacing: .04em;\n  color: var(--maroon-d); margin: 0 0 12px; line-height: 1.4; }\n.dpw-controls { margin-bottom: 14px; display: grid; gap: 12px; }\n.dpw-label { display: block; font-size: 13px; color: var(--ink2); }\n.dpw-label input[type=range] { display: block; width: 100%; margin: 8px 0 0; accent-color: var(--maroon); }\n.dpw-val { color: var(--maroon-d); font-family: 'Inconsolata', monospace; font-weight: 700; }\n.dpw-hint { font-size: 12px; color: var(--ink2); margin-top: 10px; font-style: italic; line-height: 1.55; }\n.dpw-svg { width: 100%; height: auto; display: block; margin: 6px 0 4px;\n  background: linear-gradient(180deg, #fbfcfe, #f4f7fa); border-radius: 4px; }\n.dpw-verdict { margin: 10px 0 4px; padding: 8px 12px; border-radius: 4px; font-size: 13px; font-weight: 700;\n  background: var(--rose); color: var(--maroon-d); text-align: center; font-family: 'Inconsolata', monospace; }\n.dpw-verdict.dpw-ok { background: #dcefe3; color: var(--green); }\n.dpw-verdict.dpw-neutral { background: #e3ecf4; color: #3d566b; }\n.dpw-readout { display: flex; gap: 24px; margin-top: 12px; flex-wrap: wrap; }\n.dpw-stat { display: flex; flex-direction: column; }\n.dpw-num { font-family: 'Josefin Sans', sans-serif; font-size: 23px; color: var(--maroon-d); line-height: 1.15; }\n.dpw-cap { font-size: 11px; color: var(--ink2); text-transform: uppercase; letter-spacing: .04em; }\n/* variable names keep their case inside the upper-cased captions */\n.dpw-cap .dpw-var { text-transform: none; font-size: inherit; line-height: inherit; font-family: inherit; }\n.dpw-toggle-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }\n.dpw-toggle-cap { width: 100%; margin-bottom: 3px; font-size: 12px; color: var(--ink2); }\n.dpw-toggle { font-family: 'Inconsolata', monospace; font-size: 12px; border: 1px solid var(--line);\n  background: #fff; color: var(--ink2); padding: 5px 9px; border-radius: 4px; cursor: pointer; transition: all .15s; }\n.dpw-toggle[data-on=true] { background: var(--maroon); color: #fff; border-color: var(--maroon); }\n.dpw-toggle:disabled { opacity: .45; cursor: default; }\n.dpw-detail { border: 1px solid var(--line); border-radius: 5px; padding: 13px 14px; margin-top: 10px; }\n.dpw-detail-h { font-family: 'Josefin Sans', sans-serif; font-size: 13px; text-transform: uppercase;\n  letter-spacing: .04em; color: var(--maroon-d); margin-bottom: 7px; }\n.dpw-detail-b { font-size: 13px; color: var(--ink2); line-height: 1.6; }\n.dpw-line { font-size: 13px; color: var(--ink2); margin: 9px 0; display: flex; justify-content: space-between;\n  align-items: baseline; gap: 10px; flex-wrap: wrap; }\n.dpw-line b { font-family: 'Inconsolata', monospace; font-size: 15px; color: var(--ink); font-weight: 700; }\n.dpw-mono { font-family: 'Inconsolata', monospace; }\n.dpw-input { font-family: 'Inconsolata', monospace; font-size: 14px; border: 1px solid var(--line); border-radius: 4px;\n  padding: 5px 8px; width: 80px; color: var(--ink); }\n.dpw-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }\n.dpw-chip { font-family: 'Inconsolata', monospace; font-size: 12px; padding: 3px 7px; border-radius: 3px;\n  background: #f4f7fa; border: 1px solid var(--line); color: var(--ink); }\n.dpw-chip.dpw-chip-hot { background: #dcefe3; border-color: #b9dcc5; color: var(--green); }\n.dpw-chip.dpw-chip-bad { background: var(--rose); border-color: #e7b3b1; color: var(--maroon-d); }\n.dpw-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n.dpw-table { width: 100%; border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; }\n.dpw-table td, .dpw-table th { padding: 5px 6px; border-bottom: 1px solid #eef3f7; text-align: left; }\n/* table headers hold maths: f(3) must not become F(3) */\n.dpw-table th { font-size: 11px; color: var(--ink2); text-transform: none; letter-spacing: .04em; font-weight: 600; }\n.dpw-table td.dpw-mono { white-space: nowrap; }\n@media (max-width: 560px) { .dpw { padding: 14px; } .dpw-grid2 { grid-template-columns: 1fr; } .dpw-readout { gap: 16px; } }\n@media (prefers-reduced-motion: reduce) { .dpw * { transition: none !important; } }\n</style>\n<script>\n(function () {\n  var root = document.getElementById('cc11-inv');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var $ = function (id) { return root.querySelector('#' + id); };\n  var N = 67;\n  function inv(a) { a = ((a % N) + N) % N; if (!a) return null; var r = 1, b = a, e = N - 2; while (e) { if (e & 1) r = r * b % N; b = b * b % N; e >>= 1; } return r; }\n  var agree = 0, total = 0;\n  for (var a = 1; a < N; a++) for (var b = 1; b < N; b++) {\n    if ((a + b) % N === 0) continue;\n    total++;\n    if (inv(a + b) === (inv(a) + inv(b)) % N) agree++;\n  }\n  $('cc11i-c').textContent = agree + ' of ' + total.toLocaleString();\n  function draw() {\n    var a = +$('cc11i-a').value, b = +$('cc11i-b').value;\n    $('cc11i-av').textContent = a; $('cc11i-bv').textContent = b;\n    var sum = (a + b) % N;\n    $('cc11i-s1').textContent = a + ' + ' + b + ' = ' + sum;\n    $('cc11i-s2').textContent = sum ? sum : '0 (degenerate)';\n    var i1 = inv(sum), i2 = (inv(a) + inv(b)) % N;\n    $('cc11i-e1').textContent = i1 === null ? 'undefined' : i1;\n    $('cc11i-e2').textContent = inv(a) + ' + ' + inv(b) + ' = ' + i2;\n    var v = $('cc11i-v');\n    if (i1 === i2) { v.className = 'dpw-verdict dpw-neutral'; v.innerHTML = 'They happen to agree here. Move a slider by one.'; }\n    else { v.className = 'dpw-verdict'; v.innerHTML = '' + (i1 === null ? 'undefined' : i1) + ' &ne; ' + i2 + ': inverses do not add'; }\n  }\n  on($('cc11i-a'), 'input', draw); on($('cc11i-b'), 'input', draw);\n  draw();\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc11-add');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { el.addEventListener(ev, fn); L.push([el, ev, fn]); }\n  root._cleanup = function () { L.forEach(function (x) { x[0].removeEventListener(x[1], x[2]); }); };\n  var $ = function (id) { return root.querySelector('#' + id); };\n  // y^2 = x^3 + 7 over F_79: 67 points (prime), so every non-identity point generates the group\n  var Pm = 79, N = 67;\n  function md(a, m) { a %= m; return a < 0 ? a + m : a; }\n  function pw(b, e, m) { b = md(b, m); var r = 1; while (e) { if (e & 1) r = r * b % m; b = b * b % m; e >>= 1; } return r; }\n  function inv(a, m) { return pw(a, m - 2, m); }\n  function add(A, B) {\n    if (!A) return B; if (!B) return A;\n    if (A[0] === B[0] && md(A[1] + B[1], Pm) === 0) return null;\n    var l = A[0] === B[0] ? md(3 * A[0] * A[0] * inv(2 * A[1], Pm), Pm) : md((B[1] - A[1]) * inv(md(B[0] - A[0], Pm), Pm), Pm);\n    var x = md(l * l - A[0] - B[0], Pm);\n    return [x, md(l * (A[0] - x) - A[1], Pm)];\n  }\n  function mul(k, A) { k = md(k, N); var R = null; while (k) { if (k & 1) R = add(R, A); A = add(A, A); k >>= 1; } return R; }\n  function neg(A) { return A ? [A[0], md(-A[1], Pm)] : null; }\n  var G = null;\n  for (var x = 0; x < Pm && !G; x++) for (var y = 1; y < Pm; y++) if (md(y * y - x * x * x - 7, Pm) === 0) { G = [x, y]; break; }\n  function H() { var s = Array.prototype.join.call(arguments, '|'), h = 2166136261; for (var i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619) >>> 0; } return h % N; }\n  function fmt(A) { return A ? '(' + A[0] + ', ' + A[1] + ')' : 'O'; }\n  function r1() { return 1 + Math.floor(Math.random() * (N - 1)); }\n  var st, tally = { s: 0, e: 0, n: 0 };\n  function fresh() {\n    var k;\n    st = { da: r1(), db: r1(), ka: r1(), kb: r1() };\n    // ECDSA needs x_R != 0 mod n and s != 0; retry the rare bad draws\n    draw(true);\n  }\n  function draw(count) {\n    var m = Math.round(+$('cc11a-m').value) || 0;\n    var PA = mul(st.da, G), PB = mul(st.db, G), RA = mul(st.ka, G), RB = mul(st.kb, G);\n    var Pagg = add(PA, PB), Ragg = add(RA, RB);\n    if (!Pagg || !Ragg || !RA || !RB) { fresh(); return; }\n    $('cc11a-da').textContent = st.da; $('cc11a-db').textContent = st.db;\n    $('cc11a-pa').textContent = fmt(PA); $('cc11a-pb').textContent = fmt(PB);\n    $('cc11a-ra').textContent = st.ka + ', ' + fmt(RA); $('cc11a-rb').textContent = st.kb + ', ' + fmt(RB);\n    // Schnorr\n    var c = H(Pagg[0], Ragg[0], m);\n    var sA = md(st.ka + c * st.da, N), sB = md(st.kb + c * st.db, N), s = md(sA + sB, N);\n    var Rp = add(mul(s, G), neg(mul(c, Pagg)));\n    var okS = Rp && Rp[0] === Ragg[0] && Rp[1] === Ragg[1];\n    $('cc11a-sc').textContent = c; $('cc11a-ss').textContent = sA + ', ' + sB; $('cc11a-s').textContent = s;\n    $('cc11a-sr').textContent = fmt(Rp); $('cc11a-sra').textContent = fmt(Ragg);\n    var sv = $('cc11a-sv'); sv.className = okS ? 'dpw-verdict dpw-ok' : 'dpw-verdict';\n    sv.innerHTML = '' + (okS ? 'equal &rarr; one signature, accept' : 'reject') + '';\n    // ECDSA: each signs with its own key and nonce\n    var e = H(m), xa = md(RA[0], N), xb = md(RB[0], N);\n    var eA = md(inv(st.ka, N) * (e + xa * st.da), N), eB = md(inv(st.kb, N) * (e + xb * st.db), N);\n    if (!xa || !xb || !eA || !eB) { fresh(); return; }\n    var es = md(eA + eB, N);\n    $('cc11a-ec').textContent = e; $('cc11a-es').textContent = eA + ', ' + eB; $('cc11a-e').textContent = es;\n    var xr = md(Ragg[0], N), okE = false, txt = 's = 0, undefined';\n    if (es) {\n      var w = inv(es, N);\n      var Rq = add(mul(md(e * w, N), G), mul(md(xr * w, N), Pagg));\n      okE = !!Rq && md(Rq[0], N) === xr;\n      txt = Rq ? String(md(Rq[0], N)) : 'O';\n    }\n    $('cc11a-er').textContent = txt; $('cc11a-era').textContent = xr;\n    var ev = $('cc11a-ev'); ev.className = okE ? 'dpw-verdict dpw-neutral' : 'dpw-verdict';\n    ev.innerHTML = '' + (okE ? 'passed, by coincidence: this curve only has 67 points' : 'different &rarr; the sum is not a signature') + '';\n    if (count) { tally.n++; if (okS) tally.s++; if (okE) tally.e++; }\n    $('cc11a-rs').textContent = tally.s + ' / ' + tally.n; $('cc11a-re').textContent = tally.e + ' / ' + tally.n;\n  }\n  on($('cc11a-new'), 'click', fresh);\n  on($('cc11a-m'), 'input', function () { draw(false); });\n  fresh();\n})();\n</script>","headings":[{"value":"Schnorr","depth":2},{"value":"ECDSA","depth":2},{"value":"The modular inverse makes things hard","depth":2},{"value":"ECDSA multisig: one signature per key","depth":2},{"value":"Schnorr multisig: just add","depth":2},{"value":"\"Doesn't that make it easier for the attacker too?\"","depth":2}],"frontmatter":{"date_created":"2026-10-16","path":"/blog/crypto-club-why-schnorr-adds-up","tags":["Cryptography","Bitcoin","Digital Signatures"],"title":"Why Schnorr Signatures Add Up And ECDSA Signatures Do Not"}}},"pageContext":{"prevPostPath":"/blog/crypto-club-forging-without-the-key","currPostPath":"/blog/crypto-club-rewinding-the-prover","nextPostPath":"/blog/crypto-club-why-schnorr-adds-up"}},"staticQueryHashes":[]}