{"componentChunkName":"component---src-templates-post-js","path":"/blog/crypto-club-prime-order-subgroups","result":{"data":{"prevPost":{"html":"<blockquote>\n<p>Draft. Not linked from the writing index. Outline below, to be written.</p>\n</blockquote>\n<h2 id=\"the-pipeline-i-built\" style=\"position:relative;\"><a href=\"#the-pipeline-i-built\" aria-label=\"the pipeline i built 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 pipeline I built</h2>\n<p>A proof pipeline over multi-hour GPU workloads on NASA-ISRO NISAR radar data: a RISC Zero\nzkVM guest re-executing a Fiat-Shamir residual check, wrapped in Groth16 for on-chain\nverification, with Intel TDX attestation over the off-chain engine.</p>\n<h2 id=\"the-binding-failure\" style=\"position:relative;\"><a href=\"#the-binding-failure\" aria-label=\"the binding failure 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 binding failure</h2>\n<p>The Fiat-Shamir seed committed only to public inputs, which are fixed in advance. So the\nsampled column set is computable before choosing what to publish.</p>\n<h2 id=\"the-forgery\" style=\"position:relative;\"><a href=\"#the-forgery\" aria-label=\"the forgery 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 forgery</h2>\n<p>The certificate verifies. Every check passes. 999,744 of 1,000,000 output columns are wrong.</p>\n<p>TODO: walk through construction, and state precisely what an honest verifier would have\nhad to check to catch it.</p>\n<h2 id=\"the-sampling-soundness-computed-after-the-fact\" style=\"position:relative;\"><a href=\"#the-sampling-soundness-computed-after-the-fact\" aria-label=\"the sampling soundness computed after the fact 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 sampling soundness, computed after the fact</h2>\n<p>256 samples miss a 0.1% localized corruption 77% of the time.</p>\n<p>TODO: cross-reference the hypergeometric argument already written up in\n<a href=\"/blog/fiat-shamir-coverage-gap\">Your Spot Check Cannot See the Fault You Are Paid to Catch</a>.</p>\n<h2 id=\"three-more-things-the-audit-found\" style=\"position:relative;\"><a href=\"#three-more-things-the-audit-found\" aria-label=\"three more things the audit found 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 more things the audit found</h2>\n<ul>\n<li>A byte-order bug in the published program identity.</li>\n<li>A guest binary that does not rebuild reproducibly.</li>\n<li>An attestation that turned out to be a hash of a log the process wrote about itself.</li>\n</ul>\n<h2 id=\"what-survives\" style=\"position:relative;\"><a href=\"#what-survives\" aria-label=\"what survives 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>What survives</h2>\n<p>A full RISC Zero receipt ladder measured end to end: composite 1,496 B, succinct 224,090 B,\nGroth16 1,361 B with a 260 B seal, 5.06 ms local verify, 249,749 gas and $0.0042 to verify\non chain.</p>\n<p>Separately, a GPU probe measuring 53.44 TFLOPS fp16 at 22% of peak, and finding that the\nPCIe link reports Gen 3 under load on a G2 instance.</p>\n<h2 id=\"the-design-rule\" style=\"position:relative;\"><a href=\"#the-design-rule\" aria-label=\"the design rule 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 design rule</h2>\n<p>TODO: the seed has to commit to the output, not only the input. State it as the rule and\nshow what it costs.</p>\n<h2 id=\"a-correction-i-owe\" style=\"position:relative;\"><a href=\"#a-correction-i-owe\" aria-label=\"a correction i owe 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 correction I owe</h2>\n<p>The SBAS design matrix turned out to be a permutation matrix, so the certified residual is\nidentically zero for any input, and the published 2.3174e-7 is float32 cumsum-then-diff\nrounding noise. The proof therefore proves nothing about the physics.</p>\n<p>TODO: say this plainly and early, not at the end.</p>","headings":[{"value":"The pipeline I built","depth":2},{"value":"The binding failure","depth":2},{"value":"The forgery","depth":2},{"value":"The sampling soundness, computed after the fact","depth":2},{"value":"Three more things the audit found","depth":2},{"value":"What survives","depth":2},{"value":"The design rule","depth":2},{"value":"A correction I owe","depth":2}],"frontmatter":{"date_created":"2026-09-09","path":"/blog/breaking-my-own-fiat-shamir-binding","tags":["Zero Knowledge Proofs","Protocol Audit","Fiat-Shamir"],"title":"Breaking My Own Fiat-Shamir Binding"}},"currPost":{"html":"<p>Last week, we started talking about the elliptic curve discrete log problem. Before that, we were talking about the standard discrete log problem: we have this function, f(x) = g<sup>x</sup> mod p, where x is your secret and p is a large prime.</p>\n<div class=\"dpw-formula\">f(x) = g<sup>x</sup> mod p</div>\n<h2 id=\"the-problem-with-p-−-1\" style=\"position:relative;\"><a href=\"#the-problem-with-p-%E2%88%92-1\" aria-label=\"the problem with p − 1 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 problem with p − 1</h2>\n<p>Z<sub>p</sub><sup>∗</sup>, which we said was a multiplicative group, included elements one up to p − 1. So the size of this group, what we also call order, is p − 1 exactly. If p is a prime, then this goes from one all the way up to p − 1. We don't skip anything, because every number is co-prime with p here.</p>\n<p>p is a prime, so p − 1 is a composite number, which has factors. It's an even number. There's a possibility of this whole group having multiple subgroups. The way you can think of it is, since the size of this group is composite, it's possible that we can split this group into smaller subgroups, and then we can try and attack these smaller subgroups. That makes it easier for us to break the discrete log problem. If you choose a large enough prime, then you're still dealing with very large numbers, but this is a known attack. It's called the Pohlig-Hellman algorithm.</p>\n<p>This is not really important, but I started with this because I think it gives a better intuition of how the elliptic curve discrete log problem works.</p>\n<p>What do those subgroups look like? Pick a prime, then click any number to use it as g. The filled cells are everything g can reach.</p>\n<div class=\"dpw\" id=\"cc6-zp\">\n  <div class=\"dpw-toggle-row\">\n    <span class=\"dpw-toggle-cap\">Prime p</span>\n    <button class=\"dpw-toggle\" data-p=\"23\" data-on=\"true\">23</button>\n    <button class=\"dpw-toggle\" data-p=\"47\" data-on=\"false\">47</button>\n    <button class=\"dpw-toggle\" data-p=\"29\" data-on=\"false\">29</button>\n    <button class=\"dpw-toggle\" data-p=\"31\" data-on=\"false\">31</button>\n  </div>\n  <div class=\"dpw-toggle-cap\" id=\"cc6-zcap\">&ndash;</div>\n  <div class=\"cc6-cells\" id=\"cc6-zcells\"></div>\n  <div class=\"dpw-toggle-cap\" style=\"margin-top:12px\">Subgroup sizes in this group <span class=\"dpw-inflate\">(how many numbers generate a subgroup of that size)</span></div>\n  <div class=\"cc6-pills\" id=\"cc6-pills\"></div>\n  <div class=\"dpw-readout\">\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc6-zord\">&ndash;</span><span class=\"dpw-cap\">numbers <span class=\"dpw-var\">g</span> reaches</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc6-zfac\">&ndash;</span><span class=\"dpw-cap\"><span class=\"dpw-var\">p</span> &minus; 1</span></div>\n  </div>\n  <div class=\"dpw-verdict\" id=\"cc6-zv\">&ndash;</div>\n  <div class=\"dpw-hint\">A filled cell is a power of g mod p. The size of the subgroup g generates always divides p &minus; 1, so the only sizes that can appear are the ones listed.</div>\n</div>\n<p>For p = 23, p − 1 is 22 = 2 × 11. Ten of the 22 numbers generate a subgroup of exactly 11 elements, and 11 is prime. That subgroup is what the next section builds on purpose, with q = 11 and k = 2.</p>\n<h2 id=\"forcing-the-math-into-a-prime-order-subgroup\" style=\"position:relative;\"><a href=\"#forcing-the-math-into-a-prime-order-subgroup\" aria-label=\"forcing the math into a prime order subgroup 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>Forcing the math into a prime-order subgroup</h2>\n<p>If it is the case that you can break this group of composite order into smaller subgroups to do some sort of attack, what is best practice is that the order of the group should be prime. Because if its order is prime, it can't be broken down into smaller factors.</p>\n<p>What we try to do, in the case of the discrete log problem where we're dealing with this multiplicative group of integers, is create a subgroup that is of prime order. How should we go about doing this? Because if we choose a large prime p here, we know that the total number of elements in this group goes up to p − 1. So we will always end up with a composite number.</p>\n<p>The way to do this is we choose q, which is a large prime, and then we also choose p, which is a larger prime. So we basically choose two prime numbers. And we choose p such that p = kq + 1, where q is this prime that we just chose and k is just an integer, a constant.</p>\n<div class=\"dpw-formula\">p = kq + 1 &nbsp;&nbsp;&rArr;&nbsp;&nbsp; |Z<sub>p</sub><sup>&lowast;</sup>| = p &minus; 1 = kq</div>\n<p>Let's see what happens to the size of the group. The size of this group is p − 1. If our p is a constant times another prime plus one, we get kq + 1 − 1, which equals kq. So the size of that group now will be a constant times a prime.</p>\n<p>So q divides p − 1. And if q perfectly divides p − 1, then there's a theorem that guarantees our larger group, Z<sub>p</sub><sup>∗</sup>, has a subgroup of order q. If that subgroup exists, which is a smaller subgroup, but it's a safer subgroup, then you can do all your operations in that subgroup now, instead of doing it on this one where the size is a composite number.</p>\n<h2 id=\"the-same-idea-on-bitcoins-curve\" style=\"position:relative;\"><a href=\"#the-same-idea-on-bitcoins-curve\" aria-label=\"the same idea on bitcoins curve 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 same idea on Bitcoin's curve</h2>\n<p>The reason I wanted to show this is that last week I was myself a little confused about this elliptic curve discrete log problem. We defined it like this:</p>\n<div class=\"dpw-formula\">Q = k &middot; G &nbsp;(mod p)</div>\n<p>Here, Q and G are points on the elliptic curve, and these are all points that belong to a finite field. For now, just assume it contains integers up to p. The size of this field is p. Q, in the context of Bitcoin, is our public key, and G is our generator. We're multiplying it by k, which is our secret or private key. And as someone pointed out last time, k is not a point on this graph.</p>\n<p>For Bitcoin, y<sup>2</sup> = x<sup>3</sup> + 7.</p>\n<p>Suppose you have a p, which is prime. It has a lot of elements. Now you layer this equation, y<sup>2</sup> = x<sup>3</sup> + 7, on top of this whole set of possible numbers. You're looking for values in this finite set that satisfy this equation. Some values will not work, and so they will be excluded. You started off with order p, and then you are left with, I called it n, which is all of the points, (x<sub>1</sub>, y<sub>1</sub>), (x<sub>2</sub>, y<sub>2</sub>). These are all values in this field of size a big prime p, and they are also coordinates on this curve. The size of that set, I called it n.</p>\n<p>In the case of Bitcoin, this is also a prime, and it's close to p. I'm sure this was on purpose. They purposefully chose the equation so this is the case. By the way, this is a different prime, different from p. And since it's a prime, its factors are only 1 and n.</p>\n<p>Now your k, the private key, is chosen from another field. You have a field of size p, which is a prime. Now you have another field, which is the field over which the scalar value k is chosen. We can call this field q, and the size of this field is n.</p>\n<p>The key clarification I got was that we have two fields, and they are two different fields. One is where the k is chosen from, and one is where these points Q and G are chosen. Field p works over the coordinates Q and G, and field q works over the scalar k.</p>\n<div class=\"dpw-formula\">k (mod q) &nbsp;&nbsp;&nbsp;&nbsp; Q, G (mod p)</div>\n<p>I think the reason for this is, like I tried to explain with the standard discrete log problem, that you try to force the math into a subgroup of a prime order. For Bitcoin, they chose the curve specifically so that n is also prime. But if it was not prime, you could have done an extra step, a similar exercise, to find that subgroup which is of prime order.</p>\n<p>Someone pushed back on \"two fields\" near the end. Their point: q is not chosen, it is derived. It is the number of points that satisfy the equation for the given p, and k cannot usefully be bigger than it, because after q steps you are back where you started, like a clock. What I'm wondering is, aren't we using two fields, because our first one is from 0 to p − 1? k is not chosen from this. So we would need a separate field of a different order. The size is n.</p>\n<p>Both descriptions are the same thing. Because n is prime, the whole numbers mod n are themselves a field, and that is the field the scalar k lives in.</p>\n<p>Someone suggested trying it with small numbers: keep the equation y<sup>2</sup> = x<sup>3</sup> + 7 and take p as 13. I agree. I think it helps if you work with small numbers.</p>\n<p>So here it is. How many points are on the curve for a small p, is that number prime, and can every point reach all the others?</p>\n<div class=\"dpw\" id=\"cc6-curve\">\n  <div class=\"dpw-toggle-row\">\n    <span class=\"dpw-toggle-cap\">Field prime p &nbsp;<span class=\"dpw-inflate\">(the curve is always y&sup2; = x&sup3; + 7)</span></span>\n    <button class=\"dpw-toggle\" data-p=\"13\" data-on=\"true\">13</button>\n    <button class=\"dpw-toggle\" data-p=\"17\" data-on=\"false\">17</button>\n    <button class=\"dpw-toggle\" data-p=\"31\" data-on=\"false\">31</button>\n    <button class=\"dpw-toggle\" data-p=\"43\" data-on=\"false\">43</button>\n    <button class=\"dpw-toggle\" data-p=\"79\" data-on=\"false\">79</button>\n  </div>\n  <div class=\"dpw-controls\">\n    <label class=\"dpw-label\">Generator G &nbsp; <span class=\"dpw-val\" id=\"cc6-g\">&ndash;</span> &nbsp;<span class=\"dpw-inflate\">(or click a point)</span>\n      <input type=\"range\" id=\"cc6-gr\" min=\"0\" max=\"5\" step=\"1\" value=\"0\" />\n    </label>\n    <label class=\"dpw-label\" style=\"margin-top:12px\">Private key k, the number of hops &nbsp; <span class=\"dpw-val\" id=\"cc6-k\">&ndash;</span>\n      <input type=\"range\" id=\"cc6-kr\" min=\"1\" max=\"7\" step=\"1\" value=\"5\" />\n    </label>\n  </div>\n  <svg id=\"cc6-svg\" viewBox=\"0 0 480 480\" class=\"dpw-svg\" role=\"img\" aria-label=\"The points of the curve over a small prime field, with the hops from G to Q\"></svg>\n  <div class=\"dpw-readout\">\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc6-n\">&ndash;</span><span class=\"dpw-cap\">points on the curve, <span class=\"dpw-var\">n</span></span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc6-reach\">&ndash;</span><span class=\"dpw-cap\">points G can reach</span></div>\n    <div class=\"dpw-stat\"><span class=\"dpw-num\" id=\"cc6-q\">&ndash;</span><span class=\"dpw-cap\">Q = <span class=\"dpw-var\">k</span> &middot; G</span></div>\n  </div>\n  <div class=\"dpw-verdict\" id=\"cc6-cv\">&ndash;</div>\n  <div class=\"dpw-hint\">Every dot is a pair (x, y) below p that satisfies the equation mod p. n counts those dots plus the point at infinity. Filled dots are the ones G reaches by adding itself. The line follows the hops G, 2G, 3G, up to kG.</div>\n</div>\n<p>For p = 13 the curve has 7 points, and 7 is prime, so every point reaches all of them. For p = 17 it has 18, and a point can get stuck in a subgroup of 2, 3, 6 or 9. For p = 31 it has 21 = 3 × 7, which is not prime but contains a subgroup of prime order 7: that is the extra step mentioned above. The count is close to p but is a different number, and it can land on either side: 7 for p = 13, 18 for p = 17.</p>\n<h2 id=\"hopping-around-the-curve\" style=\"position:relative;\"><a href=\"#hopping-around-the-curve\" aria-label=\"hopping around the curve 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>Hopping around the curve</h2>\n<p>The generator is fixed. You can Google what the Bitcoin generator is. This is hard-coded in software, hardware, etc. Now the k, which is your secret key, comes from a group of prime order. Remember, I said that if you have a group which is of composite order, you could do attacks. But if you have a group of prime order, the maximum you can reduce the problem to is that prime itself and one. And one doesn't really tell you anything, because you can't break it down further.</p>\n<p>You're going to hop k times. I told you many times that the goal of the generator is to generate the entire group if you multiply it by itself. I showed you that with this multiplicative group. The case stays the same for elliptic curves. If I pick k = 7, I'm going to go from this generator here, 1. Maybe this was the next point, 2. Then maybe this was the next point, 3. Then 4, 5, 6, 7. And then we stop here.</p>\n<p>This is not like Z<sub>p</sub><sup>∗</sup>. Z<sub>p</sub><sup>∗</sup> is a continuous set of 1, 2, 3, 4, 5, all the way up to p − 1. This looks random. You're hopping around 7 times. You end up here. What is this point now? Q, which is our public key. Of course, some stuff probably happens beyond this to make it the true public key. This is the raw public key.</p>\n<p>Now your adversary is wondering. This G is public, so they know this point, and they also know Q, because that's your public key. They're wondering, how did you get from here to here? How many hops did you make? We know we made seven hops, but because of the nature of this curve, even if the points are close together, you have no idea how to get to that point. You basically have to brute force.</p>\n<h2 id=\"two-fields-one-reason\" style=\"position:relative;\"><a href=\"#two-fields-one-reason\" aria-label=\"two fields one reason 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>Two fields, one reason</h2>\n<p>Initially what I didn't understand is that we're actually operating over two fields. One is the field for the scalar value, one is the field for the coordinate points. Then I tried to understand why that is the case. I think the intuition is similar to what I explained with the discrete log problem, where you want to do your operations in a set or a field which is of order a prime number, because you cannot break those down into subgroups of those factors and then solve those. Solving smaller numbers is easier. But if the order itself is a prime number, then you're stuck with that whole value.</p>\n<p>We said we can do this trick called binary exponentiation to calculate the discrete log equation quickly. For this equation, why is calculating it easy? What are we doing? Let's talk about this next week.</p>\n<style>\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;\n}\n.dpw * { box-sizing: border-box; }\n/* index.scss sets font on every span directly; let class-less spans inherit from the widget instead */\n.dpw span:not([class]) { font-size: inherit; line-height: inherit; font-family: inherit; }\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-controls { margin-bottom: 14px; }\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-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 (k is a number, G is a point) */\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: 10px; }\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-inflate { font-size: 11px; color: #94a6b8; }\n.cc6-cells { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 2px; }\n.cc6-cell { font-family: 'Inconsolata', monospace; font-size: 13px; width: 32px; padding: 5px 0; text-align: center;\n  border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink2); cursor: pointer; }\n.cc6-cell[data-in=true] { background: #dcefe3; color: var(--green); border-color: #b9dcc6; }\n.cc6-cell[data-g=true] { outline: 2px solid var(--maroon); outline-offset: 1px; color: var(--maroon-d); font-weight: 700; }\n.cc6-pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }\n.cc6-pill { font-family: 'Inconsolata', monospace; font-size: 12px; padding: 4px 9px; border-radius: 12px;\n  border: 1px solid var(--line); color: var(--ink2); background: #fbfcfe; }\n.cc6-pill[data-on=true] { background: var(--maroon); color: #fff; border-color: var(--maroon); }\n.cc6-pill[data-prime=true] { border-color: var(--green); }\n@media (max-width: 520px) { .dpw-readout { gap: 16px; } .dpw-num { font-size: 19px; } .cc6-cell { width: 30px; } }\n@media (prefers-reduced-motion: reduce) { .dpw * { transition: none !important; } }\n</style>\n<script>\n(function () {\n  var root = document.getElementById('cc6-zp');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { if (!el) return; 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\n  var p = 23, g = 2;\n  var cells = root.querySelector('#cc6-zcells'), pills = root.querySelector('#cc6-pills');\n  function isPrime(n) { if (n < 2) return false; for (var d = 2; d * d <= n; d++) if (n % d === 0) return false; return true; }\n  function factor(n) { var out = [], d = 2; while (n > 1) { var e = 0; while (n % d === 0) { n /= d; e++; } if (e) out.push(d + (e > 1 ? '^' + e : '')); d++; } return out.join(' × ') || '1'; }\n  function span(a) { var s = {}, v = 1; do { v = (v * a) % p; s[v] = true; } while (v !== 1); return s; }   // everything a reaches\n  function size(s) { return Object.keys(s).length; }\n\n  function build() {\n    cells.innerHTML = '';\n    for (var a = 1; a < p; a++) (function (a) {\n      var c = document.createElement('button');\n      c.className = 'cc6-cell'; c.textContent = a; c.setAttribute('data-a', a);\n      on(c, 'click', function () { g = a; draw(); });\n      cells.appendChild(c);\n    })(a);\n  }\n\n  function draw() {\n    var s = span(g), ord = size(s), tally = {};\n    for (var a = 1; a < p; a++) { var o = size(span(a)); tally[o] = (tally[o] || 0) + 1; }\n    [].forEach.call(cells.children, function (c) {\n      var a = +c.getAttribute('data-a');\n      c.setAttribute('data-in', String(!!s[a])); c.setAttribute('data-g', String(a === g));\n    });\n    pills.innerHTML = Object.keys(tally).map(Number).sort(function (x, y) { return x - y; }).map(function (o) {\n      return '<span class=\"cc6-pill\" data-size=\"' + o + '\" data-count=\"' + tally[o] + '\" data-on=\"' + (o === ord) + '\" data-prime=\"' + isPrime(o) + '\">size ' + o + ': ' + tally[o] + '</span>';\n    }).join('');\n    root.querySelector('#cc6-zcap').textContent = 'Numbers 1 to ' + (p - 1) + ', with g = ' + g;\n    root.querySelector('#cc6-zord').textContent = ord + ' of ' + (p - 1);\n    root.querySelector('#cc6-zfac').textContent = (p - 1) + ' = ' + factor(p - 1);\n    var v = root.querySelector('#cc6-zv');\n    if (ord === 1) { v.className = 'dpw-verdict'; v.textContent = '1 only reaches itself'; }\n    else if (isPrime(ord)) { v.className = 'dpw-verdict dpw-ok'; v.textContent = g + ' generates a subgroup of prime order ' + ord + (ord < 5 ? ': it cannot be split, but ' + ord + ' elements is far too small to hide anything' : ': it cannot be split any further'); }\n    else if (ord === p - 1) { v.className = 'dpw-verdict'; v.textContent = g + ' generates the whole group, but ' + ord + ' = ' + factor(ord) + ', so it splits into smaller pieces'; }\n    else { v.className = 'dpw-verdict'; v.textContent = g + ' generates a subgroup of size ' + ord + ' = ' + factor(ord) + ', which still splits'; }\n  }\n\n  [].forEach.call(root.querySelectorAll('[data-p]'), function (b) {\n    on(b, 'click', function () {\n      p = +b.getAttribute('data-p'); g = 2;\n      [].forEach.call(root.querySelectorAll('[data-p]'), function (o) { o.setAttribute('data-on', String(o === b)); });\n      build(); draw();\n    });\n  });\n  build(); draw();\n})();\n</script>\n<script>\n(function () {\n  var root = document.getElementById('cc6-curve');\n  if (!root) return;\n  if (root._cleanup) root._cleanup();\n  var L = [];\n  function on(el, ev, fn) { if (!el) return; 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\n  var SVG = 'http://www.w3.org/2000/svg', svg = root.querySelector('#cc6-svg');\n  var gr = root.querySelector('#cc6-gr'), kr = root.querySelector('#cc6-kr');\n  var p = 13, pts = [], gi = 0;\n  function el(n, at, txt) { var e = document.createElementNS(SVG, n); for (var k in at) e.setAttribute(k, at[k]); if (txt !== undefined) e.textContent = txt; return e; }\n  function mod(a) { return ((a % p) + p) % p; }\n  function inv(a) { var r = 1, b = mod(a), e = p - 2; while (e > 0) { if (e & 1) r = (r * b) % p; b = (b * b) % p; e >>= 1; } return r; }   // Fermat: a^(p-2)\n  function isPrime(n) { if (n < 2) return false; for (var d = 2; d * d <= n; d++) if (n % d === 0) return false; return true; }\n  function factor(n) { var out = [], d = 2; while (n > 1) { var e = 0; while (n % d === 0) { n /= d; e++; } if (e) out.push(d + (e > 1 ? '^' + e : '')); d++; } return out.join(' × '); }\n  // group law on y^2 = x^3 + 7 over F_p; null is the point at infinity\n  function add(P, Q) {\n    if (!P) return Q; if (!Q) return P;\n    if (P[0] === Q[0] && mod(P[1] + Q[1]) === 0) return null;\n    var m = (P[0] === Q[0] && P[1] === Q[1]) ? mod(3 * P[0] * P[0] * inv(2 * P[1])) : mod((Q[1] - P[1]) * inv(Q[0] - P[0]));\n    var x3 = mod(m * m - P[0] - Q[0]);\n    return [x3, mod(m * (P[0] - x3) - P[1])];\n  }\n  function key(P) { return P ? P[0] + ',' + P[1] : 'O'; }\n  function name(P) { return P ? '(' + P[0] + ', ' + P[1] + ')' : 'O'; }\n\n  function setP(np) {\n    p = np; pts = [];\n    for (var x = 0; x < p; x++) for (var y = 0; y < p; y++) if (mod(y * y - (x * x * x + 7)) === 0) pts.push([x, y]);\n    gi = 0; gr.max = pts.length - 1; gr.value = 0;\n    resetK(5);\n  }\n  function hops(G) { var out = [], R = G; while (R) { out.push(R); R = add(R, G); } return out; }   // G, 2G, ... up to but not including O\n  function resetK(want) { var ord = hops(pts[gi]).length + 1; kr.max = ord; kr.value = Math.min(want, ord - 1) || 1; }\n\n  function draw() {\n    var G = pts[gi], H = hops(G), ord = H.length + 1, N = pts.length + 1, k = +kr.value;\n    var Q = k <= H.length ? H[k - 1] : null;\n    var reach = {}; H.forEach(function (P) { reach[key(P)] = true; });\n    var W = 480, M = 26, S = (W - 2 * M) / (p - 1 || 1);\n    var px = W / (svg.getBoundingClientRect().width || W), FS = Math.min(18, 11 * px);\n    function X(v) { return M + v * S; } function Y(v) { return W - M - v * S; }\n    var rad = Math.max(2.2, Math.min(7, S * 0.36));\n\n    while (svg.firstChild) svg.removeChild(svg.firstChild);\n    svg.appendChild(el('rect', { x: M - S / 2, y: M - S / 2, width: W - 2 * M + S, height: W - 2 * M + S, fill: 'none', stroke: '#dae4ed' }));\n    var d = '';\n    for (var i = 0; i < Math.min(k, H.length); i++) d += (i ? 'L' : 'M') + X(H[i][0]).toFixed(1) + ' ' + Y(H[i][1]).toFixed(1);\n    if (d) svg.appendChild(el('path', { d: d, fill: 'none', stroke: '#a72e2b', 'stroke-width': 1.2, 'stroke-opacity': 0.55 }));\n    pts.forEach(function (P, idx) {\n      var isG = idx === gi, isQ = Q && P[0] === Q[0] && P[1] === Q[1];\n      var c = el('circle', { cx: X(P[0]), cy: Y(P[1]), r: isG || isQ ? rad + 1.5 : rad, style: 'cursor:pointer',\n        fill: isQ ? '#1b2228' : isG ? '#a72e2b' : reach[key(P)] ? '#3f8f5b' : '#fff',\n        stroke: reach[key(P)] ? 'none' : '#8ba2b8', 'stroke-width': 1, 'data-pt': key(P), 'data-reach': String(!!reach[key(P)]) });\n      on(c, 'click', function () { gi = idx; gr.value = idx; resetK(+kr.value); draw(); });\n      svg.appendChild(c);\n    });\n    if (k <= 12) for (var j = 0; j < Math.min(k, H.length); j++)\n      svg.appendChild(el('text', { x: X(H[j][0]) + rad + 3, y: Y(H[j][1]) - rad - 2, 'font-size': FS, fill: '#6a1d1b', 'font-family': 'Inconsolata, monospace' }, String(j + 1)));\n\n    root.querySelector('#cc6-g').textContent = name(G);\n    root.querySelector('#cc6-k').textContent = k;\n    root.querySelector('#cc6-n').textContent = N + (isPrime(N) ? ' (prime)' : ' = ' + factor(N));\n    root.querySelector('#cc6-reach').textContent = ord + ' of ' + N;\n    root.querySelector('#cc6-q').textContent = Q ? name(Q) : 'O';\n    var v = root.querySelector('#cc6-cv'), tail = Q ? '' : '. k = ' + k + ' lands on the point at infinity';\n    if (isPrime(N)) { v.className = 'dpw-verdict dpw-ok'; v.textContent = 'n = ' + N + ' is prime: this G, like every point, reaches all ' + N + tail; }\n    else if (ord === N) { v.className = 'dpw-verdict'; v.textContent = 'this G reaches all ' + N + ', but ' + N + ' = ' + factor(N) + ' is not prime, so the problem splits' + tail; }\n    else { v.className = 'dpw-verdict' + (isPrime(ord) ? ' dpw-ok' : ''); v.textContent = 'this G is stuck in a subgroup of ' + ord + (isPrime(ord) ? ' (prime)' : '') + ' out of ' + N + tail; }\n  }\n\n  [].forEach.call(root.querySelectorAll('[data-p]'), function (b) {\n    on(b, 'click', function () {\n      [].forEach.call(root.querySelectorAll('[data-p]'), function (o) { o.setAttribute('data-on', String(o === b)); });\n      setP(+b.getAttribute('data-p')); draw();\n    });\n  });\n  on(gr, 'input', function () { gi = +gr.value; resetK(+kr.value); draw(); });\n  on(kr, 'input', draw); on(window, 'resize', draw);\n  setP(13); draw();\n})();\n</script>","headings":[{"value":"The problem with p − 1","depth":2},{"value":"Forcing the math into a prime-order subgroup","depth":2},{"value":"The same idea on Bitcoin's curve","depth":2},{"value":"Hopping around the curve","depth":2},{"value":"Two fields, one reason","depth":2}],"frontmatter":{"date_created":"2026-09-11","path":"/blog/crypto-club-prime-order-subgroups","tags":["Cryptography","Bitcoin","Elliptic Curves"],"title":"Why Bitcoin Wants A Group Of Prime Order"}},"nextPost":{"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"}}},"pageContext":{"prevPostPath":"/blog/breaking-my-own-fiat-shamir-binding","currPostPath":"/blog/crypto-club-prime-order-subgroups","nextPostPath":"/blog/crypto-club-forging-without-the-key"}},"staticQueryHashes":[]}