<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Srishti Rathi on Medium]]></title>
        <description><![CDATA[Stories by Srishti Rathi on Medium]]></description>
        <link>https://medium.com/@rathisrishti?source=rss-97a6cfac0d34------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Srishti Rathi on Medium</title>
            <link>https://medium.com/@rathisrishti?source=rss-97a6cfac0d34------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:02:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rathisrishti/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Edge Cases to Mathematical Proofs: What Formal Verification Actually Promises in the Age of AI]]></title>
            <link>https://medium.com/@rathisrishti/from-edge-cases-to-mathematical-proofs-what-formal-verification-actually-promises-in-the-age-of-ai-ae71f9111231?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae71f9111231</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[formal-verification]]></category>
            <category><![CDATA[lean]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Sat, 19 Sep 2026 20:13:16 GMT</pubDate>
            <atom:updated>2026-09-19T20:45:27.649Z</atom:updated>
            <content:encoded><![CDATA[<p>I really got into this rabbit hole of software engineering, languages, errors, edge cases, security, threat models, and, last but not least, formal verification using Lean. As mentioned in Yoichi Hirai’s blog post,<a href="https://blog.zksecurity.xyz/posts/end-coding/">The Final Form of Software Development</a>, Hirai lays out his approach: writing code in RISC-V assembly and proving it correct in a proof assistant like Lean. That line stuck with me and sent me down this whole path.</p><p>When I started learning, one of the first things I ran into was the classic taxonomy of errors: syntax errors, runtime errors, semantic errors, and floating-point/round-off errors. But then I kept thinking: what about logical errors, the kind caused by plain human reasoning gone wrong? It turns out most taxonomies quietly fold “logical errors” into “semantic errors,” but that always felt like a bit of a cop-out to me. A semantic error caused by a type mismatch and a semantic error caused by flawed business logic are not the same animal. In the second case, the code does exactly what you told it to do; you just told it the wrong thing. That’s a specification problem, not an implementation problem, and it matters because it’s the one category no tool can fully catch for you.</p><p>All these big tech companies want engineers with strong competitive programming skills because CP is basically training for finding edge cases quickly and efficiently. But here’s the thing we already know: no one can find all the edge cases in any real codebase. That’s exactly why we can never claim that any nontrivial codebase is 100% bug-free or secure. And the more complex a system gets, the more hands and ideas touch it, the more likely it is to carry bugs, because the space of undefined edge cases grows combinatorially with the system, not linearly. Test coverage, as a fraction of all possible execution paths, asymptotically shrinks toward zero as the system scales. That’s the real reason “we tested it thoroughly” stops meaning much past a certain size.</p><p>So now, in the era of AI, where models are getting frighteningly good at finding bugs, how do we keep systems secure? This is where Hirai’s words come back into play: formal verification. If an adversary, or an AI-assisted adversary, gets better at finding exploitable edge cases than we are at defending against them, then relying on testing and fuzzing becomes a losing race by definition, as we’re doing probabilistic defense against something that can search near-exhaustively. Formal proof is one of the only strategies that doesn’t degrade under that asymmetry, because “we tested it really hard” and “we proved it holds for every input, forever” are different categories of claim, not just different amounts of confidence.</p><p>I originally imagined formal verification like this: if a competitive programming problem says the input range is 1 to 1000, formal verification is a system that mechanically checks the code against every single value from 1 to 1000. That’s not quite right, and the real version is more interesting. Brute-force checking of every value in a bounded range is called model checking. It’s a real and useful technique, but it only works because the range is finite and small enough to enumerate. What tools like Lean actually do is different: theorem proving. Instead of enumerating values, you construct a logical proof, usually by induction, that a property holds for every possible value, including infinite domains: all natural numbers, arbitrary-length byte strings, and unbounded loops. That’s the real power of it. It’s not “check harder,” it’s “prove it can’t fail,” the same way you’d prove a fact about all integers without checking each one by hand.</p><p>But making the claim that formal verification means “100% sure it is correct at every value” isn’t quite right either, and it’s worth being precise about why, because this is exactly where bugs can still hide in “formally verified” systems:</p><ul><li>The spec can be wrong. Formal verification proves your code matches your specification, not that your specification captures what you actually meant. If you prove “balance never goes negative” but forget to formalize “total supply is conserved,” the proof is airtight and the system can still be broken. This is arguably why Yoichi Hirai pushes all the way down to RISC-V assembly rather than stopping at a high-level model. Every unverified layer above the hardware, such as the compiler and OS, is a place where the gap between the spec and reality can quietly reopen.</li><li>There’s still a trusted computing base. Lean’s proof-checking kernel, the hardware, and the compiler that built the checker are trusted, not themselves proven. Keeping that kernel small and heavily scrutinized, as Lean does, reduces the risk, but doesn’t erase it.</li><li>It’s expensive. seL4, a formally verified microkernel, took person-decades of proof effort for around 10,000 lines of C. That’s the real trade-off: full verification gets reserved for small, high-stakes, stable components, such as kernels, compilers (CompCert is the classic example), cryptographic primitives, and smart contracts. Hirai’s 2017 work, Defining the Ethereum Virtual Machine for Interactive Theorem Provers, formalized the EVM in Lem and used Isabelle/HOL to prove safety properties of smart contracts. It illustrates how formal methods can be applied to a domain where bugs can have irreversible financial consequences.</li></ul><p>So the honest version of the claim isn’t “formal verification makes software 100% bug-free.” It’s that formal verification eliminates the gap between specification and implementation completely, provably, for every input, including infinite ones. What it can’t do is eliminate the gap between human intent and the specification itself. That gap is where logical errors, the human-reasoning kind, actually live. They don’t disappear under formal verification. They just migrate upstream, into the one place no proof assistant can check for you: whether you asked the right question in the first place.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae71f9111231" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is even the purpose of Zero Knowledge, and why am I so fascinated by it?]]></title>
            <link>https://medium.com/@rathisrishti/what-is-even-the-purpose-of-zero-knowledge-and-why-am-i-so-fascinated-by-it-da2caecec1b3?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/da2caecec1b3</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[zks]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 21:26:10 GMT</pubDate>
            <atom:updated>2026-09-14T21:26:10.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*ZmxbKd3mLOx5bbkQBtgFrA.png" /><figcaption>first research paper on ZK</figcaption></figure><p>Hello everyone, I am starting the series of ZK concepts where I try to explain them using first principles and in the easiest way possible. So, anyone who has basic knowledge about this can study it.</p><p>There are already many articles written before me, and great researchers have written them, which provides great resources like rareskill and all the research papers.</p><p>But still, some new people are afraid to start because of the complexity and get overwhelmed, and the reason for the complexity is how so many parts come together and meet at ZK.</p><p>I was introduced to ZK from blockchain. And I think most people get to know about ZK from this same thing.</p><p>This is how I was introduced to ZK:</p><p>WEB3 -&gt; BLOCKCHAIN -&gt; SMART CONTRACT -&gt; EVM -&gt; ZK ROLLUPS -&gt; ZK</p><p>And my mind clicked: Wait, what is ZK?</p><p>But ZK is not a subset of blockchain, it is a cryptographic technique that blockchain heavily uses.</p><p>I don’t know where to start, so I start from the start.</p><p>We all want security and privacy, but we want it in the most efficient way. Every research going on right now in the world of AI or quantum computing, everyone wants to do things fast and with less cost. But security is such a big factor in society because of obvious reasons. We also want it to be secure.</p><p>So, now we have three factors: security, money, and time, and every story revolves around it. I don’t know how not to go into deep topics, but I will try not to, but still I want it to be enjoyable.</p><p>The main motive of the first research paper on ZK in 1985 was, “Can I prove it while revealing nothing except its truth?” and they actually showed that, yes, they could do this.</p><p>And from here, everything got started.</p><p>But why we even want to hide the information when we eventually want to prove it.</p><p>Okay, so let’s imagine you want to participate in an online contest and they have high prize money. They don’t want any malicious user to enter with any fake name or enter twice, so they ask for your identity. But you don’t want to show them your identity because it can get leaked in the future, so they come up with a solution of using ZK. Here, your ID will never reach them, but the proof that you are a valid user. And it will solve both problem of privacy and authentication.</p><p>And that’s the whole concept of zk.</p><p>Right now, it is used in so many complex things, but the main motivation was always privacy.</p><p>So, why it is connected with mostly Web3 instead of any other tech field even though it was invented years before blockchains became mainstream?</p><p>Because the main point of blockchain was decentralization, meaning everything is open source and anyone can see it anytime which is great for transparency but terrible for privacy. And it also has the verification problem because it can be very expensive, so ZK solves both of these by generating proofs.</p><p>Web2 simply doesn’t use it everywhere because it already has trusted authorities for verification and privacy. And ZK and blockchain themselves state: don’t trust, verify it yourself. That’s why ZK is such an important part of blockchain and DeFi. There are other uses of ZK except blockchain, like identity, healthcare, finance, voting, databases, cloud computing, and many other things.</p><p>So, why is ZK not mainstream till now?</p><p>Because its idea was old, but making ZK practical is extremely difficult. The 1985 paper gave us just the concept. It did not give us a cheap, general-purpose technology that you could drop into an application.</p><p>This was the timeline, basically:</p><p>1985</p><p>→ Goldwasser, Micali, Rackoff</p><p>→ Zero-knowledge proofs</p><p>1990s–2000s</p><p>→ Interactive proofs</p><p>→ PCPs and related developments</p><p>→ More efficient proof systems</p><p>2010s</p><p>→ SNARK revolution</p><p>→ Pinocchio</p><p>→ Groth16</p><p>2020s</p><p>→ PLONK</p><p>→ STARKs</p><p>→ FRI</p><p>→ Recursive proofs</p><p>→ zkVMs</p><p>→ ZK-rollups</p><p>→ zkML</p><p>2026</p><p>→ Lattice-based STARKs</p><p>→Recursive STARK mempools</p><p>→And every day, new things are coming.</p><p>Researchers are continuously working to make ZK more efficient in terms of time and money, so that we can achieve good results while keeping privacy intact as I said earlier, these are the main points every story revolves around.</p><p>So, here comes the most important part even if it is so hard, why am I so fascinated by it?</p><p>I feel that it is capable of doing magical things using maths. It is convincing the verifier that something is true without even telling it, and the day I read about this, I thought I saw such a cool tech. That’s the whole reason to be in the tech field, right? Learning things that are so obvious because maths is such an obvious field, but still so magical.</p><p>(First paper referenced: Goldwasser, Micali, Rackoff 1985) — <a href="https://www.cs.miami.edu/home/burt/learning/csc609.221/goldwasser-micali-rackoff-knoweldge-complexity.pdf">https://www.cs.miami.edu/home/burt/learning/csc609.221/goldwasser-micali-rackoff-knoweldge-complexity.pdf</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da2caecec1b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a STARK Prover From Scratch in Rust: Lessons Learned]]></title>
            <link>https://medium.com/@rathisrishti/building-a-stark-prover-from-scratch-in-rust-lessons-learned-6340614424fa?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/6340614424fa</guid>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[zkstark]]></category>
            <category><![CDATA[zks]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 07:01:30 GMT</pubDate>
            <atom:updated>2026-08-08T07:01:30.014Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What implementing finite fields, FFTs, execution traces, polynomial constraints, Merkle commitments, Fiat–Shamir, and FRI taught me about how STARKs actually work.</em></p><p>Reading about STARKs and building one are two very different experiences.</p><p>When I first studied STARKs, I understood the components individually: finite fields, execution traces, AIR, low-degree extensions, Merkle trees, Fiat–Shamir, and FRI.</p><p>But understanding each component did not automatically mean I understood the <strong>prover</strong>.</p><p>That changed when I started implementing a small STARK prover in Rust.</p><p>The project forced me to understand not just what each component does, but <strong>why it exists, what data it consumes, what it produces, and why the next stage depends on it</strong>.</p><p>The complete pipeline started looking less like a collection of cryptographic ideas and more like an engineering system:</p><pre>Computation<br>     ↓<br>Execution Trace<br>     ↓<br>AIR Constraints<br>     ↓<br>Trace Polynomial<br>     ↓<br>FFT / LDE<br>     ↓<br>Merkle Commitment<br>     ↓<br>Fiat–Shamir Challenges<br>     ↓<br>Composition Polynomial<br>     ↓<br>FRI<br>     ↓<br>Query Openings<br>     ↓<br>STARK Proof</pre><p>This article is about the lessons I learned while building that pipeline from scratch.</p><h3>The First Lesson: Start With the Field, Not the Prover</h3><p>My implementation started with something that initially felt far removed from STARKs: finite-field arithmetic.</p><p>For a small educational implementation, I used the prime field <strong>F₉₇</strong>.</p><p>Every value lives in:</p><p><strong>{0, 1, 2, …, 96}</strong></p><p>and arithmetic is performed modulo 97.</p><p>For example:</p><p><strong>95 + 5 = 3 mod 97</strong></p><p>The field implementation needed the usual operations:</p><pre>Addition<br>Subtraction<br>Multiplication<br>Negation<br>Exponentiation<br>Inverse<br>Division</pre><p>At first, this feels like infrastructure.</p><p>But almost everything above it depends on these operations being correct.</p><p>Polynomial interpolation uses the field.</p><p>FFT uses the field.</p><p>AIR constraints use the field.</p><p>FRI folding uses the field.</p><p>Even a tiny mistake in inversion or modular subtraction can eventually appear as a mysterious failure several layers higher.</p><p>One thing that became much clearer while implementing the field was <strong>why the choice of prime matters</strong>.</p><p>For F₉₇:</p><p><strong>97 − 1 = 96 = ²⁵ × 3</strong></p><p>The non-zero elements of a prime field form a multiplicative group of size p − 1, so F₉₇ contains a power-of-two subgroup of size 32.</p><p>That gives us roots of unity suitable for small FFT domains.</p><pre>Prime Field F₉₇<br>      ↓<br>97 − 1 = 96<br>      ↓<br>96 = 2⁵ × 3<br>      ↓<br>Power-of-two subgroup<br>      ↓<br>Roots of Unity<br>      ↓<br>FFT / STARK Domains</pre><p>So field selection is not just choosing a prime. It directly determines which evaluation domains are available.</p><h3>FFTs Stopped Feeling Like an Optimization</h3><p>The next major piece was polynomial arithmetic.</p><p>A STARK execution trace begins as values:</p><p><strong>3, 5, 7, 9, 11, 13, 15, 17</strong></p><p>But the proof system wants to reason about a polynomial T(X) satisfying:</p><p><strong>T(ωⁱ) = trace[i]</strong></p><p>That means constantly moving between two representations:</p><pre>Evaluation Form<br>      ↓<br>     IFFT<br>      ↓<br>Coefficient Form<br>      ↓<br>      FFT<br>      ↓<br>Evaluation Form</pre><p>Before implementing this, I mostly thought of FFTs as a performance optimization.</p><p>After implementing the prover, I started seeing them as part of the architecture.</p><p>The prover repeatedly needs to interpolate and evaluate polynomials over structured domains. Without efficient transforms, these operations quickly become expensive.</p><p>It also taught me to keep track of <strong>what representation a polynomial is currently in</strong>.</p><p>A vector of field elements might represent coefficients:</p><p><strong>[a₀, a₁, a₂, …]</strong></p><p>or evaluations:</p><p><strong>[P(x₀), P(x₁), P(x₂), …]</strong></p><p>Those vectors may look identical in Rust.</p><p>Mathematically, they mean completely different things.</p><p>That distinction caused more confusion than I expected.</p><h3>The Execution Trace Is Where the Program Becomes Algebra</h3><p>For the first trace, I deliberately used a tiny computation:</p><p><strong>xᵢ₊₁ = xᵢ + 2</strong></p><p>Starting at 3 gives:</p><p><strong>3 → 5 → 7 → 9 → 11 → 13 → 15 → 17</strong></p><p>The trace itself is simple.</p><p>The interesting part is expressing what makes it valid.</p><p>The transition constraint is:</p><p><strong>xᵢ₊₁ − xᵢ − 2 = 0</strong></p><p>with boundary constraints such as:</p><p><strong>x₀ = 3</strong></p><p>and:</p><p><strong>x₇ = 17</strong></p><p>Now interpolate the trace into T(X).</p><p>If:</p><p><strong>T(X) = xᵢ</strong></p><p>then:</p><p><strong>T(ωX) = xᵢ₊₁</strong></p><p>so the transition becomes:</p><p><strong>T(ωX) − T(X) − 2 = 0</strong></p><p>This was one of the moments where the theory clicked for me.</p><pre>Rust Program<br>     ↓<br>Execution<br>     ↓<br>Trace Rows<br>     ↓<br>AIR Constraints<br>     ↓<br>Polynomial Identities</pre><p>AIR is the bridge between <strong>what the program means</strong> and <strong>what the proof system can verify algebraically</strong>.</p><h3>LDE Finally Made Sense When I Thought of It as Encoding</h3><p>After obtaining the trace polynomial, I implemented the low-degree extension.</p><p>Suppose the trace contains 8 points and the blowup factor is 4.</p><p>The prover evaluates the same low-degree polynomial over 32 points:</p><pre>Trace<br><br>● ● ● ● ● ● ● ●<br><br>        ↓<br>   interpolate<br>        ↓<br>      T(X)<br>        ↓<br> evaluate on larger domain<br>        ↓<br><br>● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●<br>● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●</pre><p>Originally, “low-degree extension” sounded like another polynomial operation I simply had to implement.</p><p>Thinking about it as <strong>Reed–Solomon encoding</strong> made its purpose much clearer.</p><p>The original polynomial has limited degrees of freedom, but we evaluate it at many more locations.</p><p>That creates redundancy.</p><p>The prover cannot freely choose every extended evaluation while still claiming they all come from the same low-degree polynomial.</p><p>That redundancy is what FRI will eventually test.</p><p>So LDE is not merely:</p><blockquote><em>evaluate the polynomial at more points.</em></blockquote><p>It is:</p><blockquote><em>create a redundant representation whose low-degree structure can be probabilistically verified.</em></blockquote><h3>Cosets and Offsets Are Not Random Implementation Details</h3><p>While implementing LDE, I also encountered the idea of evaluating over a coset.</p><p>Instead of evaluating only over a subgroup H, we can use:</p><p><strong>gH = {g, gω, gω², …}</strong></p><p>where g is an offset.</p><p>At first, the offset looked like an arbitrary extra parameter.</p><p>It becomes much more meaningful once quotient expressions appear.</p><p>For a trace domain H, a vanishing polynomial may look like:</p><p><strong>Z_H(X) = Xⁿ − 1</strong></p><p>On H:</p><p><strong>Z_H(X) = 0</strong></p><p>But the prover needs to evaluate expressions involving division by vanishing polynomials.</p><p>Evaluating on an appropriately chosen shifted domain keeps us away from those zeros.</p><p>This was another recurring lesson from implementation:</p><p><strong>parameters that look arbitrary in code usually encode an important mathematical requirement.</strong></p><h3>Merkle Trees Taught Me the Difference Between Commitment and Correctness</h3><p>Once I had the LDE evaluations, I committed to them using a Merkle tree.</p><pre>LDE Evaluations<br>      ↓<br>Hash Leaves<br>      ↓<br>Merkle Tree<br>      ↓<br>Merkle Root</pre><p>The root is small, while the underlying evaluation vector can be huge.</p><p>Later, the prover can open one evaluation using a logarithmic-size authentication path.</p><p>But implementing this also clarified something important:</p><p><strong>A Merkle tree does not prove that the evaluations are correct.</strong></p><p>It only proves that the prover is committed to them.</p><p>The prover could commit to complete garbage.</p><p>Merkle trees give us:</p><p><strong>binding</strong></p><p>FRI gives us:</p><p><strong>low-degree testing</strong></p><p>AIR gives us:</p><p><strong>computational correctness</strong></p><p>Those are different responsibilities.</p><pre>AIR<br> ↓<br>What should be true?<br><br>Merkle Tree<br> ↓<br>What did the prover commit to?<br><br>FRI<br> ↓<br>Does the committed data have<br>the required low-degree structure?</pre><p>Seeing those boundaries made the entire protocol easier to reason about.</p><h3>Fiat–Shamir Is Really About Protocol Ordering</h3><p>My transcript implementation initially looked almost too simple.</p><p>Absorb some values.</p><p>Hash the state.</p><p>Produce a field element.</p><p>But the important part is not just generating random-looking numbers.</p><p>It is <strong>when those numbers become available</strong>.</p><p>The prover should follow a pattern like:</p><pre>Commit<br>   ↓<br>Absorb Commitment<br>   ↓<br>Generate Challenge<br>   ↓<br>Use Challenge<br>   ↓<br>Commit Again<br>   ↓<br>Generate Next Challenge</pre><p>For example, the prover commits to trace data before obtaining the random coefficients used to combine constraints.</p><p>Similarly, FRI challenges are derived from commitments to previous layers.</p><p>If the prover could see a challenge first and construct the relevant committed data afterward, the protocol’s soundness argument could fail.</p><p>So one of my biggest lessons was:</p><p><strong>Fiat–Shamir is not just a random-number generator. It encodes the ordering of the interactive protocol.</strong></p><h3>The Composition Polynomial Connected AIR to FRI</h3><p>A realistic AIR contains many constraints.</p><p>We do not want to independently run a low-degree argument for every constraint.</p><p>Instead, the prover constructs normalized constraint terms and combines them using random coefficients:</p><p><strong>C_comp(X) = α₁C₁(X) + α₂C₂(X) + … + αₘCₘ(X)</strong></p><p>Conceptually:</p><pre>Constraint 1 ──× α₁──┐<br>                     │<br>Constraint 2 ──× α₂──┼──&gt; Composition Polynomial<br>                     │<br>Constraint 3 ──× α₃──┘</pre><p>This was the point where I understood the composition polynomial as more than “another polynomial in the protocol.”</p><p>It is the bridge between:</p><p><strong>AIR says the execution is correct</strong></p><p>and:</p><p><strong>FRI checks a low-degree claim</strong></p><p>The constraints capture computation semantics. The composition step packages those constraints into something suitable for low-degree testing.</p><h3>FRI Was the Hardest Part — and the Most Useful to Implement</h3><p>FRI was the component I found hardest to understand from equations alone.</p><p>The key idea became much clearer once I implemented a folding layer.</p><p>Write a polynomial as:</p><p><strong>f(X) = f_even(X²) + X · f_odd(X²)</strong></p><p>Now evaluate at x and −x:</p><p><strong>f(x) = f_even(x²) + x · f_odd(x²)</strong></p><p><strong>f(−x) = f_even(x²) − x · f_odd(x²)</strong></p><p>From these two values:</p><p><strong>f_even(x²) = (f(x) + f(−x)) / 2</strong></p><p>and:</p><p><strong>f_odd(x²) = (f(x) − f(−x)) / (2x)</strong></p><p>Using a random challenge β, we form:</p><p><strong>f_next(x²) = f_even(x²) + β · f_odd(x²)</strong></p><p>In code, this starts looking surprisingly concrete:</p><pre>let even = (a + b) * two_inv;<br>let odd = (a - b) * two_inv * x.inverse().unwrap();<br><br>let folded = even + beta * odd;</pre><p>The huge conceptual phrase:</p><p><strong>“FRI recursively reduces a low-degree proximity claim”</strong></p><p>becomes:</p><pre>Take paired evaluations<br>        ↓<br>Recover even/odd information<br>        ↓<br>Mix using random β<br>        ↓<br>Create next layer<br>        ↓<br>Square the domain<br>        ↓<br>Repeat</pre><p>And the degree bound keeps shrinking:</p><p><strong>d → d/2 → d/4 → d/8 → …</strong></p><p>Implementing that loop taught me more about FRI than reading the folding equation repeatedly.</p><h3>Domain Bookkeeping Is Surprisingly Important</h3><p>One of the easiest mistakes to make is thinking only about evaluation values and forgetting their domain points.</p><p>FRI does not simply turn:</p><pre>[a, b, c, d]</pre><p>into:</p><pre>[e, f]</pre><p>The domain changes as well.</p><p>Paired points x and −x map to:</p><p><strong>x²</strong></p><p>So each round transforms both:</p><pre>Evaluationsᵢ<br>     ↓<br>Evaluationsᵢ₊₁<br><br>and<br><br>Domainᵢ<br>     ↓<br>Domainᵢ₊₁</pre><p>A value without knowing <strong>where it was evaluated</strong> is often meaningless in polynomial protocols.</p><p>This became one of my most practical debugging rules:</p><blockquote><em>Whenever an evaluation looks wrong, check the domain before checking the formula.</em></blockquote><h3>The Verifier Changed How I Thought About the Prover</h3><p>It is easy to build a prover by thinking:</p><blockquote><em>What values do I need to calculate next?</em></blockquote><p>A better question is:</p><blockquote><em>What will the verifier eventually need to check?</em></blockquote><p>The verifier does not reconstruct the entire trace.</p><p>It receives commitments and opens only randomly selected locations.</p><p>For those locations, it needs enough information to verify:</p><ul><li>Merkle membership,</li><li>AIR/composition relationships,</li><li>FRI folding consistency,</li><li>and the final low-degree condition.</li></ul><p>That means proof generation should be designed backward from verifier requirements.</p><pre>Verifier needs to check<br>        ↓<br>Which values are required?<br>        ↓<br>Which Merkle paths are required?<br>        ↓<br>Which commitments must exist?<br>        ↓<br>What must prover retain?</pre><p>This changed how I structured the prover.</p><p>A proof is not simply a serialized collection of everything the prover computed.</p><p>It should contain <strong>exactly the information the verifier needs to reconstruct the protocol checks</strong>.</p><h3>Rust Was a Good Fit for This Project</h3><p>Rust worked particularly well for implementing a toy prover because the type system encourages explicit boundaries.</p><p>A field abstraction can expose operations such as:</p><pre>trait Field {<br>    fn zero() -&gt; Self;<br>    fn one() -&gt; Self;<br>    fn inverse(self) -&gt; Option&lt;Self&gt;;<br>    fn pow(self, exp: u64) -&gt; Self;<br>}</pre><p>Then FFT, polynomial, AIR, transcript, and FRI code can operate over the field abstraction instead of depending directly on one concrete field.</p><p>A clean project architecture naturally starts to resemble the protocol itself:</p><pre>field.rs<br>   ↓<br>fft.rs<br>   ↓<br>polynomial.rs<br>   ↓<br>lde.rs<br>   ↓<br>air.rs<br>   ↓<br>merkle.rs<br>   ↓<br>transcript.rs<br>   ↓<br>composition.rs<br>   ↓<br>fri.rs<br>   ↓<br>prover.rs<br>   ↓<br>verifier.rs</pre><p>There is also a useful security lesson here.</p><p>Cryptographic Rust code benefits from explicit invariants.</p><p>Things such as:</p><ul><li>domain sizes must be powers of two,</li><li>blowup factors must be valid,</li><li>denominators must be non-zero,</li><li>vector lengths must agree,</li><li>roots of unity must have the expected order,</li></ul><p>should not live only in comments.</p><p>Where possible, they should become assertions, checked constructors, or type-level guarantees.</p><h3>What Broke Most Often?</h3><p>Interestingly, the hardest bugs were not always in the most complicated mathematics.</p><p>They were often small mismatches:</p><pre>Wrong root of unity<br>        ↓<br>FFT output looks wrong<br><br>Wrong domain ordering<br>        ↓<br>FRI pairing looks wrong<br><br>Wrong transcript ordering<br>        ↓<br>Prover/verifier challenges differ<br><br>Wrong Merkle index<br>        ↓<br>Authentication fails<br><br>Coefficient/evaluation confusion<br>        ↓<br>Polynomial logic silently breaks</pre><p>This taught me that implementing cryptographic protocols requires two kinds of correctness at the same time.</p><p>There is <strong>mathematical correctness</strong>:</p><blockquote><em>Is this equation right?</em></blockquote><p>And there is <strong>protocol correctness</strong>:</p><blockquote><em>Are we using the right equation, on the right domain, at the right stage, with the right challenge and commitment?</em></blockquote><p>Both matter.</p><h3>The Biggest Lesson: STARKs Are About Connecting Layers</h3><p>Before implementing the prover, my mental model looked something like:</p><pre>Finite Fields<br>FFT<br>AIR<br>Merkle Trees<br>FRI<br>Fiat–Shamir</pre><p>They were separate topics I had studied.</p><p>After implementing them, my mental model became:</p><pre>                     Computation<br>                          ↓<br>                  Execution Trace<br>                          ↓<br>                         AIR<br>                          ↓<br>                  Trace Polynomial<br>                          ↓<br>                     FFT / LDE<br>                          ↓<br>                  Merkle Commitment<br>                          ↓<br>                 Fiat–Shamir α<br>                          ↓<br>               Composition Polynomial<br>                          ↓<br>                  Merkle Commitment<br>                          ↓<br>                         FRI<br>                          ↓<br>              Commit → β → Fold<br>                          ↓<br>              Commit → β → Fold<br>                          ↓<br>                         ...<br>                          ↓<br>                  Random Queries<br>                          ↓<br>                  Merkle Openings<br>                          ↓<br>                     STARK Proof</pre><p>Every component solves a specific problem.</p><p><strong>Finite fields</strong> give us the algebra.</p><p><strong>AIR</strong> defines valid execution.</p><p><strong>Polynomials</strong> encode that execution algebraically.</p><p><strong>LDE</strong> creates Reed–Solomon redundancy.</p><p><strong>Merkle trees</strong> bind the prover to large evaluation vectors.</p><p><strong>Fiat–Shamir</strong> provides unpredictable challenges in the correct protocol order.</p><p><strong>Composition</strong> reduces many constraints to a randomized polynomial claim.</p><p><strong>FRI</strong> tests low-degree structure.</p><p><strong>Query openings</strong> connect the verifier back to the committed data.</p><p>The biggest thing I learned from building a STARK prover from scratch is that understanding the definitions is only the beginning.</p><p>The real understanding comes from seeing <strong>why the output of one component must become the input of the next</strong>.</p><p>That is when STARKs stopped looking like a collection of advanced cryptographic techniques and started looking like one coherent protocol.</p><p>And that was the most valuable part of building one myself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6340614424fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Finite Fields and Why Every ZK Proof Needs Them]]></title>
            <link>https://medium.com/@rathisrishti/finite-fields-and-why-every-zk-proof-needs-them-8e0fbb8a2f7b?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e0fbb8a2f7b</guid>
            <category><![CDATA[finite-field]]></category>
            <category><![CDATA[zks]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 16:32:45 GMT</pubDate>
            <atom:updated>2026-08-07T16:32:45.787Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Why modular arithmetic sits underneath circuits, polynomial commitments, SNARKs, STARKs, and almost every modern zero-knowledge proof system.</em></p><p>When learning zero-knowledge proofs, we quickly encounter concepts like polynomial commitments, arithmetic circuits, R1CS, AIR, FFTs, KZG, and FRI.</p><p>But underneath almost all of them is something much simpler:</p><p><strong>finite fields.</strong></p><p>At first, finite fields can look like an implementation detail — a strange number system where values suddenly wrap around.</p><p>In reality, they provide the algebraic environment that makes modern ZK protocols possible.</p><p>The basic journey looks like this:</p><pre>Computation<br>    ↓<br>Represent values as field elements<br>    ↓<br>Convert computation into equations<br>    ↓<br>Turn equations into polynomial relations<br>    ↓<br>Commit / evaluate / test polynomials<br>    ↓<br>Zero-Knowledge Proof</pre><p>To understand why this works, we first need to understand what a field actually is.</p><h3>What Is a Field?</h3><p>A field is a set of values where we can perform:</p><p><strong>addition, subtraction, multiplication, and division by any non-zero element.</strong></p><p>The rational numbers are a familiar example.</p><p>If:</p><p><strong>a = 6</strong></p><p>and:</p><p><strong>b = 3</strong></p><p>then:</p><p><strong>a / b = 2</strong></p><p>and the result still belongs to the same number system.</p><p>ZK systems usually don’t work directly over rational or real numbers. Instead, they use <strong>finite fields</strong>.</p><p>A finite field contains only a finite number of elements.</p><p>The simplest example is a prime field:</p><p><strong>Fₚ = {0, 1, 2, …, p − 1}</strong></p><p>where p is prime.</p><p>All arithmetic is performed modulo p.</p><p>For example, consider:</p><p><strong>F₇ = {0, 1, 2, 3, 4, 5, 6}</strong></p><p>Then:</p><p><strong>5 + 4 = 2</strong></p><p>because:</p><p><strong>9 mod 7 = 2</strong></p><p>Similarly:</p><p><strong>3 × 5 = 1</strong></p><p>because:</p><p><strong>15 mod 7 = 1</strong></p><p>You can think of the arithmetic as wrapping around:</p><pre>0 → 1 → 2 → 3 → 4 → 5 → 6<br>↑                         ↓<br>└─────────────────────────┘</pre><p>After 6, adding 1 takes us back to 0.</p><h3>Why Must p Be Prime?</h3><p>This is where finite fields become more interesting than ordinary modular arithmetic.</p><p>Consider F₇.</p><p>Take the number 3.</p><p>We want to divide by 3. Instead of ordinary division, we find its <strong>multiplicative inverse</strong>.</p><p>We need a value x such that:</p><p><strong>3x = 1 mod 7</strong></p><p>Since:</p><p><strong>3 × 5 = 15 = 1 mod 7</strong></p><p>we have:</p><p><strong>3⁻¹ = 5</strong></p><p>Therefore:</p><p><strong>4 / 3 = 4 × 5 = 20 = 6 mod 7</strong></p><p>Every non-zero element of F₇ has an inverse.</p><p>That property is essential.</p><p>Now consider arithmetic modulo 6.</p><p>We would need an inverse for 2:</p><p><strong>2x = 1 mod 6</strong></p><p>But no such x exists.</p><p>This happens because 6 is composite.</p><p>Using a prime modulus ensures that every non-zero element has a multiplicative inverse, giving us a field.</p><pre>Prime modulus<br>     ↓<br>Every non-zero element has an inverse<br>     ↓<br>Division works<br>     ↓<br>Field structure</pre><h3>Why Does ZK Need This?</h3><p>The key reason is that modern ZK proofs transform computations into <strong>algebraic equations</strong>.</p><p>Suppose our computation contains:</p><p><strong>c = a × b</strong></p><p>Instead of asking a verifier to execute the multiplication, we can express correctness as:</p><p><strong>a × b − c = 0</strong></p><p>Similarly:</p><p><strong>c = a + b</strong></p><p>becomes:</p><p><strong>a + b − c = 0</strong></p><p>A much larger computation can therefore be represented by many equations over a finite field.</p><pre>Program<br><br>c = a × b<br>d = c + 5<br><br>      ↓<br><br>Algebraic Constraints<br><br>a × b − c = 0<br>c + 5 − d = 0<br><br>      ↓<br><br>Polynomial Relations</pre><p>This idea appears in different forms across proof systems.</p><p>SNARKs may use arithmetic circuits, R1CS, PLONK-style constraints, or related arithmetizations.</p><p>STARKs use execution traces and AIR constraints.</p><p>But in both cases, the original computation eventually becomes <strong>algebra over a field</strong>.</p><h3>From Computation to Polynomials</h3><p>Why go through all this trouble?</p><p>Because polynomials have extremely useful mathematical properties.</p><p>Suppose:</p><p><strong>P(X) = X² + 3X + 2</strong></p><p>over a finite field.</p><p>We can evaluate it, interpolate it from points, divide it by another polynomial when appropriate, commit to it, and test polynomial identities.</p><p>This lets a proof system transform a complicated statement like:</p><p><strong>“I executed this computation correctly.”</strong></p><p>into something closer to:</p><p><strong>“These polynomials satisfy these identities.”</strong></p><p>The transformation looks roughly like:</p><pre>Computation<br>     ↓<br>Field Elements<br>     ↓<br>Arithmetic Constraints<br>     ↓<br>Polynomials<br>     ↓<br>Polynomial Identities<br>     ↓<br>Cryptographic Proof</pre><p>This is one of the central ideas behind modern ZK.</p><h3>A Tiny Constraint Example</h3><p>Suppose we want to prove that we know values a and b such that:</p><p><strong>a × b = 12</strong></p><p>We can represent this with the constraint:</p><p><strong>a × b − 12 = 0</strong></p><p>If:</p><p><strong>a = 3</strong></p><p>and:</p><p><strong>b = 4</strong></p><p>then:</p><p><strong>3 × 4 − 12 = 0</strong></p><p>The constraint is satisfied.</p><p>The important point is that the proof system does not fundamentally understand the meaning of “multiplication in my program.”</p><p>It understands <strong>field elements satisfying algebraic constraints</strong>.</p><p>A real proof system may contain millions of such relationships.</p><h3>Why STARKs Need Special Fields</h3><p>STARKs reveal another reason field choice matters.</p><p>A STARK frequently needs efficient polynomial interpolation and evaluation using FFT-like algorithms.</p><p>For that, we want large multiplicative subgroups containing roots of unity.</p><p>Consider the educational field:</p><p><strong>F₉₇</strong></p><p>Because 97 is prime, its non-zero elements form a multiplicative group containing:</p><p><strong>97 − 1 = 96</strong></p><p>elements.</p><p>Factor 96:</p><p><strong>96 = ²⁵ × 3</strong></p><p>Therefore, F₉₇ contains a power-of-two multiplicative subgroup of size:</p><p><strong>32</strong></p><p>This means we can find an element ω satisfying:</p><p><strong>ω³² = 1</strong></p><p>with the appropriate order.</p><p>That gives us a roots-of-unity domain:</p><p><strong>H = {1, ω, ω², ω³, …, ω³¹}</strong></p><p>Such domains are extremely useful for FFT-based polynomial operations.</p><pre>Choose field Fₚ<br>      ↓<br>Look at p − 1<br>      ↓<br>Need large power-of-two factor<br>      ↓<br>Roots of unity<br>      ↓<br>FFT-friendly domain<br>      ↓<br>Fast polynomial operations</pre><p>So choosing a field is not simply choosing a large prime.</p><p>Its algebraic structure can directly affect prover performance.</p><h3>Why Roots of Unity Matter in STARKs</h3><p>Suppose an execution trace contains:</p><p><strong>x₀, x₁, x₂, …, xₙ₋₁</strong></p><p>We can associate those values with:</p><p><strong>1, ω, ω², …, ωⁿ⁻¹</strong></p><p>and interpolate a trace polynomial T(X):</p><p><strong>T(ωⁱ) = xᵢ</strong></p><p>Now something useful happens.</p><p>If:</p><p><strong>X = ωⁱ</strong></p><p>then:</p><p><strong>ωX = ωⁱ⁺¹</strong></p><p>So:</p><p><strong>T(X) = xᵢ</strong></p><p>and:</p><p><strong>T(ωX) = xᵢ₊₁</strong></p><p>A transition rule such as:</p><p><strong>xᵢ₊₁ = xᵢ + 2</strong></p><p>can therefore become:</p><p><strong>T(ωX) − T(X) − 2 = 0</strong></p><pre>Trace<br><br>x₀ → x₁ → x₂ → x₃<br><br>↓     ↓     ↓     ↓<br><br>1     ω     ω²    ω³<br><br>      ↓<br><br>Trace Polynomial T(X)<br><br>      ↓<br><br>Next row = T(ωX)</pre><p>The finite field and its roots of unity therefore give us a clean way to translate trace movement into polynomial relationships.</p><h3>Finite Fields Also Make Polynomial Division Reliable</h3><p>Polynomial division appears constantly in proof systems.</p><p>Suppose P(z) = y.</p><p>Then:</p><p><strong>P(X) − y</strong></p><p>has a root at X = z.</p><p>Therefore:</p><p><strong>P(X) − y = (X − z)Q(X)</strong></p><p>for some quotient polynomial Q(X).</p><p>This simple fact is at the heart of constructions such as KZG openings.</p><p>STARKs similarly use vanishing polynomials and quotient-style constraint expressions.</p><pre>Constraint holds<br>      ↓<br>Polynomial has required roots<br>      ↓<br>Vanishing polynomial divides it<br>      ↓<br>Quotient has expected degree</pre><p>All of this depends on having a clean algebraic environment where addition, multiplication, inversion, and polynomial arithmetic behave predictably.</p><p>Finite fields provide exactly that environment.</p><h3>What About Negative Numbers and Fractions?</h3><p>At first, finite-field arithmetic can look restrictive.</p><p>Where is −1?</p><p>Where is 1/2?</p><p>They are already inside the field.</p><p>In F₇:</p><p><strong>−1 = 6</strong></p><p>because:</p><p><strong>6 + 1 = 0 mod 7</strong></p><p>Similarly, 1/2 means the multiplicative inverse of 2.</p><p>Since:</p><p><strong>2 × 4 = 8 = 1 mod 7</strong></p><p>we have:</p><p><strong>2⁻¹ = 4</strong></p><p>So:</p><p><strong>1/2 = 4 in F₇</strong></p><p>The representation looks different, but the algebraic operations we need still exist.</p><h3>Finite Fields Don’t Automatically Represent Normal Program Arithmetic</h3><p>There is one important caveat.</p><p>If we represent everything using field elements, arithmetic naturally wraps modulo p.</p><p>But normal programs often work with integers, bytes, signed values, and bounded machine words.</p><p>Those semantics must be enforced separately.</p><p>For example, if a value is supposed to be an 8-bit integer, the proof system may need constraints proving:</p><p><strong>0 ≤ x &lt; 256</strong></p><p>or represent x through bits or limbs.</p><p>So:</p><pre>Finite-Field Arithmetic<br>        ≠<br>CPU Integer Arithmetic automatically</pre><p>The arithmetization must encode the intended semantics.</p><p>This is why range checks, bit decomposition, lookup arguments, and similar techniques are so important in practical ZK systems.</p><h3>Different Proof Systems, Same Foundation</h3><p>The higher-level machinery may look completely different across proof systems.</p><pre>             Finite Fields<br>                  ↓<br>              Polynomials<br>             ↙           ↘<br>          SNARKs         STARKs<br>            ↓               ↓<br>     Circuits/R1CS      AIR/Traces<br>            ↓               ↓<br>           KZG             FRI</pre><p>The details vary considerably, but finite-field arithmetic repeatedly appears underneath the polynomial machinery.</p><p>Why?</p><p>Because fields give us exactly what these protocols need:</p><p><strong>well-defined arithmetic + polynomial structure + efficient algebraic operations.</strong></p><h3>The Bigger Picture</h3><p>When I first encountered finite fields in ZK, they looked like another mathematical prerequisite I needed to get through before reaching the “real cryptography.”</p><p>The opposite is closer to the truth.</p><p>Finite fields are part of the language in which modern proof systems express computation.</p><p>A program begins with instructions, integers, memory, and state transitions.</p><p>A proof system gradually transforms those objects:</p><pre>Program<br>   ↓<br>Witness / Execution Trace<br>   ↓<br>Field Elements<br>   ↓<br>Algebraic Constraints<br>   ↓<br>Polynomials<br>   ↓<br>Polynomial Commitments / Low-Degree Tests<br>   ↓<br>Proof</pre><p>Without a field, we lose many of the algebraic properties that make this transformation clean and efficient.</p><p>That is why finite fields appear almost everywhere once you start looking inside ZK protocols.</p><p>They are not just where the arithmetic happens.</p><p><strong>They are the algebraic foundation that lets a proof system turn computation into something cryptography can efficiently verify.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e0fbb8a2f7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Polynomial Commitments Explained: From KZG to FRI]]></title>
            <link>https://medium.com/@rathisrishti/polynomial-commitments-explained-from-kzg-to-fri-ceae15d55cc6?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/ceae15d55cc6</guid>
            <category><![CDATA[fri]]></category>
            <category><![CDATA[kzg-commitment]]></category>
            <category><![CDATA[zks]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 04:54:19 GMT</pubDate>
            <atom:updated>2026-08-07T04:54:19.973Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Two ways to commit to a polynomial and prove things about it later — one relies on pairings and a trusted setup, the other on hashing and low-degree testing.</em></p><p>Polynomials appear everywhere in modern zero-knowledge proofs.</p><p>After a computation has been arithmetized, the prover often ends up with polynomials representing witness values, execution traces, constraints, or other protocol data.</p><p>But this creates a problem.</p><p>Suppose the prover has a polynomial:</p><p><strong>P(X) = 3 + 2X + 5X² + 7X³</strong></p><p>and later claims:</p><p><strong>P(4) = y</strong></p><p>How can the verifier know that this value really comes from the <strong>same polynomial the prover committed to earlier</strong>, without receiving the entire polynomial?</p><p>This is the motivation behind polynomial commitments.</p><p>At a high level, we want:</p><pre>Polynomial P(X)<br>      ↓<br>    Commit<br>      ↓<br>       C<br><br>Later...<br><br>Claim: P(z) = y<br>      ↓<br>Opening Proof<br>      ↓<br>Verifier checks<br>      ↓<br> Accept / Reject</pre><p>Two important approaches to this problem appear across modern proof systems:</p><p><strong>KZG</strong>, which uses elliptic-curve pairings and a structured reference string, and <strong>FRI-based approaches</strong>, which use Reed–Solomon encoding, hashes, and probabilistic low-degree testing.</p><p>They solve related problems, but in very different ways.</p><h3>What Does It Mean to Commit to a Polynomial?</h3><p>Think of a polynomial commitment like putting a polynomial inside a locked box.</p><p>Once the prover publishes the commitment, they should not be able to change the polynomial.</p><p>Later, they can prove statements such as:</p><p><strong>P(z) = y</strong></p><p>without revealing every coefficient of P(X).</p><p>A useful polynomial commitment should therefore give us two main properties.</p><p><strong>Binding:</strong> after committing to P(X), the prover cannot later pretend that they committed to a different polynomial.</p><p><strong>Efficient opening:</strong> the prover can convince the verifier of evaluations such as P(z) = y without sending the whole polynomial.</p><p>Now let’s see how KZG achieves this.</p><h3>KZG: Commit Using Elliptic Curves</h3><p>KZG commitments were introduced by Kate, Zaverucha, and Goldberg.</p><p>Suppose:</p><p><strong>P(X) = a₀ + a₁X + a₂X² + … + aₙXⁿ</strong></p><p>KZG begins with a secret field element, usually written as <strong>τ</strong>.</p><p>A trusted setup generates powers of τ encoded as elliptic-curve group elements:</p><p><strong>G, [τ]G, [τ²]G, [τ³]G, …</strong></p><p>The value τ itself must remain unknown.</p><p>This sequence is often called part of a <strong>Structured Reference String (SRS)</strong>.</p><pre>Secret τ<br>   ↓<br>Trusted Setup<br>   ↓<br>G, [τ]G, [τ²]G, [τ³]G, ...<br>   ↓<br>SRS</pre><p>The prover can combine these elements using the coefficients of P:</p><p><strong>C = [a₀]G + [a₁τ]G + [a₂τ²]G + …</strong></p><p>which is equivalent to:</p><p><strong>C = [P(τ)]G</strong></p><p>This elliptic-curve point is the commitment to P.</p><p>The important part is that the prover can compute <strong>[P(τ)]G without knowing τ</strong>.</p><pre>P(X)<br>  ↓<br>Use SRS powers<br>  ↓<br>[P(τ)]G<br>  ↓<br>Commitment C</pre><p>Because C is just a group element, the commitment is very small even if P contains thousands of coefficients.</p><h3>How Does KZG Open a Polynomial?</h3><p>Now suppose the prover claims:</p><p><strong>P(z) = y</strong></p><p>If this is true, then:</p><p><strong>P(X) − y</strong></p><p>has a root at X = z.</p><p>Therefore it must be divisible by:</p><p><strong>X − z</strong></p><p>So we can define the quotient polynomial:</p><p><strong>Q(X) = (P(X) − y) / (X − z)</strong></p><p>or equivalently:</p><p><strong>P(X) − y = (X − z)Q(X)</strong></p><p>This simple polynomial identity is the key to the KZG opening proof.</p><p>The prover commits to Q:</p><p><strong>π = [Q(τ)]G</strong></p><p>The verifier now needs to check that:</p><p><strong>P(τ) − y = (τ − z)Q(τ)</strong></p><p>But τ is secret.</p><p>This is exactly where <strong>pairings</strong> become useful.</p><p>Conceptually:</p><pre>Claim<br>P(z) = y<br>   ↓<br>P(X) − y has root z<br>   ↓<br>P(X) − y = (X − z)Q(X)<br>   ↓<br>Commit to Q(X)<br>   ↓<br>Pairing Check<br>   ↓<br>Accept / Reject</pre><p>The pairing lets the verifier check the encoded polynomial relation without learning τ.</p><p>That is the core elegance of KZG.</p><p>A large polynomial has been reduced to a small commitment and a small opening proof.</p><h3>The Tradeoff: Trusted Setup</h3><p>KZG’s power comes with an important requirement.</p><p>Someone must initially generate the SRS using τ.</p><p>If τ becomes known, the security of the commitment scheme can break.</p><p>So the setup ceremony must ensure that the toxic-waste secret is not retained.</p><p>Multi-party ceremonies reduce this trust assumption: security can survive as long as at least one honest participant destroys their secret contribution.</p><p>Still, KZG fundamentally depends on structured setup material.</p><p>This motivates a very different approach.</p><h3>FRI Takes a Different Route</h3><p>FRI stands for:</p><p><strong>Fast Reed–Solomon Interactive Oracle Proof of Proximity.</strong></p><p>There is an important technical distinction here:</p><p><strong>FRI itself is a low-degree proximity test, not a polynomial commitment scheme in exactly the same sense as KZG.</strong></p><p>In STARK-style protocols, polynomial evaluations are typically <strong>committed using Merkle trees</strong>, while FRI proves that those committed evaluations are close to a low-degree Reed–Solomon codeword.</p><p>So the architecture looks more like:</p><pre>Polynomial P(X)<br>       ↓<br>Evaluate over large domain<br>       ↓<br>Reed–Solomon Codeword<br>       ↓<br>Merkle Commitment<br>       ↓<br>       Root<br>       ↓<br>FRI Low-Degree Test</pre><p>This distinction is important when people casually compare “KZG vs FRI.”</p><p>KZG directly provides an algebraic polynomial commitment and evaluation-opening mechanism.</p><p>A FRI-based system gets similar functionality by combining several ingredients.</p><h3>From a Polynomial to a Reed–Solomon Codeword</h3><p>Suppose P(X) has degree less than 8.</p><p>Instead of committing directly to its coefficients, evaluate P over a larger domain, perhaps containing 32 points:</p><p><strong>P(x₀), P(x₁), …, P(x₃₁)</strong></p><pre>P(X)<br>degree &lt; 8<br>    ↓<br>Evaluate at 32 points<br>    ↓<br>[P(x₀), P(x₁), ... , P(x₃₁)]<br>    ↓<br>Reed–Solomon Codeword</pre><p>Why evaluate at 32 points when the polynomial has only 8 degrees of freedom?</p><p>Because the additional evaluations create <strong>redundancy</strong>.</p><p>An arbitrary vector of 32 field elements is unlikely to be the evaluation vector of a degree-&lt;8 polynomial.</p><p>This gives the verifier something testable.</p><h3>Merkle Trees Provide the Commitment</h3><p>The prover puts these evaluations into a Merkle tree.</p><pre>P(x₀)  P(x₁)  P(x₂)  P(x₃)  ...<br>   ↓      ↓      ↓      ↓<br>   H      H      H      H<br>    \    /        \    /<br>      H             H<br>        \          /<br>            ...<br>             ↓<br>         Merkle Root</pre><p>The Merkle root binds the prover to the evaluation vector.</p><p>Later, the prover can reveal P(xᵢ) together with a Merkle authentication path.</p><p>The verifier can then confirm that this value really belonged to the committed vector.</p><p>But there is still a problem.</p><p>The Merkle root only says:</p><p><strong>“The prover committed to these values.”</strong></p><p>It does not say:</p><p><strong>“These values come from a low-degree polynomial.”</strong></p><p>That is FRI’s job.</p><h3>How FRI Tests Low Degree</h3><p>FRI repeatedly transforms a polynomial into a polynomial with a smaller degree bound.</p><p>Start with:</p><p><strong>f₀(X)</strong></p><p>Then fold it:</p><pre>f₀<br>degree &lt; 1024<br>    ↓<br>   fold<br>    ↓<br>f₁<br>degree &lt; 512<br>    ↓<br>   fold<br>    ↓<br>f₂<br>degree &lt; 256<br>    ↓<br>   fold<br>    ↓<br>   ...<br>    ↓<br>Small Polynomial</pre><p>The basic mathematical trick is to write:</p><p><strong>f(X) = f_even(X²) + X · f_odd(X²)</strong></p><p>where f_even contains the even-degree coefficients and f_odd contains the odd-degree coefficients.</p><p>A random challenge β is generated, and the next polynomial is formed as:</p><p><strong>f_next(Y) = f_even(Y) + β · f_odd(Y)</strong></p><p>The degree bound is approximately halved.</p><p>So:</p><p><strong>d → d/2 → d/4 → d/8 → …</strong></p><p>Each new layer is again committed using a Merkle tree.</p><h3>Why Randomness Matters</h3><p>The prover should not be allowed to construct each FRI layer after knowing all future challenges.</p><p>The protocol therefore repeatedly follows the pattern:</p><pre>Commit to Layer<br>      ↓<br>Generate Random β<br>      ↓<br>Fold<br>      ↓<br>Commit to New Layer<br>      ↓<br>Generate Random β<br>      ↓<br>Fold<br>      ↓<br>...</pre><p>In non-interactive systems, these challenges are normally generated using Fiat–Shamir: hash the transcript so far and interpret the output as field elements.</p><p>Eventually, random query positions are also derived.</p><p>The prover opens only a small number of locations across the committed layers, and the verifier checks that the folding relations are consistent.</p><p>This gives probabilistic evidence that the original committed evaluation table is close to a low-degree Reed–Solomon codeword.</p><h3>KZG and FRI Side by Side</h3><p>The difference becomes much clearer when we look at the two architectures.</p><pre>                KZG<br><br>Polynomial P(X)<br>      ↓<br>Structured Reference String<br>      ↓<br>   [P(τ)]G<br>      ↓<br> Commitment<br>      ↓<br>Quotient Polynomial<br>      ↓<br> Pairing Check<br><br><br>                FRI-Based<br><br>Polynomial P(X)<br>      ↓<br>Evaluate on Large Domain<br>      ↓<br>Reed–Solomon Codeword<br>      ↓<br>Merkle Commitment<br>      ↓<br>FRI Folding<br>      ↓<br>Random Queries<br>      ↓<br>Low-Degree Verification</pre><p>KZG uses <strong>algebraic structure</strong> from elliptic-curve groups and pairings.</p><p>FRI-based protocols use <strong>coding theory, hashing, and probabilistic checking</strong>.</p><p>That leads to different tradeoffs.</p><pre>| Property              | KZG                      | FRI-based approach                  |<br>| --------------------- | ------------------------ | ----------------------------------- |<br>| Commitment            | Elliptic-curve point     | Merkle root over evaluations        |<br>| Main technique        | Pairings                 | Reed–Solomon + FRI                  |<br>| Setup                 | Structured setup/SRS     | Transparent                         |<br>| Opening style         | Algebraic quotient proof | Merkle openings + proximity queries |<br>| Proof/commitment size | Very small               | Usually larger                      |<br>| Verification          | Pairing operations       | Hashes + field operations           |<br>| Post-quantum          | No                       | Hash-based approach is PQ-oriented  |<br>| Common association    | SNARKs / polynomial IOPs | STARKs                              |</pre><p>The table is useful, but it hides the deeper difference.</p><p>KZG essentially says:</p><p><strong>“I have encoded P(τ) into a group element, and pairings let me prove evaluation relations about it.”</strong></p><p>A FRI-based protocol says:</p><p><strong>“I committed to a large Reed–Solomon evaluation table, and I will let you randomly inspect enough structure to become convinced that it is low degree.”</strong></p><h3>Why FRI Proofs Are Larger</h3><p>This also explains why FRI-based proofs tend to be larger.</p><p>A KZG opening can be represented by a small number of elliptic-curve elements.</p><p>FRI needs data such as:</p><ul><li>commitments to several folding layers,</li><li>queried field elements,</li><li>Merkle authentication paths,</li><li>final low-degree data.</li></ul><p>So FRI trades compactness for different assumptions.</p><pre>KZG<br><br>Strong algebraic machinery<br>        ↓<br>Tiny commitments/openings<br><br><br>FRI<br><br>Hash commitments<br>+ Reed–Solomon redundancy<br>+ random sampling<br>        ↓<br>Larger proofs<br>but transparent construction</pre><p>Neither approach is universally “better.”</p><p>They optimize for different goals.</p><h3>The Bigger Picture</h3><p>The most useful thing I learned while studying polynomial commitments is that <strong>KZG and FRI reach similar goals from almost opposite directions</strong>.</p><p>KZG uses elliptic-curve algebra:</p><p><strong>Polynomial → Secret Evaluation Point → Group Element → Pairing</strong></p><p>FRI-based systems use coding theory:</p><p><strong>Polynomial → Many Evaluations → Merkle Commitment → Folding → Random Queries</strong></p><p>KZG gets extremely compact proofs by relying on structured reference material and pairing-friendly elliptic curves.</p><p>FRI-based systems avoid trusted setup and can rely primarily on hash-based commitments, at the cost of larger proofs and more query data.</p><p>So when you encounter a proof system, asking:</p><p><strong>“How does this system commit to polynomials, and how does it prove low-degree/evaluation claims?”</strong></p><p>often reveals a large part of its architecture.</p><p>And that is why understanding KZG and FRI is useful beyond learning two isolated cryptographic techniques.</p><p>They represent two fundamentally different philosophies for convincing a verifier that a prover is telling the truth about a polynomial.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ceae15d55cc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How a STARK Prover Actually Works, End to End]]></title>
            <link>https://medium.com/@rathisrishti/how-a-stark-prover-actually-works-end-to-end-ddc5b41c561b?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddc5b41c561b</guid>
            <category><![CDATA[zkstark]]></category>
            <category><![CDATA[zks]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 14:58:22 GMT</pubDate>
            <atom:updated>2026-08-06T14:58:22.727Z</atom:updated>
            <content:encoded><![CDATA[<p>When I first started learning STARKs, the individual concepts made sense on their own: execution traces, AIR, finite fields, Merkle trees, low-degree extensions, Fiat–Shamir, and FRI.</p><p>The confusing part was understanding how they all fit together.</p><p>Why do we turn a computation into a polynomial? Why extend that polynomial to a larger domain? Why commit those evaluations using a Merkle tree? And where exactly does FRI enter the picture?</p><p>The easiest way to understand a STARK prover is to follow the data through the complete proving pipeline.</p><pre>Program<br> ↓<br>Execution Trace<br> ↓<br>AIR Constraints<br> ↓<br>Trace Polynomials<br> ↓<br>Low-Degree Extension (LDE)<br> ↓<br>Merkle Commitment<br> ↓<br>Composition Polynomial<br> ↓<br>FRI<br> ↓<br>Random Queries<br> ↓<br>STARK Proof</pre><h3>Start With a Computation</h3><p>Suppose we start with 3 and repeatedly add 2.</p><p><strong>xᵢ₊₁ = xᵢ + 2</strong></p><p>Running the computation gives:</p><p><strong>3 → 5 → 7 → 9 → 11 → 13 → 15 → 17</strong></p><p>The prover records these states. This is called the <strong>execution trace</strong>.</p><p>For this tiny example, the trace contains only one value per row. In a real zkVM, the trace can have many columns representing registers, the program counter, memory, instructions, and other machine state.</p><pre>Program<br>   ↓<br>Execute every step<br>   ↓<br>3 → 5 → 7 → 9 → 11 → 13 → 15 → 17<br>   ↓<br>Execution Trace</pre><p>But simply providing a trace proves nothing.</p><p>A dishonest prover could just as easily provide:</p><p><strong>3 → 5 → 7 → 100 → 11 → 13 → 15 → 17</strong></p><p>So we need mathematical rules that define what a valid execution looks like.</p><h3>AIR Turns Computation Into Algebra</h3><p>Our computation follows this rule:</p><p><strong>xᵢ₊₁ = xᵢ + 2</strong></p><p>Move everything to one side:</p><p><strong>xᵢ₊₁ − xᵢ − 2 = 0</strong></p><p>This is a <strong>transition constraint</strong>.</p><p>We also know that the computation must start at 3 and finish at 17:</p><p><strong>x₀ = 3</strong></p><p><strong>x₇ = 17</strong></p><p>These are <strong>boundary constraints</strong>.</p><p>Together, these rules form the <strong>AIR — Algebraic Intermediate Representation</strong>.</p><pre>              Execution Trace<br>                     ↓<br>                    AIR<br>               ↙           ↘<br>        Transition          Boundary<br>        Constraint         Constraints<br><br>   xᵢ₊₁ − xᵢ − 2 = 0        x₀ = 3<br>                            x₇ = 17</pre><p>AIR answers a simple but important question:</p><p><strong>What algebraic conditions must hold for this computation to be valid?</strong></p><p>We have now changed the problem from:</p><p>“Did you execute this program correctly?”</p><p>into:</p><p>“Does your execution trace satisfy these algebraic constraints?”</p><h3>Turning the Trace Into a Polynomial</h3><p>STARKs work with polynomials over finite fields.</p><p>Suppose our trace contains n rows. We choose a roots-of-unity domain:</p><p><strong>H = {1, ω, ω², …, ωⁿ⁻¹}</strong></p><p>where:</p><p><strong>ωⁿ = 1</strong></p><p>The prover interpolates the trace into a polynomial T(X) so that:</p><p><strong>T(ωⁱ) = xᵢ</strong></p><p>For our example:</p><p><strong>T(1) = 3</strong></p><p><strong>T(ω) = 5</strong></p><p><strong>T(ω²) = 7</strong></p><p>and so on.</p><p>Now comes an important trick.</p><p>If: <strong>T(X) = xᵢ</strong></p><p>then: <strong>T(ωX) = xᵢ₊₁</strong></p><p>Multiplying X by ω effectively moves us to the next row of the execution trace.</p><p>So our original rule: <strong>xᵢ₊₁ = xᵢ + 2</strong></p><p>becomes: <strong>T(ωX) − T(X) − 2 = 0</strong></p><p>This is one of the central ideas behind STARK arithmetization.</p><pre>Program Rule<br><br>xᵢ₊₁ = xᵢ + 2<br><br>        ↓<br><br>AIR Constraint<br><br>xᵢ₊₁ − xᵢ − 2 = 0<br><br>        ↓<br><br>Polynomial Constraint<br><br>T(ωX) − T(X) − 2 = 0</pre><p>The computation is now represented as a polynomial identity.</p><h3>Why Vanishing Polynomials Appear</h3><p>Suppose a constraint must hold over every point in a trace domain H.</p><p>For a roots-of-unity domain containing n points, the polynomial:</p><p><strong>Z_H(X) = Xⁿ − 1</strong></p><p>is zero at every point in H.</p><p>This is called a <strong>vanishing polynomial</strong>.</p><p>If a constraint polynomial C(X) is zero everywhere it is supposed to be, the corresponding vanishing polynomial divides it:</p><p><strong>C(X) = Z(X) · Q(X)</strong></p><p>Therefore:</p><p><strong>Q(X) = C(X) / Z(X)</strong></p><p>has the expected polynomial structure.</p><p>Conceptually:</p><pre>Correct Execution<br>       ↓<br>AIR Constraints Hold<br>       ↓<br>Constraint Polynomial Vanishes<br>       ↓<br>Expected Divisibility Holds<br>       ↓<br>Low-Degree Quotient Structure</pre><p>This is how STARKs connect computational correctness with polynomial properties.</p><h3>Low-Degree Extension Adds Redundancy</h3><p>The prover does not evaluate the trace polynomial only on the original trace domain.</p><p>Instead, it evaluates it over a much larger domain.</p><p>For example, a trace with 8 points might be extended to 32 points.</p><pre>Original Trace Domain<br><br>● ● ● ● ● ● ● ●<br><br>        ↓<br>   Interpolate T(X)<br>        ↓<br>        LDE<br>        ↓<br><br>● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●<br>● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●</pre><p>This is called the <strong>Low-Degree Extension</strong>, or LDE.</p><p>Mathematically, this is a form of Reed–Solomon encoding.</p><p>If T(X) has degree less than 8 but we evaluate it at 32 points, those evaluations contain redundancy.</p><p>An arbitrary set of 32 values is very unlikely to behave like evaluations of a polynomial with the required low degree.</p><p>That redundancy is important because it allows the verifier to detect cheating by checking only a small number of locations.</p><h3>Merkle Trees Commit to the Evaluations</h3><p>The prover may now have millions of LDE evaluations.</p><p>Sending all of them to the verifier would defeat the purpose of a succinct proof.</p><p>Instead, the prover puts the evaluations into a <strong>Merkle tree</strong>.</p><pre>LDE Evaluations<br>      ↓<br>  Merkle Tree<br>      ↓<br>  Merkle Root</pre><p>The Merkle root commits the prover to the entire evaluation vector.</p><p>Later, if the verifier asks for a particular evaluation, the prover reveals that value together with a Merkle authentication path.</p><p>There is an important distinction here:</p><p><strong>Merkle trees prove commitment. They do not prove low degree.</strong></p><p>The prover is now bound to its values, but we still need to know whether those values actually behave like evaluations of a low-degree polynomial.</p><p>That is where FRI comes in.</p><h3>Combining Constraints Into a Composition Polynomial</h3><p>A real zkVM may have hundreds or thousands of AIR constraints.</p><p>Running a separate proof for every constraint would be inefficient.</p><p>Instead, random challenges are generated:</p><p><strong>α₁, α₂, …, αₘ</strong></p><p>The prover uses them to combine appropriately normalized constraint terms into one <strong>composition polynomial</strong>:</p><p><strong>C_comp(X) = α₁C₁(X) + α₂C₂(X) + … + αₘCₘ(X)</strong></p><p>Conceptually:</p><pre>Transition Constraints ───┐<br>                          │<br>Boundary Constraints ─────┼──→ Random Combination<br>                          │<br>Other Constraints ────────┘<br>                                  ↓<br>                         Composition Polynomial</pre><p>Why use random α values?</p><p>If some constraint is invalid, the prover should not be able to carefully arrange different invalid constraints so that they cancel each other.</p><p>Random coefficients make such cancellation unlikely.</p><p>Now a large collection of AIR constraints has been reduced to a randomized polynomial claim.</p><h3>FRI Tests Low-Degree Structure</h3><p>We finally reach <strong>FRI — Fast Reed–Solomon Interactive Oracle Proof of Proximity</strong>.</p><p>FRI approximately answers this question:</p><p><strong>Do these committed evaluations behave like evaluations of a polynomial with sufficiently low degree?</strong></p><p>FRI does this by repeatedly folding a polynomial into smaller polynomial claims.</p><pre>f₀(X)<br>degree &lt; 1024<br>    ↓<br>   fold<br>    ↓<br>f₁(X)<br>degree &lt; 512<br>    ↓<br>   fold<br>    ↓<br>f₂(X)<br>degree &lt; 256<br>    ↓<br>   fold<br>    ↓<br>   ...<br>    ↓<br>Tiny Polynomial</pre><p>The idea comes from splitting a polynomial into its even and odd powers:</p><p><strong>f(X) = f_even(X²) + X · f_odd(X²)</strong></p><p>A random challenge β is then used to combine these two parts:</p><p><strong>f_next(Y) = f_even(Y) + β · f_odd(Y)</strong></p><p>The degree is roughly halved.</p><p>So FRI repeatedly reduces:</p><p><strong>d → d/2 → d/4 → d/8 → …</strong></p><p>Each FRI layer is committed using another Merkle root.</p><p>Eventually, the polynomial becomes small enough for the verifier to check directly.</p><h3>Fiat–Shamir Generates the Challenges</h3><p>Where do random values such as α and β come from?</p><p>In a non-interactive STARK, they are generated using the <strong>Fiat–Shamir transcript</strong>.</p><p>The prover hashes everything committed so far and uses the result to derive the next challenge.</p><pre>Trace Commitment<br>       ↓<br>      Hash<br>       ↓<br>Random α<br>       ↓<br>Composition Commitment<br>       ↓<br>      Hash<br>       ↓<br>Random β₀<br>       ↓<br>FRI Commitment<br>       ↓<br>      Hash<br>       ↓<br>Random β₁</pre><p>The important pattern is:</p><p><strong>Commit → Challenge → Continue</strong></p><p>The prover must commit to data before learning the challenge that depends on that commitment.</p><p>This prevents the prover from adapting previously committed data after seeing the verifier’s randomness.</p><h3>Random Queries Connect Everything</h3><p>Once all commitments and FRI rounds are complete, the transcript generates random query positions.</p><p>The prover reveals only the required trace, composition, and FRI evaluations, together with their Merkle authentication paths.</p><pre>                 Random Queries<br>                       ↓<br>          ┌────────────┼────────────┐<br>          ↓            ↓            ↓<br>        Trace      Composition      FRI<br>       Openings      Openings     Openings<br>          │            │            │<br>          └────────────┼────────────┘<br>                       ↓<br>                 Merkle Proofs<br>                       ↓<br>                  STARK Proof</pre><p>The verifier checks that the opened values really belong to the committed Merkle trees, that the sampled AIR and composition relationships are correct, and that the FRI layers are consistent with each other.</p><p>The verifier therefore does not need to read the entire execution trace.</p><h3>Putting Everything Together</h3><p>The complete STARK prover pipeline looks like this:</p><pre>                   COMPUTATION<br>                        ↓<br>                 Execution Trace<br>                        ↓<br>                       AIR<br>                        ↓<br>                Trace Polynomials<br>                        ↓<br>                       LDE<br>                        ↓<br>                Merkle Commitment<br>                        ↓<br>              Constraint Quotients<br>                        ↓<br>             Composition Polynomial<br>                        ↓<br>                Merkle Commitment<br>                        ↓<br>                       FRI<br>                        ↓<br>             Fold → Commit → Challenge<br>                        ↓<br>             Fold → Commit → Challenge<br>                        ↓<br>                       ...<br>                        ↓<br>                 Random Queries<br>                        ↓<br>                 Merkle Openings<br>                        ↓<br>                   STARK Proof<br>                        ↓<br>                    Verifier<br>                  ↙          ↘<br>              ACCEPT        REJECT</pre><p>The main idea behind a STARK prover is not one complicated cryptographic trick. It is a sequence of transformations:</p><p><strong>Computation → Execution Trace → Algebra → Polynomials → Low-Degree Testing → Proof</strong></p><p>AIR defines what a correct computation looks like.</p><p>Trace polynomials convert the execution into algebra.</p><p>LDE introduces Reed–Solomon redundancy.</p><p>Merkle trees bind the prover to large evaluation vectors.</p><p>The composition polynomial combines many constraints into a single randomized claim.</p><p>Fiat–Shamir generates unpredictable challenges.</p><p>FRI tests whether the committed values have the required low-degree structure.</p><p>Random queries connect all of these claims while allowing the verifier to inspect only a tiny fraction of the prover’s data.</p><p>That is the key insight: <strong>AIR, LDE, Merkle trees, Fiat–Shamir, and FRI are not independent tricks. Each solves a different part of the same problem.</strong></p><p>Together, they transform:</p><p><strong>“Trust me, I executed this computation correctly.”</strong></p><p>into:</p><p><strong>“Here are committed polynomial objects whose algebraic and low-degree structure you can efficiently verify.”</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddc5b41c561b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Storage slots, packing, and why they matter for security]]></title>
            <link>https://medium.com/@rathisrishti/storage-slots-packing-and-why-they-matter-for-security-74e398784dc6?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/74e398784dc6</guid>
            <category><![CDATA[delegatecall]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[data-storage]]></category>
            <category><![CDATA[evm]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 10:56:56 GMT</pubDate>
            <atom:updated>2026-04-21T10:56:56.403Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*43GumXcg8eItx1eN" /><figcaption>Photo by <a href="https://unsplash.com/@arumvisuals?utm_source=medium&amp;utm_medium=referral">Arum Visuals</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>The EVM stores state in 32-byte slots. How Solidity packs variables — and how proxy patterns can collide them — is one of the most underrated audit skills.</em></p><p><em>Prerequisites: basic Solidity familiarity.</em></p><h3>The stack vs. storage — get this clear first</h3><p>Most confusion about EVM data starts from conflating two completely different things. The stack and storage serve entirely different purposes.</p><p>The EVM is a stack-based virtual machine. The stack is its core data structure during execution — LIFO, max depth 1024, each item 32 bytes (256 bits). It holds intermediate values during computation: operands, return values, addresses. Once execution ends, it’s gone.</p><p>Storage is different in every way. It’s a persistent key-value store attached to each contract. It survives between transactions. Every key is 32 bytes, every value is 32 bytes. This is where your state variables live.</p><blockquote>Stack = temporary computation space. Storage = permanent on-chain database. Never confuse the two when reading opcodes.</blockquote><h3>From Solidity to opcodes</h3><p>Solidity is compiled by solc into bytecode — a flat sequence of bytes deployed on-chain. The EVM interprets each byte as an opcode. There are 256 possible opcodes; about 140 are in active use. Each opcode is 1 byte, consumes gas, and manipulates the stack.</p><p>Take a minimal contract:</p><pre>// SPDX-License-Identifier: MIT<br> pragma solidity ^0.8.0;<br><br>contract SimpleStorage { <br>  uint256 public storedValue; <br><br>  function set(uint256 _value) public {<br>   storedValue = _value; <br>  } <br>  <br>  function get() public view returns (uint256) { <br>    return storedValue; <br>  } <br>}</pre><p>When deployed, the EVM runs init code once (which executes the constructor and stores the runtime bytecode). All subsequent calls hit the runtime bytecode directly.</p><p>When a transaction arrives, calldata contains a 4-byte function selector derived from keccak256 of the function signature. The bytecode checks this selector and jumps to the right function body. This dispatch logic is baked into the compiled bytecode — there is no magic routing layer.</p><p>A snippet of the resulting opcodes looks like:</p><pre>[00] PUSH1 0x80 <br>[02] PUSH1 0x40 <br>[04] MSTORE // initialise free memory pointer <br>[05] CALLVALUE <br>[06] DUP1 <br>[07] ISZERO <br>[08] PUSH1 0x0e <br>[0a] JUMPI // revert if ETH sent to non-payable</pre><h3>Storage slot assignment</h3><p>Solidity assigns storage slots to state variables in declaration order, starting at slot 0. Each slot is exactly 32 bytes.</p><p>For uint256 public storedValue:</p><p>slot 0 storedValue (32 bytes)</p><p>When set(5) is called, the EVM pushes 5 onto the stack, pushes slot index 0, then executes SSTORE:</p><p>storage[0] = 5</p><p>When get() is called, the EVM executes SLOAD(0), which returns storage[0]. Both SSTORE and SLOAD are among the most gas-expensive opcodes because they touch persistent state.</p><h3>Storage packing</h3><p>When a variable is smaller than 32 bytes, Solidity tries to pack it alongside other small variables in the same slot, filling from the low-order (right) end. This is purely a compiler optimisation — the EVM itself only deals in 32-byte words.</p><p>Two uint128 variables (16 bytes each) fit neatly into one slot:</p><pre>uint128 a; <br>uint128 b;</pre><pre>slot 0 b (16 bytes) a (16 bytes)</pre><p>But a uint256 followed by a uint128 cannot share a slot — the first already consumes all 32 bytes:</p><pre>uint256 a; <br>uint128 b;</pre><pre>slot 0        a (32 bytes) <br>slot 1        b (16 bytes) unused (16 bytes)</pre><p>Declaration order controls layout. Reordering variables changes which slot each one occupies, which matters enormously for security — see below.</p><h3>Why this matters for security</h3><h3>1 — storage collision in proxy contracts</h3><p>Proxy patterns split a contract into two: a proxy that holds storage and forwards calls via delegatecall, and a logic contract that contains the actual implementation. The critical rule is that both must share an identical storage layout.</p><p>With delegatecall, the logic contract&#39;s code runs <em>in the context of the proxy&#39;s storage</em>. The EVM does not use variable names — it uses raw slot indices. If the proxy stores its admin address at slot 0, but the logic contract writes an owner variable at slot 0, the logic contract will silently overwrite the proxy&#39;s admin.</p><blockquote>Proxy storage layout</blockquote><p>slot 0 → _admin</p><p>Address of the proxy administrator. Critical for upgrade access control.</p><blockquote>Logic contract layout</blockquote><p>slot 0 → owner</p><p>Unrelated variable. Written by logic contract code via delegatecall.</p><pre>slot 0     _admin overwritten by owner write</pre><p>The result: ownership broken, proxy admin wiped, potential full contract takeover — all from a layout mismatch the compiler won’t warn you about.</p><p>EIP-1967 addresses this by reserving specific pseudo-random slots for proxy-specific variables (derived via keccak256 of a string minus 1), making accidental collision with logic contract variables statistically impossible.</p><h3>2 — delegatecall risk in general</h3><p>Any use of delegatecall carries this risk, not just formal proxy patterns. Whenever contract A calls contract B via delegatecall, B&#39;s code executes with A&#39;s storage. If B&#39;s declared layout differs from A&#39;s, every SSTORE inside B is writing to the wrong slot in A&#39;s storage.</p><blockquote>layout mismatch → wrong slot written</blockquote><blockquote>no compiler warning</blockquote><blockquote>silent state corruption</blockquote><h3>3 — packing side effects</h3><p>When multiple small variables share a slot, an SSTORE to one requires reading the full 32-byte slot, masking the target bytes, writing the new value, and storing the full word back. This is handled by the compiler, but it means that an incorrect assumption about packing — say, treating a packed bool as if it occupies a full slot — can corrupt adjacent variables in the same slot.</p><p>This surfaces most often with assembly blocks that write directly to storage slots without going through Solidity’s type system. If assembly assumes a variable is at a specific byte offset within a slot and the packing order changes, the write lands in the wrong position.</p><h3>Mappings and dynamic types</h3><p>Mappings don’t use sequential slots. Instead, the value for key k in a mapping declared at slot p is stored at:</p><p>keccak256(abi.encode(k, p))</p><p>This produces a pseudo-random 32-byte location that is effectively collision-resistant. Dynamic arrays store their length at the declared slot and their elements starting at keccak256(p). Neither mappings nor dynamic arrays pack with adjacent variables — they always occupy their own declared slot for metadata, with actual data elsewhere.</p><h3>The mental model to carry forward</h3><p>The compiler assigns slot indices mechanically: declaration order, packing rules, special handling for dynamic types. The EVM knows nothing about variable names — it only sees slot numbers. When delegatecall is involved, the slot numbering of the callee&#39;s source code is applied to the caller&#39;s storage. That mismatch is invisible to the compiler and invisible at runtime until state is already corrupted.</p><p>Auditing any upgradeable or delegatecall-using contract means manually verifying that every slot index in the proxy matches the corresponding slot in every version of the logic contract. Storage layout is a contract invariant that Solidity does not enforce for you.</p><blockquote>Solidity variable → slot assigned by compiler → SSTORE / SLOAD at that index → 32-byte persistent value → contract state</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74e398784dc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ethereum Execution Blueprint]]></title>
            <link>https://medium.com/@rathisrishti/the-ethereum-execution-blueprint-c47557e87895?source=rss-97a6cfac0d34------2</link>
            <guid isPermaLink="false">https://medium.com/p/c47557e87895</guid>
            <category><![CDATA[evm]]></category>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum-internals]]></category>
            <dc:creator><![CDATA[Srishti Rathi]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 08:40:30 GMT</pubDate>
            <atom:updated>2026-04-21T08:43:28.172Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Bts-bmZ4vTI6uQQo" /><figcaption>Photo by <a href="https://unsplash.com/@zoltantasi?utm_source=medium&amp;utm_medium=referral">Zoltan Tasi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>From one line of Solidity to permanent storage on the blockchain — explained with a post office.</em></p><p>Let’s use one analogy throughout this entire piece: <strong>a post office.</strong> Every concept maps onto it. By the end, when someone says “mempool” or “stateRoot,” you’ll have a real picture in your head, not just a word.</p><p>I’m going to assume you know roughly what Ethereum and Solidity are. That’s it. Everything else, we’ll define as we go.</p><h3>Step 1 — Writing code: drafting your letter</h3><p>When you write a smart contract in <strong>Solidity</strong>, you’re writing human-readable instructions — like drafting a letter in plain English. The problem is that the post office (Ethereum) doesn’t speak English. It only understands a very compact machine language.</p><p>So before your letter can be sent, it goes through a <strong>compiler</strong> — a translator called <strong>solc</strong>. It takes your readable Solidity and produces two things:</p><p><strong>Bytecode - </strong>The letter rewritten in machine language. This is what actually runs on Ethereum.</p><p><strong>ABI - </strong>A table of contents. Tells the outside world what functions your contract has and how to call them.</p><blockquote>Post office analogy</blockquote><blockquote>The compiler is the translation desk. You hand in a letter in English; it hands back the same letter in the post office’s own internal shorthand — plus a reference card (ABI) so others know how to address you.</blockquote><h3>Step 2 — The transaction: putting your letter in an envelope</h3><p>Nothing happens on Ethereum without a transaction. A transaction is a structured packet — like a sealed envelope — that carries your action onto the network.</p><p>Every envelope has specific fields printed on it:</p><p><strong>nonce -</strong> Your letter count. Prevents duplicates.</p><p><strong>to - </strong>The recipient’s address.</p><p><strong>value </strong>- ETH being sent with the letter.</p><p><strong>gasLimit</strong> - Max postage you’ll pay.</p><p><strong>maxFeePerGas - </strong>Max price per unit of postage.</p><p><strong>data - </strong>The actual message inside — your bytecode or function call.</p><p>These fields are packed into a compact format using something called <strong>RLP encoding(</strong>Recursive Length Prefix<strong>)</strong> — think of it as folding the letter into a standard-sized envelope so it fits through any slot in the system.</p><p>Then you <strong>sign</strong> it. Ethereum uses a cryptographic signing method called ECDSA(Elliptic Curve Digital Signature Algorithm), which produces three values — <strong>v</strong>, <strong>r</strong>, and <strong>s</strong> — that act like your unique wax seal. Anyone can verify the seal came from you, but nobody can forge it.</p><p>Finally, the sealed, signed envelope is hashed using a function called keccak256, producing a 32-byte <strong>transaction hash</strong>. This is your tracking number — a unique fingerprint that identifies this exact letter across the entire network.</p><blockquote>Post office analogy</blockquote><blockquote>You write your address and the recipient’s on the envelope, seal it with your personal wax stamp, and the post office stamps a tracking number on the outside. That number exists before the letter is even sent.</blockquote><h3>Step 3 — Deploying a contract: sending a letter that builds a new filing cabinet</h3><p>When you <strong>deploy</strong> a smart contract, you’re not calling an existing address — there is no address yet. Instead, your transaction carries something called <strong>init code</strong> (deployment bytecode). The Ethereum network runs this code once, which executes your<strong> constructor</strong> (setup instructions) and returns the final <strong>runtime bytecode</strong> — the actual code that will live permanently on-chain.</p><p>The contract’s address is deterministic: the network takes your sender address and your nonce, encodes them, hashes them with keccak256, and takes the last 20 bytes. Same sender, same nonce → same address, every time.</p><blockquote>Post office analogy</blockquote><blockquote>You send a letter with instructions to build a new filing cabinet at a specific location. The address of that cabinet is derived from your own identity and how many cabinets you’ve built before — completely predictable before the cabinet even exists.</blockquote><h3>Step 4 — Calldata: writing instructions the contract understands</h3><p>When you call a function on a contract, the ABI tells you how to format the message. This formatted message is called <strong>calldata</strong>.</p><p>Here’s how it’s built. First, the function name and its input types are hashed with keccak256, and the first 4 bytes become the <strong>function selector </strong>— a short code that tells the contract which function you want. Then the arguments are encoded: simple types like numbers get padded to 32 bytes; dynamic types like strings use offsets to point to where the actual data lives. The final calldata is: selector + encoded arguments, packed together in a precise byte layout.</p><blockquote>Post office analogy</blockquote><blockquote>The ABI is the postal form. The function selector is the department code in the top-right corner. The arguments are the fields you fill in below. The filing clerk reads the form top-to-bottom and knows exactly what to do.</blockquote><h3>Step 5 — The EVM: the clerk reading and acting on your letter</h3><p>The EVM (Ethereum Virtual Machine) is the engine that actually executes your code. Think of it as the postal clerk who opens the envelope, reads each instruction, and acts on it.</p><p>As it runs, the EVM works with three distinct regions:</p><p><strong>Calldata</strong> - The letter itself. Read-only — the clerk can read it but can’t change it.</p><p><strong>Memory</strong> - The clerk’s scratch paper. Temporary — wiped clean after each call.</p><p><strong>Storage</strong> - The filing cabinet. Permanent — survives after the call ends.</p><p>The EVM reads the <strong>bytecode</strong> instruction by instruction, decoding each byte into an <strong>opcode</strong> (a primitive command like ADD, STORE, or JUMP) and executing it. Every opcode costs <strong>gas</strong> — the fee you pay for computation. Storage operations are the most expensive, because they write permanently to the chain.</p><p>If the EVM runs out of gas at any point, the entire execution <strong>reverts</strong> — every scratch-paper note is thrown away, no filing cabinet is updated, and the state is left exactly as it was before. There are no partial changes.</p><h3>Step 6 — The mempool: the sorting room</h3><p>When you broadcast a transaction, it doesn’t go straight to the blockchain. It first enters a <strong>mempool </strong>(memory pool) — a waiting area local to each node on the network. Think of it as the sorting room at the post office.</p><p>There isn’t one global sorting room — every post office branch (node) has its own, and they share letters with each other across the network. <strong>Validators</strong> (the workers who actually build blocks) pick letters from their local sorting room. They tend to prioritise letters with higher <strong>priority fees </strong>— bigger tips get delivered first. They also consider <strong>MEV</strong> (Maximal Extractable Value) strategies, which means they sometimes reorder letters to extract extra profit. Selected transactions are bundled into a <strong>block</strong> and executed one by one, in a deterministic sequence.</p><blockquote>Post office analogy</blockquote><blockquote>You drop your letter in a local branch. The branch shares it with other branches. The head sorter picks which letters to put on today’s delivery truck — faster-tipping senders go first. Once the truck leaves, the order of delivery is locked.</blockquote><h3>Step 7 — The world state: Ethereum’s master filing system</h3><p>Every time transactions execute, the Ethereum <strong>state</strong> updates. The entire state is stored in a structure called the <strong>world state trie</strong> — a large tree where every account (wallet or contract) is a node.</p><p>Each account node holds four things: its <strong>nonce</strong>, its <strong>balance</strong>, a <strong>codeHash</strong> (a pointer to the contract’s runtime bytecode), and a <strong>storageRoot</strong> (a pointer to the contract’s own filing cabinet).</p><p>The runtime bytecode itself isn’t stored directly inside the tree — it lives separately in a key-value database (like LevelDB), addressed by its hash. This means if two contracts have identical bytecode, Ethereum stores it only once.</p><p>Each contract’s storage — all its state variables — lives in its own isolated <strong>storage trie</strong>. Simple variables sit in fixed 32-byte <strong>slots</strong>. Mappings compute their slot using keccak256(key + slot number), making placement deterministic but collision-resistant. No contract can peek into another contract’s filing cabinet unless the other contract explicitly hands over access through a function call.</p><blockquote>Post office analogy</blockquote><blockquote>The world state trie is the master directory at headquarters. Every post office branch (account) has an entry. The entry contains a pointer to that branch’s own filing cabinet (storageRoot) and a pointer to the standard procedures it follows (codeHash). The actual procedures manual is stored once in the archive room, not photocopied into every entry.</blockquote><h3>Step 8 — The block: sealing the day’s ledger</h3><p>After all transactions in a block have executed and all filing cabinets have been updated, the entire world state trie is summarised into a single 32-byte hash called the <strong>stateRoot</strong>. This hash lives in the <strong>block header</strong>.</p><p>If even a single byte anywhere — in any account balance, any storage slot, any contract code — changes, the stateRoot changes, which changes the block hash, which breaks the chain from that point forward. This chaining of hashes is what makes Ethereum <strong>immutable</strong>: you can’t quietly alter history without breaking everything that came after it.</p><blockquote>Post office analogy</blockquote><blockquote>At the end of the day, the head postmaster takes a fingerprint of every single filing cabinet across every branch — all compressed into one stamp. That stamp goes on the daily ledger page. If anyone sneaks in the next morning and changes a single old record, the stamp no longer matches, and the fraud is instantly obvious.</blockquote><h3>The full loop</h3><p>Here’s the whole pipeline in one view:</p><blockquote>01 Write Solidity → compiler produces bytecode + ABI</blockquote><blockquote>02 Pack into a transaction (the envelope), sign it, get a tracking hash</blockquote><blockquote>03 Broadcast → lands in the mempool (the sorting room)</blockquote><blockquote>04 Validator picks it, puts it in a block, assigns it an order</blockquote><blockquote>05 EVM executes it: reads calldata, uses memory as scratch paper, updates storage</blockquote><blockquote>06 World state trie updates — all filing cabinets reflect the new reality</blockquote><blockquote>07 Block is sealed: stateRoot stamps the entire system state, chained to the previous block</blockquote><p><em>That’s it. One line of Solidity to permanent, immutable storage — delivered by the world’s most elaborate post office.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c47557e87895" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>