<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>FarFromAverage</title>
        <link>https://paragraph.com/@farfromaverage</link>
        <description>Blockchain Developer | Security Researcher | ZKP | AI/ML | Econ
Building The Next Generation of Stablecoins</description>
        <lastBuildDate>Fri, 10 Apr 2026 10:42:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>FarFromAverage</title>
            <url>https://storage.googleapis.com/papyrus_images/9a05bcfde4e48a315f1ee5de174855aefe3e42caf7a4df59c81c1c42c4095805.jpg</url>
            <link>https://paragraph.com/@farfromaverage</link>
        </image>
        <copyright>All rights reserved</copyright>
        <item>
            <title><![CDATA[EulerPhi - Bringing Value Investing to Web3]]></title>
            <link>https://paragraph.com/@farfromaverage/eulerphi-bringing-value-investing-to-web3-2</link>
            <guid>XJS2nMutr2AKHR3e3Jb8</guid>
            <pubDate>Wed, 13 Aug 2025 17:45:37 GMT</pubDate>
            <description><![CDATA[Why Crypto Hasn’t Gone Mainstream YetI’ve spent three years in Web3, watching the technology mature and the infrastructure for a billion users slowly take shape. But one problem still threatens everything — and it’s getting worse. Most newcomers have no idea how this ecosystem works. They chase hype, follow influencers, and invest in projects they don’t understand. When they lose, they don’t know why. When they win, it’s luck — not strategy. The market has become a circus of memecoins, pump-a...]]></description>
            <content:encoded><![CDATA[<h2 id="h-why-crypto-hasnt-gone-mainstream-yet" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0"><strong>Why Crypto Hasn’t Gone Mainstream Yet</strong></h2><p>I’ve spent three years in Web3, watching the technology mature and the infrastructure for a billion users slowly take shape. But one problem still threatens everything — and it’s getting worse.</p><p>Most newcomers have no idea how this ecosystem works. They chase hype, follow influencers, and invest in projects they don’t understand. When they lose, they don’t know why. When they win, it’s luck — not strategy.</p><p>The market has become a circus of memecoins, pump-and-dumps, and manipulation. Scammers prey on the uninformed, and large players move prices at will. This isn’t a string of accidents — it’s a structural flaw.</p><p>I’ve seen millions wiped out — not from greed, but from ignorance. They were never given the tools to navigate this space. Web3 was meant to empower them, but instead, it’s failing them — driving people away and giving the entire ecosystem a bad reputation.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7ccb413a42f23382aa9def8ad9416dafad81b6bfb94b9bde3f3797cdbc776b72.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-why-i-created-eulerphi" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0"><strong>Why I Created EulerPhi ?</strong></h2><p>I started EulerPhi out of frustration — frustration at watching billions flow into hollow Web3 projects with no intrinsic value. Memecoins, hype-driven protocols, and fleeting trends were getting funded, while truly groundbreaking teams — the ones building technology that could reshape industries — were overlooked and underfunded.</p><p>The thought that kept echoing in my mind was: <em>“If only I could redirect that capital toward the builders who actually deserve it.”</em></p><p>The problem is simple but profound: most people are not technical. They can’t easily distinguish between a protocol destined to change the world and one destined to disappear. And so, they follow the noise — not the value.</p><p>I wanted to change that. I wanted to create a place where investors, whether retail or institutional, could find the protocols that combine vision with execution, where true innovation is made visible and accessible. A place where capital flows toward value, not vanity.</p><p>History gives us powerful reminders. Take Nvidia: years ago, only a handful of technical minds in AI understood the magnitude of what they were building. For everyone else, it was just another chip company. But when the world finally realized Nvidia was powering the AI revolution, and so it became the largest company in the stock market.</p><p>It’s proof of a hard truth: most people don’t know how to allocate their funds toward high-performing, high-potential companies — until it’s too late.</p><p>As Warren Buffett once said, <em>“Price is what you pay. Value is what you get.”</em> EulerPhi is here to ensure capital flows toward innovation with true intrinsic value and to help educate investors, ultimately reshaping how society perceives and engages with our ecosystem.</p><h2 id="h-our-mission" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Our Mission</h2><p>Onboarding retail and institutional investors into crypto by redirecting capital toward protocols with the highest intrinsic value.</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/d8e090d360018fdd20126e2365eaeb4a789b44299aea91e2f2bcac3b40816082.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Why dumb people buy Dogecoin and why you should too ]]></title>
            <link>https://paragraph.com/@farfromaverage/why-dumb-people-buy-dogecoin-and-why-you-should-too</link>
            <guid>jctBT8rlJe1EXNvF0mWC</guid>
            <pubDate>Mon, 30 Dec 2024 00:19:26 GMT</pubDate>
            <description><![CDATA[I know you&apos;re eager to jump right in, but before we rush ahead, let&apos;s hit pause and travel back in time—back to an era when civilization was on the verge of making its next great leap, a breakthrough almost as monumental as the discovery of fire itself. Please note that this is a brief article written for curious readers looking to understand how money and investments work.I - Barter SystemThe barter system is a system of trading goods and services directly for other goods and servi...]]></description>
            <content:encoded><![CDATA[<p>I know you&apos;re eager to jump right in, but before we rush ahead, let&apos;s hit pause and travel back in time—back to an era when civilization was on the verge of making its next great leap, a breakthrough almost as monumental as the discovery of fire itself. Please note that this is a brief article written for curious readers looking to understand how money and investments work.</p><h2 id="h-i-barter-system" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">I - Barter System</h2><p>The barter system is a system of trading goods and services directly for other goods and services. The <strong>barter system</strong> dominated during the <strong>prehistoric and early agrarian eras</strong>, before the advent of money and standardized commodities as mediums of exchange. This system was most prevalent in the <strong>Neolithic period</strong> (around 9000 BCE to 3000 BCE), when human societies transitioned from nomadic hunter-gatherer lifestyles to settled agricultural communities. This system was brought to life to fulfill a single goal, to meet everyone’s needs and demands. People would exchange goods and services for other goods and services, making life much easier. But this system had its potential flaws.</p><h3 id="h-unit-of-account" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0"><strong>Unit of account</strong></h3><p><strong><em>is a way to measure how valuable something is (used as a unit of account). Bitcoin is a poor unit of account since its price fluctuates and you cannot price items.</em></strong></p><p>There wasn’t a proper form of measurement which made it hard for both parties to agree on the worth of the goods exchanged. One apple could be traded for 5 eggs between two people, while another person might exchange one apple for 8 eggs. Also another issue arises when someone attempts to trade 100 apples for half a livestock. Many goods cannot be easily divided to match the value of smaller items. Difficulty in storing goods for extended periods diminished their value, and transporting them over long distances made it highly impractical. To solve these issues, humanity was in need for a new system that could solve these problems and that’s where commodities came into place.</p><h2 id="h-ii-commodity-based-money" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">II - Commodity-based money</h2><p>Gold aka God’s Money was first valued for its beauty and malleability, appearing in jewelry and ornamentation in ancient cultures such as those in Mesopotamia and Egypt (~4000 BCE). Its shine and resistance to tarnish made it a symbol of wealth and divinity. Gold&apos;s use as a medium of exchange began in ancient Egypt (~1500 BCE), where gold bars were used for trade. While not yet coined, gold&apos;s role in commerce marked a shift toward its recognition as money.</p><h3 id="h-medium-of-exchange" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0"><strong>Medium of exchange</strong></h3><p><strong><em>is an agreed upon method to transact with each other for example by buying groceries with gold or silver coins.</em></strong></p><p>Gold became a standardized medium of exchange with the minting of the first gold coins by the Lydians in what is now Turkey, around 600 BCE. King Alyattes and his successors issued coins made of electrum (a naturally occurring alloy of gold and silver). These coins facilitated trade and were widely recognized for their intrinsic value. Over time, civilizations across the Mediterranean, Middle East, and Asia adopted gold and silver as primary forms of currency. Gold’s scarcity, durability, divisibility, and inherent value made it an ideal medium of exchange and storage of value. Long before the modern era, civilizations engaged in international trade across the Silk Road (connecting Asia, the Middle East, and Europe) and maritime routes, such as the Indian Ocean Trade. This facilitated the exchange of goods, ideas, and cultural practices, laying early foundations for globalization. Empires such as the Roman Empire, the Persian Empire, and the Mongol Empire expanded their territories and created extensive networks of trade, communication, and cultural exchange.</p><h3 id="h-storage-of-value" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0"><strong>Storage of value</strong></h3><p><strong><em>is a way for us to keep the value and wealth we’ve generated.</em></strong></p><p>During the ancient Egyptian era, nobles instilled in society the belief that gold held immense value due to its scarcity, shining and anti-oxidant properties. This widespread belief persisted for centuries, shaping how people viewed wealth. For an asset to be seen as a reliable medium of exchange, it had to possess tangible value first. Just like gold and other commodities, goods were also deemed valuable because they provided nourishment and met people&apos;s real world needs. What reinforced this belief was the deep emotional connection between the holder and the asset. People worked tirelessly throughout their lives to earn money, so they needed it to have real-world value to believe that it really had value.</p><p>Since basic needs were seen as essential, they were highly valued, as they were considered luxuries in those times. In an era when life was much harder, basic needs were viewed as luxuries, and wants were simply never an option for normal people. At the beginning of the 20th century, owning a car was a luxury that only the wealthy could afford, while the everyday luxuries of the masses were the necessities required to survive. This is why one of the less obvious characteristics of money is that it must have tangible value or utility. Gold was best suited for them because they were able to establish an emotional connection with it which took thousands of years. So this solved <strong>the measurement and storing problem</strong> however Gold is heavy, costly to transport, and requires secure storage, making it impractical for large-scale or international trade. This was a critical issue as humanity was advancing at an increasingly faster rate. Humanity needed a new system—one that could fuel its expansion, ensure reliability and fairness for all, and gain universal adoption. A system capable of facilitating globalization on a far larger scale, while overcoming the limitations that metal money imposed on society.</p><h2 id="h-iii-paper-based-currency" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">III - Paper-based Currency</h2><p>The first government-issued paper currency, known as &quot;jiaozi,&quot; emerged in China during the Song Dynasty (960–1279 AD). In 1023, the Song government nationalized the issuance of these notes, establishing the world&apos;s earliest state-sponsored paper money system. Initially, merchants used privately issued promissory notes to avoid carrying heavy copper coins over long distances. Every system has its flaws, and the more complex it becomes, the more flaws it is likely to have. The overproduction of paper money and mismanagement of the monetary system led to hyperinflation. The government, in an effort to finance military campaigns, printed excessive amounts of paper currency, which devalued the money and contributed to widespread economic instability. This caused loss of confidence in the currency and further weakened the economy. While the fall of the Song Dynasty was caused by a combination of factors, the mismanagement of the monetary system and the resulting inflation played a crucial role in undermining the dynasty&apos;s financial foundation.</p><p>In 2024, several countries have made the same mistake with their economic systems:</p><ul><li><p><strong>USA : The Great Depression (1929–1939)/1971/1987/2000/2008</strong></p></li><li><p><strong>The 1997 Asian Financial Crisis</strong></p></li><li><p><strong>The 2010 European Debt Crisis</strong></p></li><li><p><strong>Venezuela’s Economic Collapse (2010s-present)</strong></p></li><li><p><strong>The 1994 Mexican Peso Crisis</strong></p></li><li><p>The 2001 Argentine Financial Crisis</p></li><li><p><strong>Spain’s 2010-2012 Sovereign Debt Crisis</strong></p></li></ul><p>and the list goes on…</p><p>The overproduction of paper money has flooded the economy, causing inflation and reducing the currency&apos;s reliability. As a result, people often turn to gold as a hedge against inflation, valuing it for its scarcity and real-world value. History repeats itself, though with different shades. As I write this article, humanity finds itself in need of a new financial system—one capable of addressing the flaws of the previous system, such as inflation, counterfeiting, and durability issues.</p><h3 id="h-small-recap" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Small Recap</h3><p>Throughout centuries, money had 3 essential properties:</p><ol><li><p><strong>Storage of value</strong></p></li><li><p><strong>Unit of account</strong></p></li><li><p><strong>Medium of exchange</strong></p></li><li><p><strong>Tangible value (hidden property)</strong></p></li></ol><h2 id="h-digital-based-system" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Digital-based System</h2><h2 id="h-dogecoin" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Dogecoin</h2><p>Now the part you’re been waiting for !!</p><p>It might sound confusing for the reader since it involves Game theory aka probability, psychology, strategy, discrete math and some insanity to understand it.</p><p>Comparing Dogecoin to a national currency is like comparing a red apple with a green apple. They both taste the same !! History has proven that even the strongest countries are prone to financial collapse and devaluation of their currency. The increase in trust and number of people holding the currency, the stronger it becomes. So if the number of holders holding Dogecoin keeps on increasing, it will have proven itself currently to be more reliable than most national currencies. The bigger the mass putting trust in a currency the safer it gets or I’d like to believe so, not accounting for black swans of course. It’s called a meme coin or shit coin since it has no tangible real world value and cannot be considered as shares of a stock since it doesn’t provide any useful services and doesn’t have a legal team backing it up, only rational/irrational people like Elon musk hyping it up only to use the so called victims/followers as exit liquidity. For some people acting rational is acting irrational. They put their faith in the hands of a billionaire who successfully built a couple of companies and did some good things for the community. It’s like he’s the lion and we’re the sheep, manipulation and persuasion at its finest. If you keep playing the game like a sheep you will remain a sheep, in the end its your decision.</p><h2 id="h-investing-vs-gambling" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Investing vs Gambling</h2><p>Investing is investing, gambling is gambling, investing is gambling and gambling is investing. Take a moment to process this phrase, I mean really think about it. Everything you buy has a risk of it going bust.</p><p>Investing in something you know nothing about is called gambling.</p><p>Similarly gambling can also be explained as investing in something you know everything about. Hhmmm this sounds controversial.</p><p>Let just talk about it in a couple of phrases to broaden your perspective.</p><p>Consider Investing as a blue battery that has a positive and negative pole and gambling as a red battery with also a positive and negative pole.</p><h3 id="h-investing" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0"><strong>Investing</strong></h3><p><code>Positive Pole:</code></p><p>1- Investing in something you know nothing about is called gambling.</p><p>2- Its inverse should be : Investing in something you know everything about is called gambling.</p><p>This deduces that Investing is Gambling even though you know nothing or everything about the purchase your making.</p><p><code>Negative Pole:</code></p><p>1- Gambling can be explained as investing in something you know everything about.</p><p>2- Its inverse should be : Gambling can be explained as investing in something you know nothing about.</p><p>This deduces that gambling is investing even though you know nothing about the purchase your making.</p><p>The positive and negative poles are like yin and yang, they are the same yet they are polar opposites.</p><h3 id="h-gambling" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Gambling</h3><p><code>Positive Pole:</code></p><p>1- Gambling in something you know nothing about is called gambling.</p><p>2- Its inverse should be : Investing in something you know nothing about is called investing.</p><p>This deduces that investing is investing and gambling is gambling. They are not the same in anyway.</p><p><code>Negative Pole:</code></p><p>1- Gambling in something you know everything about is called gambling.</p><p>2- Its inverse should be : Investing in something you know everything about is called investing.</p><p>This deduces that gambling is investing even though you know everything about the purchase your making.</p><p>The positive and negative poles are like Tom and Jerry, completely different. Upps, I forgot that they both like food.</p><p>Anyway, I know it was well of confusing but we’re gonna stick to only 2 logical meanings since this article was intended for your average reader.</p><p><strong>1- Investing in something you know nothing about is called gambling.</strong></p><p><strong>2- Gambling can be explained as investing in something you know everything about.</strong></p><blockquote><p>The Phoenicians, were the first people to establish a trading network across the Mediterranean in the first millennium <em>BCE</em>, from an original base in modern Lebanon.</p></blockquote><p><strong>Investing in something you know nothing about is called gambling.</strong></p><p>In simple terms, if you invest in something you know nothing about, the odds are you’re better of buying shit (because its the worst investment you could possibly make) or buying gold(this is the best investment you could make) because there’s a slight chance that you could be right (if accounting for randomness which is impossible to do). So investing in something you know nothing about aka gambling is very risky yet very rewarding in some instances but the odds of it being very rewarding are very slim. It’s like walking in a fog wishing the next step isn’t your last because you don’t know the path you’re walking on. That’s why doing your fundamental analysis properly is crucial for a safer investment. Noobs aka retards proceed with technical analysis first without checking if the investment is shit or not. How do you know if someone’s a noob ?</p><p>They would say: “ You can do a proper fundamental analysis and buy something good but at the wrong time (technical analysis), you’ll lose money. And you only do technical analysis and buy shit at the right time and still turn on a profit.”</p><p>I would totally agree with them, but why risk it ?! You can have the best of both worlds by buying something good and the right time. If it goes down, who the hell cares ? You can go to bed and sleep like a baby knowing that your investment will very likely turn a profit in the long run because you’re an investor not a day trader. You did your due diligence, you worked smart and hard for it and you’re gonna earn your rewards eventually.</p><blockquote><p>Warren buffet said : “The longer you hold your asset, the less risky it becomes.“</p></blockquote><p><strong>Gambling can be explained as investing in something you know everything about.</strong></p><p>Imagine doing all your research for the past 100 years on a specific investment. You’ve done your fundamental and technical analysis. You’re 100% sure that this is a very secure and very rewarding investment but a <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Black_swan_theory">black swan</a> happened and the company/coin went bankrupt and so as you. I won’t talk much about it except that this is very unlikely to happen like the 2008 mortgage crisis in the USA or the Terra Luna incident. No one was expecting it, maybe only a handful of people like Michael Burry who is exceptionally gifted in his field. I won’t talk much about it, because it’s unpredictable. Just take that L and move on. Professional investors use asset allocation and risk management to lower the risk of them losing all their money.</p><blockquote><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Philip_Coggan">Philip Coggan</a>, author of More (The 10,000-Year Rise of the world Economy) famously said : “Send your grains across the seas, and in time, profit will flow back to you. But divide your investments among many places for you do not know what risks might lie ahead.“</p></blockquote><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>Dogecoin is an amazing and shitty asset at the same time. To see if it’s a good investment for you, you should go back to your values/morals and investment strategy. If it doesn’t fit your trading strategy or it doesn’t fit your beliefs then it isn’t the best investment for you.</p><p>Also consider the fact that since human beings are animals. For some probably most, acting rational is acting irrational. You can’t anticipate their next move since they are crazy psychopaths. So beware of these people because as you can see they are flooding the crypto market. $$\text{FUNDAMENTAL ANALYSIS}$$ protects you from them !!</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3386dfd0ea2d246284399d3fce4aab10d4a6be27de90d894d913fa23dbc4f567.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-personal-opinion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Personal Opinion</h2><p>As a blockchain developer, security researcher and cryptography enthusiast with a background ranging from finance, economics, psychology and data analytics, I follow the teachings of other well known economists such as <strong>Friedrich Hayek</strong>, <strong>Benjamin graham, Adam Smith, Nicholas Nassim Taleb.</strong> So from my personal research dogecoin isn’t an investments that fit my values and beliefs.</p><p>Hope you enjoyed this article as much as I did writing it and I hope you learned a thing or two about yourself. You are the only person who can give yourself what you want, you reap what you sow so put the work in and enjoy your success !!</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/5e9fec67350748700b6b3555871360ae3eaf9c7b6ee581af9b71fff4f0b59d47.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Cryptographic Pairings for zk-snarks | Guide for lazy people]]></title>
            <link>https://paragraph.com/@farfromaverage/cryptographic-pairings-for-zk-snarks-guide-for-lazy-people</link>
            <guid>r4Hd2hkZeg5IkffQ0GN8</guid>
            <pubDate>Tue, 10 Dec 2024 20:58:47 GMT</pubDate>
            <description><![CDATA[IntroductionPairings are mathematical tools that allow efficient verification of certain cryptographic properties without revealing any additional information to the other party. Verifiers rely on cryptographic pairings because pairings enable efficient and secure verification of complex algebraic relationships, particularly those arising from polynomial commitments without knowing the underlying polynomial&apos;s coefficients thus satisfying the zero knowledge property. Pairings are used in ...]]></description>
            <content:encoded><![CDATA[<h2 id="h-introduction" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Introduction</h2><p>Pairings are mathematical tools that allow efficient verification of certain cryptographic properties without revealing any additional information to the other party. Verifiers rely on <strong>cryptographic pairings</strong> because pairings enable efficient and secure verification of complex algebraic relationships, particularly those arising from polynomial commitments without knowing the underlying polynomial&apos;s coefficients thus satisfying the zero knowledge property.</p><p>Pairings are used in <strong>commitment schemes</strong>, where the Prover commits to certain values (e.g., polynomials) without revealing them.</p><ul><li><p>The Verifier uses pairings to ensure the commitments are consistent with the proof and the public inputs.</p></li><li><p>For example, pairings verify that a committed polynomial satisfies certain algebraic constraints.</p></li><li><p>Bilinear pairings enable Verifiers to <strong>detect forgery</strong> or invalid proofs by enforcing algebraic consistency.</p></li></ul><h2 id="h-homomorphism" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Homomorphism</h2><p>Let’s take an example,</p><p>$$200 \space G+275 \space G = 475 \space G$$</p><p>$$\begin{align*} &amp; A = 200 \space G \ &amp; B = 275 \space G \ &amp; C = 475 \space G \end{align*}$$</p><p>If I want to calculate what C is, there are two possible ways to do so.</p><p>Method 1 :</p><p>First calculate $$ 200 \times G = A$$ then $$275 \times G = B$$ and finally do $$A+B = 475 \space G = C$$.</p><p>Method 2 :</p><p>First calculate $$200 + 275 = 475$$ then do $$475 \times G = C$$</p><p>If you perform scalar multiplication first and then addition (Method 1), or addition first and then scalar multiplication (Method 2), both methods produce the same result. This property is why elliptic curve groups are said to be <em>homomorphic under addition</em>.</p><h3 id="h-example-1" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Example 1</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/ba90110e20a1d5a9c68288387024711ec0edb15f9536309b1db18ccfd455a7f9.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>The Prover calculates A and B, then sends A, B, and G to the Verifier. The Verifier computes A + B and returns C to the Prover. The advantage here is that the Verifier can do proper computation without knowing the underlying secret values.</p><h3 id="h-example-2" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Example 2</h3><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d4cfb068dba3bb3519c8b699690d253b0b1d905da6a1451d4ebe5c39f22894fb.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>The Prover calculates A and B, then adds them together to obtain a new value C. The Prover then asks the Verifier to confirm whether A + B indeed equals C.</p><p>Both Example 1 and 2 are <em>homomorphic under addition</em> but are they <em>homomorphic under multiplication</em> ?</p><p>Calculating $$D$$ such that $$D = (200 \times 275) G$$ by multiplying $$A \times B$$ won’t work because we cannot multiply two elliptic curve points. We say this is not <em>homomorphic under multiplication.</em></p><p>The only way we can calculate D is if we first multiply $$200 \times 275$$ then multiply the result with G.</p><blockquote><p>Fully Homomorphic = <em>homomorphic under addition and homomorphic under multiplication</em></p></blockquote><p>Providing the Verifier with A and B alone does not allow them to compute D under multiplication. Therefore, similarly to example 2, where 200 and 275 remain secret, the Prover computes A, B, and D and sends them to the Verifier. Using elliptic curve pairings, the Verifier can then verify that $$A \times B = D$$.</p><h2 id="h-definition" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Definition</h2><p>Cryptographic pairings are special mathematical functions that map two group elements into a target group. Formally, a pairing $$e$$ is a function:</p><p>$$e : G_1 \times G_2 \rightarrow G_T$$</p><p>where $$G_1$$, $$G_2$$, and $$G_T$$ are groups, and the function 𝑒 satisfies the following properties:</p><ul><li><p><strong>Bilinearity</strong>:</p><p>For all $$a,b \in \mathbb{Z}$$, $$P \in G_1, Q \in G_2$$ :</p><p>$$e(aP,bQ)=e(P,Q)^{ab} $$$</p></li><li><p><strong>Non-degeneracy</strong>:</p><p>If $$𝑃 ≠ 0$$ and $$𝑄 ≠ 0$$, then $$𝑒 ( 𝑃 , 𝑄 ) ≠ 1$$ . This ensures the pairing provides useful information.</p></li><li><p><strong>Computability/Efficiency</strong>:</p><p>There exists an efficient algorithm to compute $$e(P,Q)$$ for all $$P \in G_1, Q \in G_2$$.</p></li></ul><p>Note that $$G_1$$ and $$G_2$$ are elliptic curve groups and $$G_T$$ isn’t.</p><h2 id="h-elliptic-curve-pairings" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Elliptic Curve Pairings</h2><p>A pairing on $$(G_1,G_2,G_T)$$ defines the function $$e : G_1 \times G_2 \rightarrow G_T$$, and where $$g_1$$ is a generator for $$G_1$$ and $$g_2$$ is a generator for $$G_2$$. If we have the points of $$\color{lightblue}U_1$$ and $$\color{lightblue}U_2$$ on $$\color{lightblue}G_1$$ and $$\color{pink}V_1$$ and $$\color{pink}V_2$$ on $$\color{pink}G_2$$, we get the bilinear mapping of:$$ \begin{align*} &amp; e(U_1+U_2,V_1)=e(U_1,V_1) \times e(U_2,V_1) \ &amp; e(U_1,V_1+V_2)=e(U_1,V_1) \times e(U_1,V_2) \end{align*} $$If $$\color{lightblue}U$$ is a point on $$\color{lightblue}G_1$$, $$\color{pink}V$$ is a point on $$\color{pink}G_2$$ and $$\color{orange}a,b$$ are scalars, we get:$$ e(\textcolor{orange}{a}U,\textcolor{orange}{b}V)=e(U,V)^{\textcolor{orange}{ab}} = e(\textcolor{orange}{ab}U,V) = e(U,\textcolor{orange}{ab}V) $$If $$G_1$$ and $$G_2$$ are the same group, we get a symmetric grouping $$(G_1=G_2=G)$$, and the following commutative property will apply:$$ e(U^{\textcolor{orange}{a}},V^{\textcolor{orange}{b}})=e(U^{\textcolor{orange}{b}},V^{\textcolor{orange}{a}})=e(U,V)^{\textcolor{orange}{ab}} = e(V,U)^{\textcolor{orange}{ab}} $$$</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/6a444b123a8f80f9eba9aec3305316a67e84d829f0eb409c6bf5cb3a785ea261.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[The R1CS & QAP Blueprint for zk-SNARKs | From Zero to Deku ]]></title>
            <link>https://paragraph.com/@farfromaverage/the-r1cs-qap-blueprint-for-zk-snarks-from-zero-to-deku</link>
            <guid>hmbfQ3S012scKhg225Bc</guid>
            <pubDate>Tue, 12 Nov 2024 01:58:52 GMT</pubDate>
            <description><![CDATA[This beginner friendly article is an extended version of Vitalik’s article on Quadratic Arithmetic Programs. We will provide a deeper technical dive on how to transition from a Problem to R1CS and from R1CS to QAP. As mentioned by Vitalik, “zk-SNARKs cannot be applied to any computational problem directly; rather, you have to convert the problem into the right “form” for the problem to operate on. The form is called a “quadratic arithmetic program” (QAP)”Along with the process for converting ...]]></description>
            <content:encoded><![CDATA[<p>This beginner friendly article is an extended version of Vitalik’s article on <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://medium.com/@VitalikButerin/quadratic-arithmetic-programs-from-zero-to-hero-f6d558cea649">Quadratic Arithmetic Programs</a>. We will provide a deeper technical dive on how to transition from a Problem to R1CS and from R1CS to QAP.</p><p>As mentioned by Vitalik, “zk-SNARKs cannot be applied to any computational problem directly; rather, you have to convert the problem into the right “form” for the problem to operate on. The form is called a “quadratic arithmetic program” (QAP)”</p><blockquote><p>Along with the process for converting the code of a function into a QAP is another process that can be run alongside so that if you have an input to the code you can create a corresponding solution (sometimes called “witness” to the QAP).</p></blockquote><blockquote><p>After this, there is another fairly intricate process for creating the actual “zero knowledge proof” for this witness, and a separate process for verifying a proof that someone else passes along to you, but these are details that are out of scope for this post.</p></blockquote><h2 id="h-introduction" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Introduction</h2><p>We will use the same example as Vitalik because it is simple enough that the resulting QAP will not be so large as to be intimidating, but nontrivial enough that you can see all of the machinery come into play. Our goal is to prove that we know the solution to a cubic equation :</p><p>$$x^3 + x + 5 = 35$$</p><p>As you can see, the solution for this is $$x=3$$. The Prover must thus show to Verifier that he knows the solution, without giving away the value 3.</p><p>To keep things simple, we will use a <strong>Galois Field</strong> (or <strong>finite field</strong>) of GF(641) which is a prime number.</p><p>If you’re not familiar with Modular Arithmetic, I recommend reading the <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.rareskills.io/post/finite-fields">Finite Fields and Modular Arithmetic for ZK Proofs</a> chapter from <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.rareskills.io/zk-book">Rareskills Zero Knowledge book</a> before proceeding an further.</p><h2 id="h-problem-statement-to-r1cs" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Problem Statement to R1CS</h2><h3 id="h-definition-of-r1cs" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Definition of R1CS</h3><p>Rank-1 Constraint System (R1CS) is a way to represent complex mathematical statements as a series of equations that a computer can verify efficiently. In essence, R1CS allows us to break down a problem into simple constraints that verify if a solution is valid. This let’s us easily prove to the Verifier that the Prover does really know a proper witness $$w$$ (solution) for a specific problem or in this case a cubic equation.</p><h3 id="h-step-1-flattening" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Step 1: Flattening</h3><p>We have a function $$x^3 + x +5 = 35$$, we want to simplify it into multiple small functions called constraints which take the form of $$x = y \space (op) \space z$$ where $$(op)$$ can be any arithmetic operation $$(+, -, \times, /)$$.</p><p>$$\begin{align*} a &amp;= x \times x \quad &amp; x^2 \ b &amp;= a \times x \quad &amp; x^3 \ c &amp;= b + x \quad &amp; x^3 + x \ d &amp;= c + 5 \quad &amp; x^3 + x + 5 \end{align*}$$</p><p>We have 4 gates because in every line $$a, b, c$$ and $$d$$ we have one arithmetic operations. Since $$a$$ and $$b$$ both have multiplication, we’ll need two multiplication gates:<code>Gate#1</code> and <code>Gate#2</code>. Similarly, since $$c$$ and $$d$$ both have addition, we’ll also need two addition gates: <code>Gate#3</code> and <code>Gate#4</code>.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/7af6477cfb949e12925400e1f723561d5855a88a2c06653594d3b2319e886636.png" alt="Logical circuit" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="">Logical circuit</figcaption></figure><h3 id="h-step-2-gates-to-r1cs" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Step 2: Gates to R1CS</h3><p>Next, we will need to convert the previous statements into the R1CS (Rank-1 Constrain System) format, and which defines three vectors: A, B and C. The solution to this is a vector $$(S)$$ that must satisfy the equation below.</p><p>$$(A.S) \times (B.S) - (C.S) = 0$$</p><p><code>.</code> represents the dot product which is a mathematical operation that takes two vectors and returns a single number (a scalar) so it’s not multiplication.</p><p>The length of each vector is equal to the total number of variables in the system, including a dummy variable <code>one</code> at the first index representing the number 1 which allows all constraints to be written in a constant form, the input variable <code>x</code>, a dummy variable <code>d</code> representing the output, and then all of the intermediate variables<code>a, b</code> and <code>c</code>. So we will use this layout to display the variables:</p><p>$$S=[1,x,a,b,c,d]$$</p><p>Other articles might use a different layout like the one below. They are all the same, they all serve the same purpose. You can structure your layout depending on your own needs.</p><p>$$S=[1,d,x,a,b,c,d,1]$$</p><p>In this case, the Prover proves that he knows a solution that satisfies the equation$$(x^3 + x +5 = 35)$$ by producing a vector <code>S</code> which is the witness $$w$$ for $$x = 3$$ :</p><p>$$\begin{align*} S = \text{witness} = [1, x, (x \times x), (x^2 \times x), (x^3 + x), (x^3 + x + 5)] \ S = \text{witness} = [1, 3, (3 \times 3), (9 \times 3), (27 + 3), (27 + 3 + 5)] \ S = \text{witness} = [1, 3, 9, 27, 30, 35] \end{align*}$$</p><p><code>For the First Constraint:</code></p><p>By applying $$x= 3$$ on our first constraint $$a =x \times x$$, we will get:</p><p>$$\begin{align*} A = [0,1,0,0,0,0] \ B = [0,1,0,0,0,0] \ C = [0,0,1,0,0,0] \end{align*}$$</p><p>So for $$x = 3$$, $$a= x \times x$$ will be represented as $$ 9 =3 \times 3$$ or $$3 \times 3 -9 = 0$$ . The first $$x$$ which is 3 will be in the second index of the vector <code>A</code> because the second index in $$S = [1,3,9,27,30,35]$$ is 3. The second $$x$$ which is also 3 will also be in the second index of vector <code>B</code>. This leaves us with 9 which will be in the third index of vector<code>C</code>.</p><p>So the function $$(A.S) \times (B.S) - (C.S) = 0$$ for $$x = 3$$ will look like this in vector form :</p><p>$${ \small \begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} \times \begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} - \begin{pmatrix} 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} = \begin{pmatrix} 0 \end{pmatrix} }$$</p><p><code>For the Second Constraint:</code></p><p>Similarly to the first constraint, by applying $$x=3$$ on our second constraint $$b = a \times x$$, we will get:</p><p>$$\begin{align*} A = [0,0,1,0,0,0] \ B = [0,1,0,0,0,0] \ C = [0,0,0,1,0,0] \end{align*}$$</p><p>In simple terms, for $$x =3$$, the second constraint will become $$27 = 9 \times 3$$ or $$9 \times 3 -27 = 0$$. 9 is the third index in vector $$A$$, 3 is the second index in vector $$B$$ and 27 is the fourth index in vector $$c$$. Remember these vectors are made this way because of the structure of our layout for vector <code>S</code> :</p><p>$$S = [1, 3, 9, 27, 30, 35]$$</p><p>So the function $$(A.S) \times (B.S) - (C.S) = 0$$ for $$x = 3$$ will look like this in vector form :</p><p>$${ \small \begin{pmatrix} 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} \times \begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} - \begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} = \begin{pmatrix} 0 \end{pmatrix} }$$</p><p><code>For the Third Constraint:</code></p><p>By applying $$x = 3$$ on our third constraint $$c = b + x$$ or $$c = (b + x) \times 1$$, we will get:</p><p>$$\begin{align*} A = [0,1,0,1,0,0] \ B = [1,0,0,0,0,0] \ C = [0,0,0,0,1,0] \end{align*}$$</p><p>The third constraint will become $$30 = (27 + 3) \times 1$$ or $$(27 + 3) \times 1 - 30 =0$$.</p><p>27 is the fourth index in vector <code>A</code> and 3 is the second index in vector <code>A</code>. 1 is the first index in vector <code>B</code> and 30 is the fifth index in vector <code>C</code>.</p><p>$${ \small \begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} \times \begin{pmatrix} 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} - \begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} = \begin{pmatrix} 0 \end{pmatrix} }$$</p><p>So vector $$A$$ is $$3 + 27$$, vector $$b$$ is $$1$$ and vector $$C$$ is $$30$$. Thus, $$27 +3 - 30 = 0$$.</p><p><code>For the Fourth Constraint:</code></p><p>By applying $$x = 3$$ on our third constraint $$d = c + 5$$ or $$d = (c+5) \times 1$$, we will get:</p><p>$$\begin{align*} A = [5,0,0,0,1,0] \ B = [1,0,0,0,0,0] \ C = [0,0,0,0,0,1] \end{align*}$$</p><p>$${ \small \begin{pmatrix} 5 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} \times \begin{pmatrix} 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} - \begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \ \end{pmatrix} \begin{pmatrix} S \ \end{pmatrix} = \begin{pmatrix} 0 \end{pmatrix} }$$</p><p>We have 5 as the first index in vector <code>A</code> and $$c=30$$ as the fifth index in vector <code>A</code>. 1 is the first index in vector <code>B</code> and <code>d = 35</code> is the last index in vector <code>C</code>.</p><p>After adding the vector <code>A</code> of all the constraints from 1 to 4 into a single vector <code>A</code> and doing the same thing for vector <code>B</code> and <code>C</code>, we will get the complete R1CS or final vector form of $$(A.S) \times (B.S) - (C.S) = 0$$ for $$x =3$$ :</p><p>$${\small {\begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ 5 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} S</p><p>\end{pmatrix} \times {\begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} S</p><h2 id="h-endpmatrix" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">\end{pmatrix}</h2><h1 id="h-beginpmatrix-0-and-0-and-1-and-0-and-0-and-0-0-and-0-and-0-and-1-and-0-and-0-0-and-0-and-0-and-0-and-1-and-0-0-and-0-and-0-and-0-and-0-and-1-endpmatrix-beginpmatrix-s-endpmatrix" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">{\begin{pmatrix} 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \ \end{pmatrix}} \begin{pmatrix} S \end{pmatrix}</h1><p>\begin{pmatrix} 0 \ 0 \ 0 \ 0 \end{pmatrix} }$$</p><p>Now let’s do the dot product of vector <code>A,B</code> and <code>C</code> with vector <code>S</code> but only for the first row of each vector to check if our calculations are correct.</p><p><code>For Vector A :</code></p><p>$${\begin{pmatrix} \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{1} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} \ 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ 5 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} \textcolor{lightblue}{1} \ \textcolor{lightblue}{3} \ \textcolor{lightblue}{9} \ \textcolor{lightblue}{27} \ \textcolor{lightblue}{30} \ \textcolor{lightblue}{35} \end{pmatrix} = 3$$</p><p>$$(0 \times 1) + (1 \times 3) + (0 \times 9) + (0 \times 27) + (0 \times 30) + (0 \times 35) = 3$$</p><p><code>For Vector B :</code></p><p>$${\begin{pmatrix} \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{1} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} \ 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} \textcolor{lightblue}{1} \ \textcolor{lightblue}{3} \ \textcolor{lightblue}{9} \ \textcolor{lightblue}{27} \ \textcolor{lightblue}{30} \ \textcolor{lightblue}{35} \end{pmatrix} = 3$$</p><p>$$(0 \times 1) + (1 \times 3) + (0 \times 9) + (0 \times 27) + (0 \times 30) + (0 \times 35) = 3$$</p><p><code>For Vector C :</code></p><p>$${\begin{pmatrix} \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{1} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} &amp; \textcolor{lightblue}{0} \ 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \ \end{pmatrix}} \begin{pmatrix} \textcolor{lightblue}{1} \ \textcolor{lightblue}{3} \ \textcolor{lightblue}{9} \ \textcolor{lightblue}{27} \ \textcolor{lightblue}{30} \ \textcolor{lightblue}{35} \end{pmatrix} = 9$$</p><p>$$(0 \times 1) + (0 \times 3) + (1 \times 9) + (0 \times 27) + (0 \times 30) + (0 \times 35) = 9$$</p><p>Final Equation :</p><p>$$(A.S) \times (B.S) - (C.S) = 3 \times 3 - 9 = 0$$</p><p>The Prover has provided the correct first part of the proof. We can then got through the other 3 rows for each vector <code>A, B</code> and <code>C</code> to find that the results will be zero but we won’t do it because you got the point. You can try it yourself and see that for every line $$A \times B - C$$ will always be <code>zero</code>. The Prover has thus proven that he knows the solution of the cubic equation. If you’re too lazy here’s the answers :</p><p>$$\begin{align*} 3 \times 3 - 9 = 0 \ 9 \times 3 - 27 = 0 \ (3+27) \times 1 - 30 = 0\ (5+30) \times 1 - 35 = 0 \ \end{align*}$$</p><p>To not create any confusion later we will refer to $$(A.S) \times (B.S) - (C.S) = 0$$ as</p><p>$$(A’.S) \times (B’.S) - (C’.S) = 0$$. A will be called <code>A’</code>, <code>B’</code> for B and <code>C’</code> for C.</p><h2 id="h-r1cs-to-qap" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">R1CS to QAP</h2><p>The next step is taking this R1CS and converting it into QAP form, which implements the exact same logic except using polynomials instead of dot products. We go from <code>four groups of three vectors of length six</code> to <code>six groups of three degree-3 polynomials</code>, where evaluating the polynomials at each <em>x coordinate</em> represents one of the constraints. That is, if we evaluate the polynomials at $$x=1$$, then we get our first set of vectors, if we evaluate the polynomials at $$x=2$$, then we get our second set of vectors, and so on.</p><p>We can make this transformation using something called a <em>Lagrange interpolation</em>. The problem that a Lagrange interpolation solves is this: if you have a set of points (i.e. (x, y) coordinate pairs), then doing a Lagrange interpolation on those points gives you a polynomial that passes through all of those points.</p><p>What we are going to do is take the first value out of every <code>A’</code> vector, use Lagrange interpolation to make a polynomial out of that (where evaluating the polynomial at <code>i</code> gets you the first value of the ith <code>A’</code> vector), repeat the process for the first value of every <code>B’</code> and <code>C’</code> vector, and then repeat that process for the second values, the third values, and so on.</p><h3 id="h-step-1" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Step 1</h3><p>Since we have 4 constraints, we will choose values for $$x$$ such that $$x \in [ 1,2,3,4 ]$$.</p><p>We’re gonna have 6 polynomials against 6 variables and <code>A’,B’,C’</code> are going to be these polynomials. Don’t worry if you didn’t understand this, we’ll explain everything.</p><p>We’re gonna evaluate each vector <code>A,B</code> and <code>C</code> for every value of $$x \in [ 1,2,3,4 ]$$ at every constraint.</p><h3 id="h-first-constraint" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">First constraint</h3><p>Remember vector <code>A, B</code> and <code>C</code> for the <code>first constraint</code> :</p><p>$$\begin{align*} A = [0,\textcolor{lightblue}{1},0,0,0,0] \ B = [0,\textcolor{lightblue}{1},0,0,0,0] \ C = [0,0,\textcolor{lightblue}{1},0,0,0] \end{align*}$$</p><p>We evaluate <code>A, B</code> and <code>C</code> for $$x = 1$$ :</p><p>$$\begin{align*} A_1(1) = 0 \hspace{1 cm} B_1(1) = 0 \hspace{1 cm} C_1(1) = 0 \ A_2(1) = \textcolor{lightblue}{1} \hspace{1 cm} B_2(1) = \textcolor{lightblue}{1} \hspace{1 cm} C_2(1) = 0 \ A_3(1) = 0 \hspace{1 cm} B_3(1) = 0 \hspace{1 cm} C_3(1) = \textcolor{lightblue}{1} \ A_4(1) = 0 \hspace{1 cm} B_4(1) = 0 \hspace{1 cm} C_4(1) = 0 \ A_5(1) = 0 \hspace{1 cm} B_5(1) = 0 \hspace{1 cm} C_5(1) = 0 \ A_6(1) = 0 \hspace{1 cm} B_6(1) = 0 \hspace{1 cm} C_6(1) = 0 \end{align*}$$</p><h3 id="h-second-constraint" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Second Constraint</h3><p>$$\begin{align*} A = [0,0,\textcolor{lightblue}{1},0,0,0] \ B = [0,\textcolor{lightblue}{1},0,0,0,0] \ C = [0,0,0,\textcolor{lightblue}{1},0,0] \end{align*}$$</p><p>We evaluate <code>A, B</code> and <code>C</code> for $$x = 2$$ :</p><p>$$\begin{align*} A_1(2) = 0 \hspace{1 cm} B_1(2) = 0 \hspace{1 cm} C_1(2) = 0 \ A_2(2) = 0 \hspace{1 cm} B_2(2) = \textcolor{lightblue}{1} \hspace{1 cm} C_2(2) = 0 \ A_3(2) = \textcolor{lightblue}{1} \hspace{1 cm} B_3(2) = 0 \hspace{1 cm} C_3(2) = 0 \ A_4(2) = 0 \hspace{1 cm} B_4(2) = 0 \hspace{1 cm} C_4(2) = \textcolor{lightblue}{1} \ A_5(2) = 0 \hspace{1 cm} B_5(2) = 0 \hspace{1 cm} C_5(2) = 0 \ A_6(2) = 0 \hspace{1 cm} B_6(2) = 0 \hspace{1 cm} C_6(2) = 0 \end{align*}$$</p><h3 id="h-third-constraint" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Third Constraint</h3><p>$$\begin{align*} A = [0,\textcolor{lightblue}{1},0,\textcolor{lightblue}{1},0,0] \ B = [\textcolor{lightblue}{1},0,0,0,0,0] \ C = [0,0,0,0,\textcolor{lightblue}{1},0] \end{align*}$$</p><p>We evaluate <code>A, B</code> and <code>C</code> for $$x = 3$$ :</p><p>$$\begin{align*} A_1(3) = 0 \hspace{1 cm} B_1(3) = \textcolor{lightblue}{1} \hspace{1 cm} C_1(3) = 0 \ A_2(3) = \textcolor{lightblue}{1} \hspace{1 cm} B_2(3) = 0 \hspace{1 cm} C_2(3) = 0 \ A_3(3) = 0 \hspace{1 cm} B_3(3) = 0 \hspace{1 cm} C_3(3) = 0 \ A_4(3) = \textcolor{lightblue}{1} \hspace{1 cm} B_4(3) = 0 \hspace{1 cm} C_4(3) = 0 \ A_5(3) = 0 \hspace{1 cm} B_5(3) = 0 \hspace{1 cm} C_5(3) = \textcolor{lightblue}{1} \ A_6(3) = 0 \hspace{1 cm} B_6(3) = 0 \hspace{1 cm} C_6(3) = 0 \end{align*}$$</p><h3 id="h-fourth-constraint" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Fourth Constraint</h3><p>$$\begin{align*} A = [\textcolor{lightblue}{5},0,0,0,\textcolor{lightblue}{1},0] \ B = [\textcolor{lightblue}{1},0,0,0,0,0] \ C = [0,0,0,0,0,\textcolor{lightblue}{1}] \end{align*}$$</p><p>We evaluate <code>A, B</code> and <code>C</code> for $$x = 4$$ :</p><p>$$\begin{align*} A_1(4) = \textcolor{lightblue}{5} \hspace{1 cm} B_1(4) = \textcolor{lightblue}{1} \hspace{1 cm} C_1(4) = 0 \ A_2(4) = 0 \hspace{1 cm} B_2(4) = 0 \hspace{1 cm} C_2(4) = 0 \ A_3(4) = 0 \hspace{1 cm} B_3(4) = 0 \hspace{1 cm} C_3(4) = 0 \ A_4(4) = 0 \hspace{1 cm} B_4(4) = 0 \hspace{1 cm} C_4(4) = 0 \ A_5(4) = \textcolor{lightblue}{1} \hspace{1 cm} B_5(4) = 0 \hspace{1 cm} C_5(4) = 0 \ A_6(4) = 0 \hspace{1 cm} B_6(4) = 0 \hspace{1 cm} C_6(4) = \textcolor{lightblue}{1} \end{align*}$$</p><h3 id="h-step-2" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Step 2</h3><p>We can see $$A_1(x), …, A_6(x)$$, $$B_1(x), …, B_6(x)$$ and $$C_1(x), …, C_6(x)$$ at every point $$x$$ from 1 to 4. We will display them in the format below :</p><p>$$\begin{align*} A_1(1) = 0 \hspace{1 cm} B_1(1) = 0 \hspace{1 cm} C_1(1) = 0 \ A_1(2) = 0 \hspace{1 cm} B_1(2) = 0 \hspace{1 cm} C_1(2) = 0 \ A_1(3) = 0 \hspace{1 cm} B_1(3) = 1 \hspace{1 cm} C_1(3) = 0 \ A_1(4) = 5 \hspace{1 cm} B_1(4) = 1 \hspace{1 cm} C_1(4) = 0 \ \hspace{0.5 cm}... \hspace{2.5 cm} ... \hspace{2.5 cm} ...\ A_6(1) = 0 \hspace{1 cm} B_6(1) = 0 \hspace{1 cm} C_6(1) = 0 \ A_6(2) = 0 \hspace{1 cm} B_6(2) = 0 \hspace{1 cm} C_6(2) = 0 \end{align*}$$</p><p>We have only a single polynomial of degree 3 that passes through $$A_1(1)$$ to $$A_1(4)$$. The polynomial will intersect the $$x-axis$$ at $$x = 1, 2 \space \text{and} \space 3$$ since the result for each one of them is <code>0</code> $$(A_1(1) = 0, A_1(2) = 0, A_1(3) = 0)$$ and will hit the line $$y = 5$$ for $$x = 4$$.</p><p>Or we can also take the $$ y-coordinates$$ in the first column in $$(A’.S) \times (B’.S) - (C’.S) = 0$$ for $$x \in [1,2,3,4]$$ resulting to 4 points $$(1,0), (2,0), (3,0), (4,5)$$ :</p><p>$${\small {\begin{pmatrix} \textcolor{orange}{0} &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \textcolor{orange}{0} &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ \textcolor{orange}{0} &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ \textcolor{orange}{5} &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} S</p><p>\end{pmatrix} \times {\begin{pmatrix} 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} S</p><h2 id="h-endpmatrix" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">\end{pmatrix}</h2><h1 id="h-beginpmatrix-0-and-0-and-1-and-0-and-0-and-0-0-and-0-and-0-and-1-and-0-and-0-0-and-0-and-0-and-0-and-1-and-0-0-and-0-and-0-and-0-and-0-and-1-endpmatrix-beginpmatrix-s-endpmatrix" class="text-4xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">{\begin{pmatrix} 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 &amp; 0 &amp; 1 \ \end{pmatrix}} \begin{pmatrix} S \end{pmatrix}</h1><p>\begin{pmatrix} 0 \ 0 \ 0 \ 0 \end{pmatrix} }$$</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/d25965d458152ed3a6a2308cffb57a0967d9f66439b2ed7245bbf0f53260590d.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>This is an arbitrary interpretation which we use to convert the R1CS into the QAP form. We could have as well used $$[5,7,9,11]$$ instead of $$[1,2,3,4]$$ as long as we are consistent across all equations.</p><p>The number of polynomials &amp; their degree would depend on the length of the solution vector &amp; the number of gates.</p><p>The solution vector <code>S</code> contains 6 elements $$[1, 3, 9, 27, 30, 35]$$, so we can construct 6 polynomials per vector. Each gate contributes 1 point to each polynomial. We have 4 gates here meaning we get 4 points per polynomial. 4 points allows us to define a polynomial of maximum degree 3. So we can construct 6 polynomials each with a maximum degree of 3.</p><p>A visual representation of the points for each polynomial of <code>vector A’</code> will look like :</p><p>$$\begin{align*} \textcolor{orange}{(}A_1(1),..., A_1(4)\textcolor{orange}{)}, \textcolor{orange}{(}A_2(1),..., A_2(4)\textcolor{orange}{)}, \textcolor{orange}{(}A_3(1),..., A_3(4)\textcolor{orange}{)}, \ \textcolor{orange}{(}A_4(1),..., A_4(4)\textcolor{orange}{)}, \textcolor{orange}{(}A_5(1),..., A_5(4)\textcolor{orange}{)}, \textcolor{orange}{(}A_6(1),..., A_6(4)\textcolor{orange}{)} \end{align*}$$</p><p>So in total we have 3 vectors <code>A’, B’</code> and <code>C’</code> with 6 polynomials each, resulting in 18 polynomials.</p><p>We can find the polynomial passing through these 4 points using <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://en.wikipedia.org/wiki/Lagrange_polynomial">Lagrange Interpolation</a>. We will only demonstrate for only the first polynomial and give you the result for all 18 polynomials. You can do the other ones by yourselves and compare your answers.</p><h3 id="h-lagrange-interpolation" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Lagrange Interpolation</h3><p>To construct the Lagrange interpolation polynomial for the points $$(1,0),(2,0),(3,0),(4,5)$$ over a finite field with $$GF(641)$$, we’ll use the following approach.</p><p>Given points $$(x_1 ​ ,y_1 ​ ),(x_2 ​ ,y_2 ​ ), …, (x_n ​ ,y_n ​)$$, the Lagrange polynomial $$L(x)$$ is constructed as:</p><p>$$L(x) = \sum^n_{i=1} y_i ⋅ l_i(x)$$</p><p>where each $$l_i(x)$$ is the Lagrange basis polynomial for point $$(x_i, y_i)$$, defined by:</p><p>$$l_i(x) = \Pi_{j \neq i} \frac{x-x_j}{x_i - x_j} \space (mod \space 641)$$</p><p>In this case :</p><ul><li><p>The points are :</p><ul><li><p>$$( 𝑥_1 , 𝑦_1 ) = ( 1 , 0 )$$</p></li><li><p>$$( 𝑥_2 , 𝑦_2 ) = ( 2 , 0 )$$</p></li><li><p>$$( 𝑥_3 , 𝑦_3 ) = ( 3 , 0 )$$</p></li><li><p>$$( 𝑥_4 , 𝑦_4 ) = ( 4 , 5 )$$</p></li></ul></li><li><p>Field $$GF(641)$$</p></li></ul><p>Since $$𝑦_1 ​ =y_2 ​ =y_3 ​ =0$$, only $$𝑦_4 = 5$$ contributes to the polynomial, so we need only compute $$l_4 ( 𝑥 )$$.</p><p>Step-by-Step Calculation of $$l_4 ( 𝑥 )$$ :</p><p>$$l_4(x)= \frac{(x-x_1)(x-x_2)(x-x_3)}{(x_4-x_1)(x_4-x_2)(x_4-x_3)} \space (mod \space 641)$$</p><p>Substitute $$𝑥_1=1, 𝑥_2​ =2, 𝑥_3=3$$, and $$𝑥_4=4$$ :</p><ol><li><p><strong>Calculate the denominator</strong> :</p><p>$$(4−1)(4−2)(4−3)=3⋅2⋅1=6 $$$</p><p>Inverse of $$6 \space mod \space 641$$ is $$107$$, since $$6 \times 107 \equiv 1 \space (mod \space 641)$$.</p></li><li><p><strong>Compute</strong> $$l_4 ( 𝑥 )$$ :</p><p>$$$ l_4(x) = 107 ⋅(x−1)(x−2)(x−3) \space (mod \space 641) $$$</p></li><li><p><strong>Expand</strong> $$(x-1)(x-2)(x-3)$$ :</p><p>Expanding this product :</p><p>$$$ (x−1)(x−2)=x^2−3x+2 $$$$$</p></li></ol><p>(x^2−3x+2)(x−3) = x^3−3x^2 −3x^2+9x+2x−6 = x^3 −6x^2+11x−6 $$Substitute into $$l_4(x)$$ :$$ l_4(x)= 107(x^3−6x^2+11x−6)=107x^3 - 642x^2 + 1177x - 642 \space (mod \space 10) $$Final Polynomial $$L(x)$$ :$$ \begin{align*} L(x) &amp;= y_4 \times l_4(x)=5 \times(107x^3 - 642x^2 + 1177x - 642 ) \space (mod \space 641) \ L(x) &amp;= (535x^3 - 3210x^2 + 5885x - 3210) \space (mod \space 641) \end{align*} $$So the polynomial corresponding to the first Column of vector <code>A’</code> is :$$ L(x)=535x^3+ 636x^2+ 116x+ 636 $$Since we didn’t calculated $$𝑦_1, y_2, y_3$$, you can ask chatgpt to calculate $$y_1, y_2, y_3, y_4$$ and generate the final polynomial if you have more than one point with coordinates other than 0.</p><p>Below are all coefficients of all 18 polynomials that we applied a finite field 641 to :</p><p>Polynomials of <code>vector A’</code> : We’ll call the new vector, vector <code>A’’</code>.$$ {\begin{pmatrix} 636 &amp; 116 &amp; 636 &amp; 535 \ 213 &amp; 5 &amp; 416 &amp; 8 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} $$You can see the polynomial we got from the first column i.e. $$(535x^3+ 636x^2+ 116x+ 636$$) appear in first row of vector <code>A’’</code>. The Row is to be interpreted in reverse order - i.e. $$[4, 2, 3, 7]$$.</p><p>I’m going to re-explain what happened so we won’t get confused later. We applied Lagrange interpolation to the first column of vector <code>A’</code> and we got the first row of vector <code>A’’</code> but in reverse.$$ { \small {\begin{pmatrix} \textcolor{orange}{0} &amp; 1 &amp; 0 &amp; 0 &amp; 0 &amp; 0 \ \textcolor{orange}{0} &amp; 0 &amp; 1 &amp; 0 &amp; 0 &amp; 0 \ \textcolor{orange}{0} &amp; 1 &amp; 0 &amp; 1 &amp; 0 &amp; 0 \ \textcolor{orange}{5} &amp; 0 &amp; 0 &amp; 0 &amp; 1 &amp; 0 \ \end{pmatrix}} \longrightarrow {\begin{pmatrix} \textcolor{orange}{636} &amp; \textcolor{orange}{116} &amp; \textcolor{orange}{636} &amp; \textcolor{orange}{535} \ 8 &amp; 416 &amp; 5 &amp; 213 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} } $$Polynomials of vector <code>B’</code> : We’ll call the new vector, vector <code>B’’</code>.$$ {\begin{pmatrix} 3 &amp; 529 &amp; 323 &amp; 427 \ 639 &amp; 112 &amp; 318 &amp; 214 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} $$Polynomials of <code>vector C’</code> : We’ll call the new vector, vector <code>C’’</code>.$$ {\begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 4 &amp; 423 &amp; 322 &amp; 534 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ \end{pmatrix}} $$This finishes the transformation of the problem to the QAP Form.</p><p>What do we achieve by converting it into the QAP form? Instead of checking the constraints in the R1CS individually, we can now check all of the constraints at the same time by doing the dot product check on the polynomials.</p><p>Our solution <code>S</code> has 6 elements $$[1, 3, 9, 27, 30, 35]$$. we can do a dot product of $$(S.A&apos;&apos;)$$ whose output again will be a polynomial. Likewise for the other 2 polynomial matrices.</p><p>For vector <code>A’’</code> :$$ {\begin{pmatrix} \textcolor{orange}{636} &amp; \textcolor{orange}{116} &amp; \textcolor{orange}{636} &amp; \textcolor{orange}{535} \ 8 &amp; 416 &amp; 5 &amp; &amp; 213 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} \textcolor{orange}{1} \ \textcolor{orange}{3} \ \textcolor{orange}{9} \ \textcolor{orange}{27} \ \textcolor{orange}{30} \ \textcolor{orange}{35} \end{pmatrix} = ... $$We know the dot product is done by multiplying all the values of each row at a time in <code>A’’</code> with vector <code>S</code>. Like this for the first row:$$ (636 \times 1) + (116 \times 3) + (636 \times 9) + (535 \times 27) + (0 \times 30) + (0 \times 35) = ... $$This approach is not correct!! Since we have rotated <code>A’</code> going to <code>A’’</code>, we will need to calculate the dot product vertically like this for the first column :$$ {\begin{pmatrix} {636} &amp; {116} &amp; 636 &amp; \textcolor{orange}{535} \ 8 &amp; 416 &amp; 5 &amp; \textcolor{orange}{213} \ 635 &amp; 330 &amp; 637 &amp; \textcolor{orange}{321} \ 4 &amp; 634 &amp; 324 &amp; \textcolor{orange}{320} \ 640 &amp; 536 &amp; 640 &amp; \textcolor{orange}{107} \ 0 &amp; 0 &amp; 0 &amp; \textcolor{orange}{0} \ \end{pmatrix}} \begin{pmatrix} \textcolor{orange}{1} \ \textcolor{orange}{3} \ \textcolor{orange}{9} \ \textcolor{orange}{27} \ \textcolor{orange}{30} \ \textcolor{orange}{35} \end{pmatrix} = 529\textcolor{orange}{x^3} + 359\textcolor{orange}{x^2} + 354\textcolor{orange}{x} + 43 $$$$ \begin{align*} &amp;(535 \times 1) + (213 \times 3) + (321 \times 9) + (320 \times 27) + (107 \times 30) + (0 \times 35) \ &amp; 535 + 639 + 2889 + 8640 + 3210 + 0 = 15913\ \end{align*}<br>$$We do the same thing for all 4 columns while applying $$GF(641)$$ :$$ \begin{align*} &amp; \text{1st column : } 15913 \textcolor{orange}{x^3} \ &amp; 15913 \textcolor{orange}{x^3} \mod 641 = 529\textcolor{orange}{x^3} \ &amp; \text{2nd column : } 34332 \textcolor{orange}{x^2} \ &amp; 34332 \textcolor{orange}{x^2} \mod 641 = 359\textcolor{orange}{x^2} \ &amp; \text{3rd column : } 37532\textcolor{orange}{x} \ &amp; 37532\textcolor{orange}{x} \mod 641 = 354\textcolor{orange}{x} \ &amp; \text{4th column : } 25683 \ &amp; 25683 \mod 641 = 43 \end{align*} $$or we can rotate the vector <code>A’’</code> to get 4 rows and 6 columns instead of 6 rows and 4 columns and do the dot product as we usually do it, horizontally.</p><p>For vector <code>B’’</code> :$$ {\begin{pmatrix} 3 &amp; 529 &amp; 323 &amp; 427 \ 639 &amp; 112 &amp; 318 &amp; 214 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} 1 \ 3 \ 9 \ 27 \ 30 \ 35 \end{pmatrix} = 428\textcolor{orange}{x^3} + 636\textcolor{orange}{x^2} + 224\textcolor{orange}{x} + 638 $$$$ \begin{align*} &amp; \text{1st column : } 1069\textcolor{orange}{x^3} \ &amp; 1069\textcolor{orange}{x^3} \mod 641 = 428\textcolor{orange}{x^3} \ &amp; \text{2nd column : } 1277\textcolor{orange}{x^2}\ &amp; 1277\textcolor{orange}{x^2} \mod 641 = 636\textcolor{orange}{x^2} \ &amp; \text{3rd column : } 865\textcolor{orange}{x} \ &amp; 865\textcolor{orange}{x} \mod 641 = 224\textcolor{orange}{x} \ &amp; \text{4th column : } 1920 \ &amp; 1920 \mod 641 = 638 \end{align*} $$For vector <code>C’’</code> :$$ {\begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 4 &amp; 423 &amp; 322 &amp; 534 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ \end{pmatrix} } \begin{pmatrix} 1 \ 3 \ 9 \ 27 \ 30 \ 35 \end{pmatrix} = 537\textcolor{orange}{x^3} + 296\textcolor{orange}{x^2} + 499\textcolor{orange}{x} + 600 $$$$ \begin{align*} &amp; \text{1st column : } 26818\textcolor{orange}{x^3} \ &amp; 26818\textcolor{orange}{x^3} \mod 641 = 537\textcolor{orange}{x^3} \ &amp; \text{2nd column : } 52217\textcolor{orange}{x^2} \ &amp; 52217\textcolor{orange}{x^2} \mod 641 = 296\textcolor{orange}{x^2} \ &amp; \text{3rd column : } 50497\textcolor{orange}{x} \ &amp; 50497\textcolor{orange}{x} \mod 641 = 499\textcolor{orange}{x} \ &amp; \text{4th column : } 39701 \ &amp; 39701 \mod 641 = 600 \end{align*} $$So by taking the dot product of <code>S</code> with each of matrix <code>A’’, B’’, C’’</code>, we created 3 polynomials.$$ \begin{align*} &amp; (A&apos;&apos;.S) = 529\textcolor{orange}{x^3} + 359\textcolor{orange}{x^2} + 354\textcolor{orange}{x} + 43 \ &amp; (B&apos;&apos;.S) = 428\textcolor{orange}{x^3} + 636\textcolor{orange}{x^2} + 224\textcolor{orange}{x} + 638 \ &amp; (C&apos;&apos;.S) = 537\textcolor{orange}{x^3} + 296\textcolor{orange}{x^2} + 499\textcolor{orange}{x} + 600 \end{align*} $$We can define a new polynomial :$$ T = (A&apos;&apos;.S) \times (B&apos;&apos;.S) - (C&apos;&apos;.S) $$$$ {\small T =<br>{\begin{pmatrix} 636 &amp; 116 &amp; 636 &amp; 535 \ 213 &amp; 5 &amp; 416 &amp; 8 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} 1 \ 3 \ 9 \ 27 \ 30 \ 35 \end{pmatrix} \times {\begin{pmatrix} 3 &amp; 529 &amp; 323 &amp; 427 \ 639 &amp; 112 &amp; 318 &amp; 214 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ \end{pmatrix}} \begin{pmatrix} 1 \ 3 \ 9 \ 27 \ 30 \ 35 \end{pmatrix} - {\begin{pmatrix} 0 &amp; 0 &amp; 0 &amp; 0 \ 0 &amp; 0 &amp; 0 &amp; 0 \ 4 &amp; 423 &amp; 322 &amp; 534 \ 635 &amp; 330 &amp; 637 &amp; 321 \ 4 &amp; 634 &amp; 324 &amp; 320 \ 640 &amp; 536 &amp; 640 &amp; 107 \ \end{pmatrix}} \begin{pmatrix} 1 \ 3 \ 9 \ 27 \ 30 \ 35 \end{pmatrix} } $$$$ \begin{align*} &amp; {\small T(x) =(529\textcolor{orange}{x^3} + 359\textcolor{orange}{x^2} + 354\textcolor{orange}{x} + 43) \times (428\textcolor{orange}{x^3} + 636\textcolor{orange}{x^2} + 224\textcolor{orange}{x} + 638 ) - (537\textcolor{orange}{x^3} + 296\textcolor{orange}{x^2} + 499\textcolor{orange}{x} + 600) } \ &amp; T(x) = 139\textcolor{orange}{x^6} + 372\textcolor{orange}{x^5} + 275\textcolor{orange}{x^4} + 58\textcolor{orange}{x^3} + 147\textcolor{orange}{x^2} + 379\textcolor{orange}{x} + 553<br>\end{align*}<br>$$In the R1S, we had checked if $$(A.S)∗(B.S)-(C.S) = 0$$ for each of the Gates. After conversion to QAP, we can do the same by checking the value of $$T$$ at $$x$$  at $$1,2,3,4$$- if all 4 are <code>zero</code>, then we have checked all the constraints together <code>- thereby proving that the solution vector known to the Provers satisfies the equation.</code>$$ T(1) = T(2) = T(3) = T(4) = 0 $$Let take a value, for example $$3$$ at lets check if its $$0$$ for $$T(3)$$ :$$ \begin{align*} &amp; T(3) = 139 \times \textcolor{orange} {3^6} + 372 \times \textcolor{orange} {3^5} + 275 \times \textcolor{orange} {3^4} + 58 \times \textcolor{orange}{3^3} + 147\times \textcolor{orange}{3^2} + 379 \times \textcolor{orange}{3} + 553 \ &amp; T(3) = 218581 \mod 641 = 0 \end{align*}<br>$$However, the Verifier doesn’t know the polynomial $$T$$, nor can he compute it since he doesn’t know the solution vector <code>S</code>. So the Prover has to prove it to the Verifier that $$T$$ is <code>zero</code> at $$x \in [1,2,3,4]$$. If T is really <code>zero</code> at $$x \in [1,2,3,4]$$, then we say that these are all roots of $$T$$. So we create a new polynomial $$Z$$ known by both the Prover &amp; the Verifier. If $$T$$ is perfectly divisible by $$Z$$, then it will leave no remainder.</p><p>Let $$Z$$ be :$$ Z = (x-1) \times (x-2) \times (x-3) \times (x-4) $$So there must exist a Polynomial $$H$$ such that :$$ T(x)=H(x) \times Z(x) $$$$ H(x) = \frac {T(x)} {Z(x)} = \frac{ 139\textcolor{orange}{x^6} + 372\textcolor{orange}{x^5} + 275\textcolor{orange}{x^4} + 58\textcolor{orange}{x^3} + 147\textcolor{orange}{x^2} + 379\textcolor{orange}{x} + 553 } {((x-1) \times (x-2) \times (x-3) \times (x-4))} = 0 $$$</p><p>In real life $$T$$ won’t be equal to 0. If it was 0, the Prover can act maliciously and prove that $$H(x) = 0$$ for any kind of polynomial $$Z(x)$$. This was just an example. If you structure vector $$S$$ like this $$[\textcolor{orange}{1},\textcolor{orange}{35},3,9,27,30]$$, $$T(x)$$ will equal to :</p><p>Usually they put the dummy variables like <code>1</code> or the <code>output</code> $$d = 35$$ at the start or/and in the end of the vector so this structure is also true : $$[\textcolor{orange}{1},\textcolor{orange}{35},3,9,27,30,\textcolor{orange}{35},\textcolor{orange}{1}]$$ or $$[\textcolor{orange}{1},\textcolor{orange}{35},3,9,27,30]$$.</p><p>In a typical <strong>zk-SNARK</strong>, the Prover proves that $$Z$$ exactly divides $$T$$ using Polynomial Commitments &amp; Elliptic Curve Bilinear Pairings.</p><p>This is the end of our article. Hope it wasn’t hard to understand. To make sure you fully understood, you can try different structures of vector <code>S</code> then check that $$T(x) = 0$$ for $$x \in [1,2,3,4]$$ and $$H(x) = \frac {T(x)} {Z(x)}$$ has no a remainder of 0.</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/cdbb8037c0f66ac1b7fbc28a68677ac98523046252ea10710c1347d149df204e.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[SumCheck Protocol | A Love Story between a Prover and a Verifier]]></title>
            <link>https://paragraph.com/@farfromaverage/sumcheck-protocol-a-love-story-between-a-prover-and-a-verifier</link>
            <guid>a4Vlqm7og2dVtl8KIUAn</guid>
            <pubDate>Fri, 25 Oct 2024 15:08:16 GMT</pubDate>
            <description><![CDATA[IntroductionHow can a Prover convince a Verifier that he can accurately compute the sum of the evaluation of a function $$g$$ over all possible inputs $${ 0,1 }$$ ? Let&apos;s say the Prover has a function $$g$$ that takes several binary variables, $$b_1,b_2,…,b_l$$, where each variable can only be either $$0$$ or $$1$$. The goal is for the Prover to convince the Verifier that he can compute the sum of the function $$g$$ evaluated on all possible combinations of these binary inputs correctly ...]]></description>
            <content:encoded><![CDATA[<h2 id="h-introduction" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Introduction</h2><p>How can a Prover convince a Verifier that he can accurately compute the <strong>sum of the evaluation of a function</strong> $$g$$ over all possible inputs $${ 0,1 }$$ ?</p><p>Let&apos;s say the Prover has a function $$g$$ that takes several binary variables, $$b_1,b_2,…,b_l$$, where each variable can only be either $$0$$ or $$1$$. The goal is for the Prover to convince the Verifier that he can compute the sum of the function $$g$$ evaluated on <strong>all possible combinations</strong> of these binary inputs correctly without any malicious intent.</p><p>This sum would be:</p><p>$$C = \sum_{b_1,b_2,…,b_l \in { 0,1 }} g(b_1,b_2,…,b_l)$$</p><p>simplified to :</p><p>$$\sum_{b_1 \in { 0,1 }} \sum_{b_2 \in { 0,1 }} ... \sum_{b_l \in { 0,1 }} g(b_1,...,b_l)$$</p><p>However, instead of the Verifier recomputing everything to check if the Prover’s claim is correct (which could take too long if there are many variables), they use the <strong>sumcheck protocol</strong>.</p><p>For instance suppose we define the function $$g$$ :</p><p>$$g(b_1,b_2,b_3,b_4,b_5)= 2b^2_1+b_2+b_1b_2b_3-b_4+b_2b^3_5$$</p><p>As you can see below, this function has a different evaluation for all possible combination of 0 and 1 for the variables of $$b_1$$ to $$b_5$$.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/359899751cb6853e36b87dd20a9b1f8acdba7830ce5d9c65ea9554c3ae5de6af.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>If the Prover has calculated the sum of all evaluations and combined them together by taking the result of $$g(b_1,b_2,b_3,b_4,b_5)$$ at every possible combination (32 combinations because $$2^5=32$$) and adding them up, it will amount to 44.</p><p>Quick demonstration:</p><p>If we replace $$g(b_1,b_2,b_3,b_4,b_5)$$ with $${ 0,0,0,0,0 }$$, we will get 0.</p><p>$$g(b_1,b_2,b_3,b_4,b_5)= 2b^2_1+b_2+b_1b_2b_3-b_4+b_2b^3_5$$</p><p>$$g(0,0,0,0,0) = 2 \times 0 + 0 + 0 \times 0 \times 0 - 0 + 0 \times 0 = 0$$</p><p>$$g(0,0,0,0,0) + g(0,0,0,0,1)+ ... + g(1,1,1,1,1) = 44$$</p><p>How can the Prover convince the verifier that the calculated value 44 is correct and has not been tampered with?</p><p><code>The naive solution is that the verifier could calculate the sum himself but this is time consuming, so we need a more efficient algorithm. The sum-check protocol provides a solution for this problem.</code></p><h3 id="h-general-overview-of-sumcheck-protocol" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">General Overview of Sumcheck Protocol</h3><p>This is just a general overview, don’t worry if you don’t understand it. We’ll explain everything later so you skip it if you want.</p><ul><li><p><strong>Start :</strong> Prover sends claimed answer $$C_1$$ which in our previous example was 44. The protocol must check that :</p></li></ul><p>$$C_1 = \sum_{b_1 \in {0,1 }} \sum_{b_2 \in{0,1}} ... \sum_{b_l \in {0,1 }} g(b_1,...,b_l)$$</p><ul><li><p><strong>Round 1 :</strong> Prover sends univariate polynomial $$S_1(X_1)$$ claimed to equal :</p></li></ul><p>$$H_1(X_1) = \sum_{b_2 \in{0,1}} ... \sum_{b_l \in {0,1 }} g(X_1,...,b_l)$$</p><blockquote><p>$$s_1$$ what the prover actually sends and $$H_1$$ is what the prover would send if the prover is honest. Note that the degree of $$H_1$$ and $$X_1$$ is at most the degree of the multivariate $$g$$ in its first variable meaning that if $$g$$ has a low degree in each variable (for example : 2 or 3) then even though there are $$2^{l -1}$$ terms in this sum, $$H_1$$ will simply be a degree 2 or 3 univariate polynomial. Hence, specifying $$H_1$$ can be done by just sending three or 4 coefficients.</p></blockquote><p>Verifier checks that $$C_1 = s_1(0) + s_1(1)$$. If this check passes, it is safe for the Verifier to assume that $$C_1$$ is the correct answer, so long as the Verifier believes that $$s_1 = H_1$$. How do we check that ? We just check that $$s_1$$ and $$H_1$$ agree at a random point $$r_1$$.</p><ul><li><p><strong>Round $$l$$ (Final Round):</strong> The Prover sends univariate polynomials $$s_l(X_l)$$ claimed to be equal :</p><p>$$H_l := g(r_1,...,r_{l-1},X_l) $$$</p></li></ul><p>Verifier checks that $$s_{l-1}(r_{l-1}) ] = s_l(0) + s_l(1)$$.</p><p>Verifier picks $$r_l$$ at random, and needs to check that $$s_l(r_l) = g(r_l,…,r_l)$$.</p><p>No need for more rounds, the verifier can perform this check with one oracle query. So after $$ l$$ rounds of interaction, the prover can convince the verifier.</p><h2 id="h-round-one" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0"><strong>Round One</strong></h2><p>In this example we will be sticking to our original function $$g$$:$$ \boxed {g(b_1,b_2,b_3,b_4,b_5)= 2b^2_1+b_2+b_1b_2b_3-b_4+b_2b^3_5} $$Prover knows the function $$g(b_1,b_2,b_3,b_4,b_5)$$ and he wants to compute :$$ C_1 = \sum_{b_1 \in {0,1 }} \sum_{b_2 \in{0,1}} \sum_{b_3 \in {0,1 }}\sum_{b_4 \in {0,1 }}\sum_{b_5 \in {0,1 }} g(b_1,b_2,b_3,b_4,b_5) $$</p><p>In the first step, the Verifier shares the function with the Prover and ask him what the summation of all evaluations which is $$C_1$$.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/9171c5eb52883a113034f2a465f181764c8c34328b4e28ec63fb102d21805d51.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>In the first round, the Prover calculates the required summation which is $$C_1$$. This means that the Prover needs to open the summation over all the variables of $$b_1$$ to $$b_5$$ for the values $$0$$ and $$1$$. For better comprehension, we can write the above image/function like this :$$ g(0,0,0,0,0) + g(0,0,0,0,1)+ ... + g(1,1,1,1,1) = 44 $$After the Prover has calculated the sum of all evaluations and combined them together, he will get the value 44 which is the required summation $$C_1$$.</p><p>Then the prover will have to share this value with the verifier. However only providing the value isn’t enough to satisfy the Verifier because she doesn’t know if the Prover has really done the work, has really calculated this summation properly. Thus some extra calculations need to be done and shared to satisfy the Verifier. We can’t upset the Verifier. The Prover might also need to buy her some flowers while he’s at it.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/bc4abd3aa707684c9564d4d517fad14a73e265de59fd8425b18bfb19cf4e4d64.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>For the extra calculations, the Prover needs to define $$H_1X_1$$. This step is repetitive in different in every single interaction. So in each round the Prover has to form a function $$H_iX_i$$. In the first round, the Prover forms the function $$H_1X_1$$ by only swapping the first variable $$b_1$$ of function $$g$$, by $$X_1$$. This means that the Prover needs to hold this fixed variable and then calculate the summation based on the remaining variables $$b_2$$ to $$b_5$$. So each variable in the function g except $$X_1$$ can be either $$0$$ or $$1$$.</p><p>This computation leads a polynomial :$$ H_1(X_1) = 32X^2_1 + 4X_1 + 4 $$</p><p>By assuming that the Prover is malicious and might not have shared the accurate function $$H_1(X_1)$$, we will need to use a different notation as $$s_1(X_1)$$.</p><blockquote><p>$$s_1$$ what the prover actually sends and $$H_1$$ is what the prover would send if the prover is honest.</p></blockquote><p>We expect that $$s_1$$ should be equal to $$H_1$$. The Prover later sends $$C_1$$ as the summation of the evaluation, the polynomial $$s_1(X_1)$$ and the coefficient of the polynomial $$32X^2_1+4X_1+4$$ which are $${32,4,4 }$$.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/3b93d239b58f528da3b49b119575f6e533045cbcb6288d450b3145feac6c24a8.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>On the verification side, the Verifier forms $$s_1(X_1)$$ using the received coefficients and then calculates $$s_1(0)$$ which is 4.</p><p>So the Verifier replaces $$X_1$$ with 0 in the polynomial $$32X^2_1+4X1+4$$ which results to $$32×0+4×0+4=4$$ and she did the same thing with $$s_1(1)$$ = $$32 \times 1 + 4 \times 1 + 4 = 40$$</p><p>We can see the equation is correct because $$s_1(0)+s_1(1)= C_1 =44$$ meaning the first check is approved.</p><p>This is not enough to satisfy the Verifier so we need to perform a second round. I guess the Prover should have also bought her some chocolate. Let’s keep going and see what’s his second move.</p><h2 id="h-round-two" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Round Two</h2><p>The prover takes the previous function and changes $$b_1$$ to $$r_1$$ and $$b_2$$ to $$X_2$$$$ \boxed {g(r_1,X_2,b_3,b_4,b_5)= 2r^2_1+X_2+r_1X_2b_3-b_4+X_2b^3_5} $$</p><p>Then he proceeds to calculate the sum of all evaluations of function $$g(r_1,X_2,b_3,b_4,b_5)$$ over all possible values that consists of $$0$$ and $$1$$ for only $$b_3,b_4,b_5$$ and add them up to form a polynomial. This means that the Prover should not change $$r_1$$ and $$X_2$$ which are the first two variables to $$0$$ or $$1$$.</p><p>In the end, we will have a the equation :$$ (4r_1+12)X_2+16r^2_1-4 $$My guy has no rizz so she decided to give him a hint by sending him a random value $$r_1$$ equal to 93. He takes the random value $$r_1$$ and puts it in the equation above.$$ s_2(X_2) = (4 \times 93 +12)X_2+16 \times 93^2-4 = 352X_2+ 115596 $$The Prover was able to calculate $$s_2(X_2)$$ which is $$352X_2+ 115596$$ and similarly to the previous round the Prover should send the coefficient of the polynomial which is $${ 352,115596 }$$ to the Verifier (Bold move by the Prover).</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/425856b0973c5d0034e27bc7fe2f8c34b92cf7c3964e2eebb7a9f9e95bb7a2ec.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>On the verification side, the Verifier will calculate $$s_2(0) + s_2(1)$$ by changing $$X_2$$ to $$0$$ which gives us $$352 \times 0 + 115596 = 115596 = s_2(0)$$ and changing $$X_2$$ to $$1$$ which gives us $$352 \times 1 + 115596 = 115948 = s_2(1)$$.$$ s_2(0)+s_2(1) = 115596 + 115948 = 277144 $$In addition from the previous rounds, the Verifier knows the function $$s_1(X_1)$$so then the verifier could calculate the value of $$s_1(r_1)$$ by changing $$X_1$$ with $$r_1$$.$$ 32X^2_1+4X_1+4 = 32 \times 93^2 + 4 \times 93 + 4 = 277144 $$So the sum of $$s_2(0)+s_2(1)$$ should be equal to $$s_1(r_1)$$. <code>The second test passed.</code></p><p>The verifier is convinced that the Prover did everything right till now.</p><p>Bro is winning but she’s playing hard to get.</p><p>Bro needs to be persistent and patient.</p><p>Let’s see his next move!!</p><h2 id="h-round-three" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Round Three</h2><p>Like last time, the Verifier chooses another random value $$r_2 = 35$$ and sends it to the Prover (What a lucky guy). The Prover generates an updated version of our original function by replacing $$b_1, b_2$$ and $$b_3$$ with $$r_1,r_2$$ and $$X_3$$.$$ \boxed {g(r_1,r_2,X_3,b_4,b_5) = 2r^2_1 + r_2 + r_1r_2X_3 - b_4 + r_2b^3_5} $$He then proceeds to compute the function $$H_3(X_3)$$ by calculating the summation for the variables $$b_4$$ and $$b_5$$ which are the only two remaining values that should be replaced by $$0$$ and $$1$$.</p><p>$$ H_3(X_3) = s_3(X_3,r_2) = 4r_1r_2X_3 + 8r^2_1 + 6r_2 - 2 $$By replacing the values $$r_1​ = 93$$ and $$r_2​ = 35$$, the Prover will get :$$ s_3(X_3) = 13020X_3 + 69400 $$</p><p>Then the Prover will share the coefficients $${ 13020,69400 }$$ of the polynomial $$s_3(X_3)$$ with the Verifier so she can calculate $$s_2(r_2)$$.</p><p>Since she knows the coefficients of $$s_2(X_2)$$, she can calculate $$s_2(r_2)$$ and get the same value as $$s_3(0)+s_3(1) = 151820$$.</p><p>You may be asking how can she calculate $$s_2(r_2)$$ with only the coefficients ?</p><p>The Verifier receives the coefficients in this format :$$ [0, 0, 0, 0, 384, 138380] $$For more clarity, you can imagine the function $$s_2(r_2)$$ like this$$ [0(x^5), 0(x^4), 0(x^3), 0(x^2), 384(x), 138380] $$So from the coefficients, the Verifier can construct $$s_2(r_2)$$:$$ s_2(r_2) = 384x^2 + 138380 $$and then replace $$r_2$$ with 35 :$$ s_2(35) = 384 \times 35^2 + 138380 = 151820 $$This can be done by replacing $$X_2$$ with $$r_2$$. So we just replace $$r_1$$ with 93 and $$r_2$$ with 35 :$$ (4r_1+12)X_2+16r^2_1-4 = (4 \times 93 + 12) \times 35 + 16 \times 93^2 - 4 = 151820 $$$$ s_2(r_2) = s_3(0)+s_3(1) = 151820 $$If the two sides of the equation is correct then the next round passes.</p><h2 id="h-round-four" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Round Four</h2><p>Round 4 is similar to round 2 and 3.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/78f8ee23cbcb09aa12a762668910b0ba606a1c1dca374143c740888091a0a5c0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-round-five-final-round" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Round Five (Final Round)</h2><p>I’d like to mention that we have 5 rounds of interaction between Prover and Verifier because we have 5 variables in the function $$g$$ → $$(b_1,b_2,b_3,b_4,b_5)$$.</p><blockquote><p>5 Rounds of Interactions: (1,2), (3,4), (5,6), (7,8), (9,10).</p></blockquote><p>So for the final round, the Verifier chooses a random value $$r_4$$. On the other side the Prover calculates the function g by replacing $$b_1$$ to $$b_5$$ by $$r_1,r_2,r_3,r_4,X_5$$$$ \boxed {g(r_1,r_2,r_3,r_4,X_5) = 2r^2_1 + r_2 + r_1r_2r_3 - r_4 + r_2X^3_5} $$$$H_5(X_5)$$ is similar to $$g(r_1,r_2,r_3,r_4,X_5)$$ because there’s no remaining variables to be replaced by $$0$$ and $$1$$ to calculate any summation.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/20b8efd062fc570163444097bed55b15f20b2869c369324608a6d3dc64b65d7b.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>The Prover will replace the variables $$r_1$$ to $$r_4$$ in $$s_5(X_5,r_4)$$ to get :$$ 35X^3_5 + 82407 $$and share the coefficients of the polynomial to the Verifier one last time .</p><p>The Verifier will calculate $$s_5(0) + s_5(1)$$ and check if its equal to $$s_4(r_4)$$ based on the coefficient received $$s_4$$ from the previous round and then the verifier.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/db1aebd2cca88f6bb6a5cc836fa512c7e4d42438221394c611e66eb16a4a799e.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>This can be done by replacing $$X_4$$ with $$r_4$$.$$ s_4(r_4) = -2r_4 + 164901 = -2 \times 26 + 164901 = 164849 $$So $$s_5(0) + s_5(1)$$ is equal to $$s_4(r_4)$$. <code>The test passes!!</code></p><h3 id="h-last-check" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Last Check</h3><p>The only thing left is to check if the final round passes. The verifier picks a random value $$r_5 = 14$$ and then she will need to calculate $$ g(r_1,r_2,r_3,r_4,r_5)$$.</p><p>Since the verifier knows the function $$g$$, she can replace the variables $$b_1$$ to $$b_5$$ by $$r_1$$ to $$r_5$$ and calculate $$s_5(r_5)$$ :$$ g(r_1,r_2,r_3,r_4,r_5) = s_5(r_5) = 2r^2_1 + r_2 + r_1r_2r_3 - r_4 + r_2r^3_5 $$$$ g(93,35,20,26,14) = 2 \times 93^2 + 35 + 93 \times 55 \times 20 - 26 + 35 \times 14^3 = 178447 $$We then check $$s_5(r_5)$$ :$$ s_5(r_5) = 35r^3_5 + 82407 = 35 \times 14^3 + 81407 = 178447 $$Thus :$$ g(r_1,r_2,r_3,r_4,r_5) = s_5(r_5) = 178447 $$$</p><p>This means that the verifier is convinced that the first received value of $$C_1$$ which is 44 is the correct summation. Finally the Prover and Verifier are dating!!!!!</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/e94c38069bb87897b60d7629c0505588cc9994e9cfc604e5a873fec65611e212.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>We can conclude that SumCheck Protocol needs $$l$$-rounds of interactions between Prover and Verifier to convince the Verifier that the summation was correctly computed. We can use Fiat-Shamir to make the SumCheck protocol non interactive.</p><p>Hope this was helpful and you finally understood the SumCheck Protocol. If you’re wondering there isn’t a season 2 for it so at least it was a happy ending.</p><p>Stay tuned for more !!</p><h2 id="h-references" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">References</h2><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.linkedin.com/in/ehsan-meamari-39717b4b/">Ehsan Meamari</a></p><div data-type="youtube" videoId="4018OYyoAf8">
      <div class="youtube-player" data-id="4018OYyoAf8" style="background-image: url('https://i.ytimg.com/vi/4018OYyoAf8/hqdefault.jpg'); background-size: cover; background-position: center">
        <a href="https://www.youtube.com/watch?v=4018OYyoAf8">
          <img src="{{DOMAIN}}/editor/youtube/play.png" class="play"/>
        </a>
      </div></div><p><a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="">The Sum-Check Protocol</a></p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/c4093a3cdf1b03a23ae051c29750c06239b46ae7ab07954626d739d94d8e35bb.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Lagrange Interpolation for MLEs Part II | ZKP]]></title>
            <link>https://paragraph.com/@farfromaverage/lagrange-interpolation-for-mles-part-ii-zkp</link>
            <guid>WkE4Mf2A8SnwlV9BG6IM</guid>
            <pubDate>Fri, 11 Oct 2024 17:12:43 GMT</pubDate>
            <description><![CDATA[OverviewIf you’re familiar with the Lagrange interpolation, you may know that it is used to construct the interpolation polynomial for a set of points in one dimension and if you’re not, no worries you can just watch these two videos (Video 1, Video 2) before proceeding. Our main focus today is using Lagrange interpolation in multilinear extensions. Don’t be overwhelmed by the upcoming formulas, you only need to understand what they do. We will provide you with a much simpler formula to use w...]]></description>
            <content:encoded><![CDATA[<h2 id="h-overview" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Overview</h2><p>If you’re familiar with the Lagrange interpolation, you may know that it is used to construct the interpolation polynomial for a set of points in one dimension and if you’re not, no worries you can just watch these two videos (<a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.youtube.com/watch?v=WCGKqJrf4N4">Video 1</a>, <a target="_blank" rel="noopener noreferrer nofollow ugc" class="dont-break-out" href="https://www.youtube.com/watch?v=nvkX1Bd90Gk">Video 2</a>) before proceeding. Our main focus today is using Lagrange interpolation in multilinear extensions. Don’t be overwhelmed by the upcoming formulas, you only need to understand what they do. We will provide you with a much simpler formula to use when dealing with MLEs at the end of the article, after understanding everything.</p><h2 id="h-formulation" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Formulation :</h2><p>The formulation of the multilinear extension can be thought of as a multi-dimensional extension of the Lagrange interpolation formula. The idea is to maintain the properties of the function at the vertices while allowing for interpolation within the entire hypercube.</p><p>Given as input all $$2^l$$ evaluations of a function $$f: { 0,1 }^l → \mathbb{F}$$, for any point $$r \in \mathbb{F}^l$$ there is an $$O(2^l)$$-time algorithm for evaluating $$\tilde{f}(r)$$.</p><p><strong>Multilinear Extension Formula:</strong></p><p>$$\tilde{f}(r) = \sum_{w \in { 0,1 }^l} f(w)⋅ \tilde{\delta}_w(r)$$</p><p>where $$\tilde{\delta}_w(r)$$ is the Multilinear Lagrange basis Polynomial corresponding to $$w$$ :</p><p>$$\tilde{\delta}<em>w(r) = \Pi</em>{i=1}^l(r_iw_i + (1-r_i)(1-w_i))$$</p><p>The formula $$\tilde{\delta}_w(r)$$ is part of a <strong>multilinear extension</strong> (MLE), which allows us to extend a function defined on binary inputs to work with real inputs between 0 and 1.</p><p>It works by multiplying together simple terms that either &quot;pick&quot; $$r_i​ $$or $$1− r_i​,$$ depending on whether the binary value $$w_i$$ is 1 or 0. This product ensures a smooth transition between the values at each binary point. Essentially, it blends between these binary points based on the real values of $$r$$, allowing us to interpolate the function over continuous inputs.</p><p>If you still don’t understand how it works, no worries you don’t need to. Just keep going and you’ll get a much simpler formula that you can use easily at the end.</p><h3 id="h-how-it-uses-lagrange-concepts" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">How It Uses Lagrange Concepts</h3><ul><li><p><strong>Basis Structure</strong>: $$\tilde{\delta}_w(r)$$​, can be seen as a generalization of Lagrange basis polynomials. They ensure that at each vertex $$r​$$, the extension matches the value of $$f(r_i)$$, similar to how Lagrange interpolation ensures the polynomial passes through each point.</p></li><li><p><strong>Generalization</strong>: The multilinear extension extends the concept of interpolation from one dimension to multiple dimensions. The basis polynomials in both cases are structured to ensure that the extended function preserves the behavior of the original function at specified points (the vertices).</p></li></ul><h2 id="h-what-is-the-boolean-hypercube" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">What is the Boolean Hypercube ?</h2><p>A Boolean hypercube is a geometric representation of all possible binary values $${0, 1}$$ in n-dimensional space. Each vertex of the hypercube corresponds to an n-length binary string, and there are $$2^𝑛$$ n vertices in total, representing all possible combinations of 0 and 1.</p><p>For example:</p><ul><li><p>In a 1-dimensional Boolean hypercube, you have 2 vertices: $$0$$ and $$1$$, which is just a line.</p></li><li><p>In a 2-dimensional Boolean hypercube, you have 4 vertices: $$(0,0),(0,1),(1,0),(1,1)$$, forming a square.</p></li><li><p>In a 3-dimensional Boolean hypercube, you have 8 vertices:$$(000),(001),(010),(011),(100),(101),(110),(111),$$ forming a cube.</p><pre data-type="codeBlock" text="             000---------001
            / |          / |
           /  |         /  |    3-Dimensional Boolean Hypercube:
          010--------011   |    {000,001,010,011,100,101,110,111}
          |   |        |   |
          |   100------|-101
          |  /         |  /
          | /          | /
          110--------111
"><code>             000<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>001
            <span class="hljs-operator">/</span> <span class="hljs-operator">|</span>          <span class="hljs-operator">/</span> <span class="hljs-operator">|</span>
           <span class="hljs-operator">/</span>  <span class="hljs-operator">|</span>         <span class="hljs-operator">/</span>  <span class="hljs-operator">|</span>    <span class="hljs-number">3</span><span class="hljs-operator">-</span>Dimensional Boolean Hypercube:
          010<span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span>011   <span class="hljs-operator">|</span>    {000,001,010,011,<span class="hljs-number">100</span>,<span class="hljs-number">101</span>,<span class="hljs-number">110</span>,<span class="hljs-number">111</span>}
          <span class="hljs-operator">|</span>   <span class="hljs-operator">|</span>        <span class="hljs-operator">|</span>   <span class="hljs-operator">|</span>
          <span class="hljs-operator">|</span>   <span class="hljs-number">100</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">|</span><span class="hljs-number">-101</span>
          <span class="hljs-operator">|</span>  <span class="hljs-operator">/</span>         <span class="hljs-operator">|</span>  <span class="hljs-operator">/</span>
          <span class="hljs-operator">|</span> <span class="hljs-operator">/</span>          <span class="hljs-operator">|</span> <span class="hljs-operator">/</span>
          <span class="hljs-number">110</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-number">-111</span>
</code></pre></li></ul><p>In ZKPs, you often need to work with functions that are defined over binary inputs. For instance, a function $$f$$ might be defined on inputs of length $$n$$ that are either 0 or 1, meaning $$f$$ is naturally defined on the vertices of a Boolean hypercube of dimension $$n$$. So a Boolean Hypercube is another way of describing our multivariate function.</p><h2 id="h-derivation-of-multilinear-extension" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Derivation of Multilinear Extension</h2><ul><li><p><strong>Building the Formula</strong></p><ul><li><p><strong>Choose the points for interpolation</strong>: For bilinear interpolation in two dimensions, you generally have four points:</p><ul><li><p>$$v_0 = (x_{v_0},y_{v0})$$</p></li><li><p>$$v_1 = ( 𝑥_{𝑣 <em>1} , 𝑦</em>{𝑣 _1})$$</p></li><li><p>$$v_2 = ( 𝑥_{𝑣 <em>2} , 𝑦</em>{𝑣 _2})$$</p></li><li><p>$$v_3 = ( 𝑥_{𝑣<em>3} , 𝑦</em>{𝑣 _3})$$</p></li></ul></li><li><p><strong>Lagrange Basis Functions:</strong></p><ul><li><p>To construct the MLE, we first need to define the <strong>Lagrange basis functions</strong>. These functions will ensure that the MLE passes through the vertex values of $$f$$.</p></li><li><p><strong>The Lagrange basis functions</strong> for the vertices $$𝑣_0, 𝑣_1,$$, $$v_2$$ and $$v_3$$ ​ are:</p></li></ul></li></ul></li></ul><p>$$L_0(\textcolor{skyblue}{x_1,x_2}) = \frac{(\textcolor{skyblue}{x_1}-x_{v_1})((\textcolor{skyblue}{x_1}-x_{v_2})}{(x_{v_0}-x_{v_1})(x_{v_0}-x_{v_2})} ⋅ \frac{(\textcolor{skyblue}{x_2} -y_{v_1})(\textcolor{skyblue}{x_2} -y_{v_2})}{(y_{v_0} -y_{v_1})((y_{v_0}-y_{v_2})}$$</p><p>$$L_1(\textcolor{skyblue}{x_1,x_2}) = \frac{(\textcolor{skyblue}{x_1}-x_{v_0})((\textcolor{skyblue}{x_1}-x_{v_2})}{(x_{v_1}-x_{v_0})(x_{v_1}-x_{v_2})} ⋅ \frac{(\textcolor{skyblue}{x_2} -y_{v_0})(\textcolor{skyblue}{x_2}-y_{v_2})}{(y_{v_1} -y_{v_0})((y_{v_1}-y_{v_2})}$$</p><p>$$L_2(\textcolor{skyblue}{x_1,x_2}) = \frac{(\textcolor{skyblue}{x_1}-x_{v_0})((\textcolor{skyblue}{x_1}-x_{v_1})}{(x_{v_2}-x_{v_0})(x_{v_2}-x_{v_1})} ⋅ \frac{(\textcolor{skyblue}{x_2} -y_{v_0})(\textcolor{skyblue}{x_2}-y_{v_1})}{(y_{v_2} -y_{v_0})((y_{v_2}-y_{v_1})}$$</p><p>$$L_3(\textcolor{skyblue}{x_1,x_2}) = \frac{(\textcolor{skyblue}{x_1}-x_{v_0})((\textcolor{skyblue}{x_1}-x_{v_1})}{(x_{v_3}-x_{v_0})(x_{v_3}-x_{v_1})} ⋅ \frac{(\textcolor{skyblue}{x_2} -y_{v_0})(\textcolor{skyblue}{x_2}-y_{v_1})}{(y_{v_3} -y_{v_0})((y_{v_3}-y_{v_1})}$$</p><p>Each $$L_i(x,y)$$ equals 1 at vertex $$v_i$$ and 0 at the other vertices meaning:</p><ul><li><p>$$L_0(x_1,x_2)$$ is 1 when $$𝑥<em>1 ​ = x</em>{v_0}$$ ​and $$𝑥<em>2 ​ = y</em>{v_0}$$, and 0 when either $$𝑥<em>1 ​ = x</em>{v_1}$$ or $$𝑥<em>2 ​ = y</em>{v_1}$$</p></li><li><p>$$L_1(x_1,x_2)$$ is 1 when $$𝑥<em>1 ​ = x</em>{v_1}$$ ​and $$𝑥<em>2 ​ = y</em>{v_0}$$, and 0 when either $$𝑥<em>1 ​ = x</em>{v_0}$$ or $$𝑥<em>2 ​ = y</em>{v_1}$$</p></li><li><p>$$L_2(x_1,x_2)$$ is 1 when $$𝑥<em>1 ​ = x</em>{v_0}$$ ​and $$𝑥<em>2 ​ = y</em>{v_1}$$, and 0 when either $$𝑥<em>1 ​ = x</em>{v_1}$$ or $$𝑥<em>2 ​ = y</em>{v_0}$$</p></li><li><p>$$L_3(x_1,x_2)$$ is 1 when $$𝑥<em>1 ​ = x</em>{v_1}$$ ​and $$𝑥<em>2 ​ = y</em>{v_1}$$, and 0 when either $$𝑥<em>1 ​ = x</em>{v_0}$$ or $$𝑥<em>2 ​ = y</em>{v_0}$$</p></li><li><p><strong>Formulating the Multilinear Extension:</strong></p><ul><li><p>Now, we can express the multilinear extension $$\tilde{f}(x,y)$$ using the function values at the vertices and the Lagrange basis functions:</p></li></ul></li></ul><p>$$\tilde{f}(x_1,x_2) = \textcolor{skyblue}{f(v_0)}L_0(x_1,x_2) + \textcolor{skyblue}{f(v_1)}L_1(x_1,x_2) + \textcolor{skyblue}{f(v_2)}L_2(x_1,x_2) + \textcolor{skyblue}{f(v_3)}L_3(x_1,x_2)$$</p><ul><li><p><strong>Final Formula (Simplified):</strong></p></li></ul><p>$$\tilde{f}(x_1,x_2) = \textcolor{skyblue}{f(v_0)}(1-x_1)(1-x_2) + \textcolor{skyblue}{f(v_1)}(1-x_1)x_2 + \textcolor{skyblue}{f(v_2)}x_1 (1-x_2) + \textcolor{skyblue}{f(v_3)}x_1x_2$$</p><p>You only need to understand this formula when dealing with MLEs without going through all of the math behind it.</p><p>$$\tilde{f}(r) = \sum_{w \in { 0,1 }^l} f(w)⋅ \tilde{\delta}_w(r)$$</p><p>So the Final Formula is basically this formula but written in a more elegant way.</p><h2 id="h-example" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Example</h2><p>We define a bivariate function over the domain $${ 0,1 }^l$$ :</p><p>$$f(0,0)= 1 \space \space \space \space f(0,1) = 2 \space \space \space \space f(1,0) = 8 \space \space \space \space f(1,1) = 10$$</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/74b3bd67baa417feb274030416223fc14edebe8b8c0b488a450c59d97cb2cbe0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>The MLE of the bivariate function will look like this:</p><p>$$\tilde{f}(x_1,x_2) =\textcolor{skyblue}{1}(1-x_1)(1-x_2) + \textcolor{skyblue}{2}(1-x_1)x_2 + \textcolor{skyblue}{8}x_1 (1-x_2) + \textcolor{skyblue}{10}x_1x_2$$</p><p>which we can simplify it to:</p><p>$$\tilde{f}(x_1,x_2) = 1+ 7x_1 + x_2 + x_1x_2$$</p><p>Notice that each of the four terms on the right hand side of the equation ensures that the MLE evaluates equally to our predefined values for the bivariate function:</p><p>$$f(0,0) = \tilde{f}(0,0) = \textcolor{skyblue}{1}⋅1 + 2⋅0 + 8⋅0 + 10⋅0 = \textcolor{skyblue}{1}$$</p><p>$$f(0,1) = \tilde{f}(0,1) = 1⋅0 + \textcolor{skyblue}{2}⋅1 + 8⋅0 + 10⋅0 = \textcolor{skyblue}{2}$$</p><p>$$f(1,0) = \tilde{f}(1,0) = 1⋅0 + 2⋅0 + \textcolor{skyblue}{8}⋅1 + 10⋅0 = \textcolor{skyblue}{8}$$</p><p>$$f(1,1) = \tilde{f}(1,1) = 1⋅0 + 2⋅0 + 8⋅0 + \textcolor{skyblue}{10}⋅1 = \textcolor{skyblue}{10}$$</p><p>So our MLE looks like this:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/b5468b94ea92e5ead5a5e4a4ed3a9ea3250269af7c8e60c2281721c05156c9ab.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>By replacing $$x_1$$ and $$x_2$$ in $$\tilde{f}(x_1,x_2)$$ by the indexes (4,5) we will get 54 which is the most bottom right cell.</p><p>$$\tilde{f}(x_1,x_2) = 1+ 7x_1 + x_2 + x_1x_2$$</p><p>$$\tilde{f}(5,5) = 1 + 7⋅4 + 5 + 4⋅5 = 1 + 28 + 5 + 20 = 54$$</p><h2 id="h-conclusion" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Conclusion</h2><p>$$Formula \space 1: \space \space \space \space \tilde{f}(r) = \sum_{w \in { 0,1 }^l} f(w)⋅ \tilde{\delta}_w(r)$$</p><p>$$Formula \space 2: \space \space \space \space \tilde{f}(x_1,x_2) = {f(v_0)}(1-x_1)(1-x_2) + {f(v_1)}(1-x_1)x_2 + {f(v_2)}x_1 (1-x_2) + {f(v_3)}x_1x_2$$</p><p>Both of these formulas represent multilinear extensions (MLE) of a Boolean function defined on binary points like $${0,1}$$ to a continuous domain.</p><p>The first formula is the general case for an $$l$$-dimensional Boolean function, where you&apos;re summing over all possible binary vectors $$𝑤 ∈ {0 , 1}^l$$ .</p><p>The second formula is the specific bivariate (2-dimensional) case, where $$l=2$$, and you&apos;re interpolating between the four possible binary inputs $$(0,0),(0,1),(1,0),(1,1)$$ as we saw in the previous example.</p><p>This is all you need to know about Multi-dimensional Lagrange Interpolation for Multilinear extensions. Hope this article was helpful. The next article will be a full guide on the sumcheck protocol. We’ll be applying everything we’ve learned so far.</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/f68c2b5f555c2cec83fb3eeb8718dbd4a7d0b61217f84764dc4b299c11c630af.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[Multilinear Extensions Part I | ZKP]]></title>
            <link>https://paragraph.com/@farfromaverage/multilinear-extensions-part-i-zkp</link>
            <guid>ySQWGwV9TyUkfALebtfU</guid>
            <pubDate>Mon, 07 Oct 2024 14:06:23 GMT</pubDate>
            <description><![CDATA[Let’s be real—there’s nothing worse than gridding through a long-ass article only to realize you’ve spent 20 minutes getting to the good part. So, here’s the deal: before we dive in, we’re giving you the why. Why are multilinear extensions a big deal in the world of ZKPs? Because trust me, they are. This article cuts through the noise and gives you everything you need to understand them—without endlessly searching the internet or looping through videos (like I did). I’ve got you covered. Read...]]></description>
            <content:encoded><![CDATA[<p>Let’s be real—there’s nothing worse than gridding through a long-ass article only to realize you’ve spent 20 minutes getting to the good part. So, here’s the deal: before we dive in, we’re giving you the why. Why are multilinear extensions a big deal in the world of ZKPs? Because trust me, they are.</p><p>This article cuts through the noise and gives you everything you need to understand them—without endlessly searching the internet or looping through videos (like I did).</p><p>I’ve got you covered. Ready? Let’s jump right in!</p><h2 id="h-overview" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Overview</h2><p>First of all, don’t be worried if you’re not familiar with <strong>Sumcheck Protocol and GKR Protocol,</strong> we’ll cover them in other article. You only need to understand that we have a Prover and a Verifier. The Prover generates a proof $$\pi$$ using public and private inputs and sends it to the verifier that will later accept or reject.</p><ol><li><p><strong>Multilinear Extensions (MLEs)</strong>:</p><p>A function $$f$$ (with multiple inputs) can be transformed into a multilinear polynomial. This allows us to represent the function in a more &quot;manageable&quot; form for certain cryptographic protocols. In ZKP systems, this is essential because polynomials have nice properties (like interpolation), which help in proving things efficiently. By turning a function into a polynomial, the prover can later prove things about it (like evaluations) without revealing the whole function.</p></li><li><p><strong>Sumcheck Protocol</strong>:</p><p>This is a way to prove that a sum over a large number of values (typically from a multilinear polynomial) is correct. Imagine you want to prove that the sum of evaluations of your multilinear polynomial at many points equals some value. Instead of having the verifier check every single evaluation (which is costly), the prover can use the sumcheck protocol to prove it with only a few rounds of interaction.</p></li><li><p><strong>GKR Protocol (Goldwasser-Kalai-Rothblum)</strong>:</p><p>The <strong>GKR protocol</strong> is designed to verify computations over layered arithmetic circuits. These circuits consist of multiple layers of gates, each computing simple arithmetic functions like addition or multiplication. The protocol is structured to efficiently verify computations on these circuits. It allows a verifier to check the correctness of a computation (like a circuit or a function evaluation) by checking only a few random positions in the multilinear extension of the function.</p><p>In your case, after the prover creates the multilinear extension and runs the <strong>sumcheck protocol</strong>, the <strong>GKR protocol</strong> can be used to verify that the entire computation (represented by the circuit) was done correctly using MLEs and sumcheck. The GKR protocol verifies whether the result of the computation is correct without requiring the verifier to redo the entire computation.</p></li></ol><h3 id="h-how-they-work-together" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">How They Work Together</h3><ul><li><p>The <strong>prover</strong> takes a function (or computation) and transforms it into a multilinear extension (using MLE).</p></li><li><p>The <strong>sumcheck protocol</strong> helps prove that the sum of evaluations of this multilinear polynomial is correct.</p></li><li><p>The <strong>GKR protocol</strong> adds an extra layer by allowing the verifier to check that this computation was done correctly with minimal effort.</p></li></ul><p>The process becomes non-interactive by applying Fiat-Shamir, allowing the prover to send the proof directly to the verifier, who can then easily check the proof without additional communication rounds.</p><h2 id="h-what-is-an-extension" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">What is an Extension ?</h2><p>Imagine you have a function that works only on a specific set of values. For example, let&apos;s say you have a simple function that works on integers:</p><ul><li><p>For $$x=1$$, it gives 5</p></li><li><p>For $$x=2$$, it gives 8</p></li><li><p>For $$x=3$$, it gives 10</p></li></ul><p>This function is only defined for $$x=1,2,3$$, but you might want to “extend” it so it works on other numbers like $$x=1.5, \space x=2.7$$, etc. That&apos;s called an extension—taking a function that works on a small set and extending it to work on more values.</p><h2 id="h-multilinear-extensions" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Multilinear Extensions</h2><p>Now, instead of just having one variable (like $$x$$), imagine you have <strong>multiple variables</strong> (like $$x$$ and $$y$$). A multilinear extension is when you take a function that only gives you results at specific combinations of values (like a list or table of results) and extend it to fill in all the gaps between those values. This means the function will work not just at those specific points but smoothly across all values in between.</p><h3 id="h-original-function-specific-points-only" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Original Function (Specific Points Only)</h3><p>Let&apos;s say we have a function that gives values only at specific points for $$x$$ and $$y$$. For example:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/c9fd644814c050b4173403594af6a949465b7a0f7906b1a0073641e864ccc1ad.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>In this table, the function is only defined for $$x=0$$ or $$1$$, and $$y=0$$ or $$1$$.</p><p>But this function <strong>does not tell us</strong> what happens when $$x = 0.5$$ or $$y = 0.5$$, or other values in between.</p><h3 id="h-multilinear-extension-filling-in-the-gaps" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Multilinear Extension (Filling in the Gaps)</h3><p>Now, the multilinear extension smoothly fills in the gaps between the known points. It creates new values for points like $$x=0.5, \space y=0.5$$, etc. The table might look something like this:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/1554ae5bab63390c23d078b96a706fd1dd541d0ece87f4f6690331db30924ad0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>Now, the function provides values not just for $$x=0$$ and 1, but also for points in between, like $$x=0.5$$, $$y=0.5$$. The values are calculated in a way that ensures smooth changes between the known points.</p><p>So, the multilinear extension allows the function to work <strong>not just at the original grid points</strong> (like $$x=0$$, $$y=0$$) but <strong>also at every point in between</strong>, like $$x=0.5$$, $$y=0.5$$, while ensuring the transitions are smooth and linear.</p><h2 id="h-why-use-it-in-zkps" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Why use it in ZKPs ?</h2><p>In protocols like GKR, you&apos;re often working with huge amounts of data, but you want to prove things efficiently. Instead of dealing with all the data points individually, you can summarize the behavior of a function over a small set of values and then extend it to cover the whole space. This makes the computation easier and faster while preserving the structure of the data.</p><h2 id="h-the-core-idea" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">The Core Idea</h2><p>The key idea is that multilinear extensions allow you to deal with complex, multi-variable functions in a more efficient way, by extending them from a small number of points to a larger range, while still keeping the math manageable.</p><h3 id="h-visualization" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Visualization</h3><p>Imagine you&apos;re looking at a huge high-resolution picture (like 4K). Instead of sending or analyzing every single pixel, you take a few key points that define the overall image (like the corners and a few central spots). Then, you use these points to <strong>reconstruct</strong> the image at a lower resolution. It saves time, but you still get a good idea of what the whole picture looks like.</p><p>This is similar to how multilinear extensions work in ZKPs: you only work with a few key data points, extend the function over the rest of the space, and still have enough information to prove things about the whole dataset.</p><h2 id="h-example" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Example</h2><p>If you have a dataset of 10 elements, you can pick 2 or 3 key elements, use those to create a <strong>multilinear extension</strong> of the function, and then evaluate that function on 4 or 5 elements to get a good representation of how the function behaves across the entire set. This way, you avoid the need to process all 10 elements directly.</p><h2 id="h-small-exercise" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Small Exercise</h2><p>Let&apos;s do a simple exercise for a multilinear extension using two variables $$x$$ and $$y$$. I’ll explain the step-by-step process and then walk you through the solution.</p><p>Given the following values for a function $$f(x,y)$$ at four points:</p><p>$$f(0,0)=1, \space \space \space f(0,1)=3,\space \space \space f(1,0)=5,\space \space \space f(1,1)=7$$</p><p><strong>Goal :</strong> Construct the <strong>multilinear extension</strong> of $$f(x,y)$$, and find the value of the function at $$(0.5,0.5)$$.</p><h3 id="h-steps" class="text-2xl font-header !mt-6 !mb-4 first:!mt-0 first:!mb-0">Steps</h3><ol><li><p><strong>Start with the four known Key Points</strong>. We know the values of the function at $$(0,0), (0,1), (1,0)$$ and $$(1,1)$$.</p></li><li><p><strong>Define the multilinear extension formula</strong>. For two variables, the multilinear extension is a bilinear interpolation between the known points.</p><blockquote><p>Bilinear Interpolation: is a fixed formula that applies universally when you have values at the four corners of a grid (in two dimensions) and by four corners I mean the four Key points $$(0,0), (0,1), (1,0) (1,1)$$. It always follows the same structure because it&apos;s derived from linear interpolation along two axes. (You can watch a video on Youtube that explains this formula in depth if want to know how its built).</p></blockquote><p>The general formula is :</p><p>$$f(x,y)= \textcolor{skyblue}{f(0,0)}⋅(1−x)(1−y)+\textcolor{skyblue}{f(1,0)}⋅x(1−y)+\textcolor{skyblue}{f(0,1)}⋅(1−x)y+\textcolor{skyblue}{f(1,1)}⋅xy $$$</p></li><li><p><strong>Substitute the known values of the function</strong> into the formula :</p><p>$$$ f(x,y)=\textcolor{skyblue}{1}⋅(1−x)(1−y)+\textcolor{skyblue}5⋅x(1−y)+\textcolor{skyblue}3⋅(1−x)y+\textcolor{skyblue}7⋅xy $$$</p></li><li><p><strong>Find the value at $$(0.5,0.5)$$</strong> by plugging $$x=0.5$$ and $$y=0.5$$ into the formula:</p><p>$$$ f(0.5,0.5)=\textcolor{skyblue}1⋅(1−0.5)(1−0.5)+\textcolor{skyblue}5⋅0.5(1−0.5)+\textcolor{skyblue}3⋅(1−0.5)⋅0.5+\textcolor{skyblue}7⋅(0.50⋅0.5) $$$</p></li><li><p>Now let’s calculate that step by step:</p><p>$$$ f(0.5,0.5)=\textcolor{skyblue}1⋅(0.5)(0.5)+\textcolor{skyblue}5⋅0.5(0.5)+\textcolor{skyblue}3⋅(0.5)(0.5)+\textcolor{skyblue}7⋅(0.5)(0.5) $$$</p><p>$$$ f(0.5,0.5)=\textcolor{skyblue}1⋅0.25+\textcolor{skyblue}5⋅0.25+\textcolor{skyblue}3⋅0.25+7⋅0.25 $$$</p><p>$$$ f(0.5,0.5)=0.25+1.25+0.75+1.75=4 $$$</p><p><strong>Answer :</strong> The value of the multilinear extension of the function at $$(0.5,0.5)$$ is <strong>4</strong>.</p><p>This process shows how you can extend a function defined at a few specific points (in this case, 4 points) to other values (like $$x=0.5, y=0.5$$) using multilinear interpolation.</p></li></ol><h2 id="h-notes" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Notes</h2><ul><li><p>A polynomial is considered multilinear if he has degree at most 1 in each variable for example: $$(1-x_1)(1-x_2)$$.</p></li><li><p>$$x^2_1x_2$$ is not a multilinear polynomial because it has a variable with degree 2.</p></li><li><p>Any function $$f$$ who’s domain is $${ 0,1 }^l$$ has many extension polynomials but only one of them will be exactly multilinear of degree at most 1 in each variable.</p></li></ul><h2 id="h-recap-with-some-visualize" class="text-3xl font-header !mt-8 !mb-4 first:!mt-0 first:!mb-0">Recap with some visualize</h2><p>Here we have a function $$f$$ defined on two bit inputs $${ 0,1 }^2$$.</p><p>$$f$$ has four inputs $$(0,0), (0,1), (1,0)$$ and $$(1,1)$$.</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/74b3bd67baa417feb274030416223fc14edebe8b8c0b488a450c59d97cb2cbe0.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>So for each of these four inputs, it spits out some field element:$$ f(0,0)=1, \space \space \space f(0,1)=2,\space \space \space f(1,0)=8,\space \space \space f(1,1)=10 $$and here is its multilinear extension:</p><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/bbb0d618d4f1078c5abf0d3c95b0cbbdff07106d2554824dccd5adbc8922db3a.png" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><blockquote><p>The multilinear extension polynomial is defined over all pairs of field elements. Often when we run these interactive proofs the field size is say $$2^{64}$$ or $$2^{128}$$.</p></blockquote><figure float="none" data-type="figure" class="img-center" style="max-width: null;"><img src="https://storage.googleapis.com/papyrus_images/baf1c0bd5b1d329e5753bc7ee995136f8c9eefc8afa4d44351abb8624588df29.jpg" alt="" blurdataurl="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=" nextheight="600" nextwidth="800" class="image-node embed"><figcaption HTMLAttributes="[object Object]" class="hide-figcaption"></figcaption></figure><p>If $$f$$ has these four inputs $$(0,0), (0,1), (1,0), (1,1)$$, we can express $$\tilde{f}$$ via Lagrange interpolation where sum each of the four inputs to $$f$$ and ensure that the polynomial your defining $$\tilde{f}$$ has exactly the current behavior on that input.</p><blockquote><p>Lagrange interpolation and bilinear interpolation are both methods used for estimating unknown values, but they serve different purposes and are applied in distinct contexts. So this function is the same as the previous one we saw in the small exercise.</p></blockquote><p>So for example if $$f(0,0) = 1$$, this function is the Lagrange basis polynomial that captures that.$$ \tilde{f}(x_1,x_2) = \textcolor{skyblue}1(1-x_1)(1-x_2) + \textcolor{skyblue}2(1-x_1)x_2 + \textcolor{skyblue}8x_1(1-x_2) +\textcolor{skyblue}{10}x_1x_2 $$$$ \tilde{f}(0,0) = \textcolor{skyblue}1(1-0)(1-0)+\textcolor{skyblue}2(1-0)⋅0+\textcolor{skyblue}8⋅0(1-0)+\textcolor{skyblue}{10}⋅0⋅0 $$$$ \tilde{f}(0,0) = 1 + 0 + 0 + 0 = 1. $$$</p><p>So a function $$f$$ that has $${ 0,1 }^l$$ or $$2^l$$ inputs will take $$O(2^l)$$-time (linear time) algorithm for evaluating $$\tilde{f}(r)$$, $$r$$ being random points $$(x_i,x_j)$$ in the finite field $$F^l$$.</p><p>That concludes everything you need to know about <strong>Multilinear Extensions</strong>. It wasn&apos;t so hard, was it ? In the next article we’ll be covering a full guide on the <strong>sumcheck Protocol</strong>. If you think this article was helpful feel free to subscribe and share it, byby.</p>]]></content:encoded>
            <author>farfromaverage@newsletter.paragraph.com (FarFromAverage)</author>
            <enclosure url="https://storage.googleapis.com/papyrus_images/8742c7da65fe0c90af7eacea8e7759f86e1dcab64116e6b68bf254a6ff83286b.png" length="0" type="image/png"/>
        </item>
    </channel>
</rss>