<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Garvit Goel on Medium]]></title>
        <description><![CDATA[Stories by Garvit Goel on Medium]]></description>
        <link>https://medium.com/@garvitgoel?source=rss-1b75b9e1f362------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LfokTWREuYDWd6R8BR2L4Q.jpeg</url>
            <title>Stories by Garvit Goel on Medium</title>
            <link>https://medium.com/@garvitgoel?source=rss-1b75b9e1f362------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 15:08:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@garvitgoel/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Top 10 BTC bridges to look out for (May 2025)]]></title>
            <link>https://garvitgoel.medium.com/top-10-btc-bridges-to-look-out-for-may-2025-4ec915149ce1?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ec915149ce1</guid>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Mon, 19 May 2025 10:44:48 GMT</pubDate>
            <atom:updated>2025-05-19T10:52:21.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CdeAc2zJtI0Iy0LsV3mKmA.png" /></figure><p>Over the last 12 months, we’ve seen an explosion in BTC bridging infra. What was once a 3-hour WBTC minting window with a 1% fee has evolved into near-instant cross-chain swaps and sub-10 bps spreads.</p><p>We broke down <strong>10 top BTC bridges</strong> by two of your favourite metrics: <strong>Speed &amp; Fees.</strong> Here’s how they stack up.</p><h3>1. <a href="https://app.optimex.xyz/">Optimex</a></h3><h4>Speed: ~10–15 minutes (1 BTC confirmation)<br>Fees: 1%</h4><blockquote><strong><em>Pros:</em><br></strong>No AMM slippage<br>Custody-less swaps</blockquote><blockquote><strong><em>Cons:</em><br></strong>RFQ model depends on active makers<br>Limited destination assets</blockquote><h3>2. Bitcoin Bridge (by PermuteFi)</h3><h4><strong>Speed</strong>: ~ 10–20 mins (1 BTC confirmation)<br><strong>Fees</strong>: ~0.1%</h4><blockquote><strong><em>Pros:</em><br></strong>BTC-native bridge<br>Lowest cost bridging <br>Very deep liquidity bridge</blockquote><blockquote><strong><em>Cons:<br></em></strong>Still in closed beta</blockquote><h3>3. <a href="https://www.garden.finance/">Garden Finance</a></h3><h4>Speed: ~5–10 mins<br>Fees: 0.3%</h4><blockquote><strong><em>Pros</em></strong><em>:</em><strong><br></strong>Fastest non-custodial bridge<br>No wrapping</blockquote><blockquote><strong><em>Cons:</em><br></strong>Still gaining awareness among retail users<br>Low liquidity (can’t swap more than 5 BTC)</blockquote><h3>4. <a href="https://relay.link/bridge">Relay</a></h3><h4><strong>Speed:</strong> 20 mins(1 BTC confirmation or less)<br><strong>Fees:</strong> ~ 0.2% + Network Cost</h4><blockquote><strong><em>Pros:</em><br></strong>Extremely fast routing<br>Broadest chain support</blockquote><blockquote><strong><em>Cons:</em><br></strong>Relies on wrapped assets (e.g., WBTC)</blockquote><h3>5. <a href="https://app.thorswap.finance/swap/ETH.WBTC-0x2260fac5e5542a773aa44fbcfedf7c193bc2c599_BTC.BTC?sellAmount=0">ThorSwap</a></h3><h4><strong>Speed:</strong> ~30–40 minutes<br><strong>Fees:</strong> ~0.9% total (AMM model)</h4><blockquote><strong><em>Pros:</em><br></strong>Native asset swaps (no wrapping)<br>Proven decentralization (THORChain security)</blockquote><blockquote><strong><em>Cons:</em><br></strong>Slower than newer bridges<br>Higher slippage for large swaps<br>Have been compromised in the past</blockquote><h3>6. <a href="https://app.debridge.finance/">deBridge</a></h3><h4><strong>Speed:</strong> Under 1 minute (for wrapped assets)<br><strong>Fees:</strong> ~0.05%–0.1% average; highly optimized</h4><blockquote><strong><em>Pros:</em><br></strong>Smart routing via makers<br>Extremely low latency across chains</blockquote><blockquote><strong><em>Cons:</em><br></strong>BTC mints not instant on-chain<br>Also relies on wrapped assets</blockquote><h3>7. <a href="https://app.across.to/bridge">Across</a></h3><h4><strong>Speed:</strong> 3 minutes<br><strong>Fees:</strong> 0.05%</h4><blockquote><strong><em>Pros:</em><br></strong>Fast bridging</blockquote><blockquote><strong><em>Cons:</em><br></strong>Very limited token pairs<br>Can’t bridge native BTC</blockquote><h3>8. <a href="https://core.app/bridge/">Avalanche BTC.b</a></h3><h4><strong>Speed:</strong> ~1–2 hours (multiple confirmations + SGX process)<br><strong>Fees:</strong> <strong>$3 to bridge in, $20 to bridge out (flat) + Bitcoin transaction fee (&lt;$2)</strong></h4><blockquote><strong><em>Pros:</em><br></strong>Deep liquidity on Avalanche<br>No % fees, good for whales</blockquote><blockquote><strong><em>Cons:</em><br></strong>Fixed fees harsh on small user<br>Doesn’t directly connect to Ethereum</blockquote><h3>9. <a href="https://threshold.network/">Threshold tBTC</a></h3><h4><strong>Speed:</strong> 10 min (optimistic mint); ~3–4 hours for full finality<br><strong>Fees:</strong> Mint fee is 0% &amp; Redemption fee is 0.2%</h4><blockquote><strong><em>Pros:</em><br></strong>Fully decentralized bridge<br>Native ERC-20 tBTC with strong integrations</blockquote><blockquote><strong><em>Cons:</em><br></strong>Slower redemptions (~6–12 hrs)<br>Slightly complex UX<br>Have been compromised in the past</blockquote><h3>10. <a href="https://swap.chainflip.io/">Chainflip</a></h3><h4><strong>Speed:</strong> ~10–30 minutes (BTC swaps)<br><strong>Fees:</strong> ~0.2% (plus 0.05% for Boost)</h4><blockquote><strong><em>Pros:</em><br></strong>Seamless cross-chain AMM<br>Deep liquidity and market-maker support</blockquote><blockquote><strong><em>Cons:</em><br></strong>Boost swaps cost extra<br>Protocol still ramping up integrations</blockquote><h3>TL;DR Table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NpcTz9CM-xBASi1rywL7jA.png" /></figure><p>More bridges, lower latency, better fees.</p><p><strong>Bitcoin is finally becoming multichain.</strong></p><h3>Resources</h3><ul><li><a href="https://docs.garden.finance/">Garden Docs</a></li><li><a href="https://docs.optimex.xyz/">Optimex docs</a></li><li><a href="https://relay.link/bridge">Relay Bridge</a></li><li><a href="https://github.com/thorchain">THORChain GitHub</a></li><li><a href="https://debridge.finance/">deBridge Protocol</a></li><li><a href="https://docs.across.to/introduction/what-is-across">Across docs</a></li><li><a href="https://core.app/bridge/">Avalanche BTC.b</a></li><li><a href="https://threshold.network/">Threshold tBTC</a></li><li><a href="https://docs.chainflip.io/concepts/welcome">Chainflip Docs</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ec915149ce1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Busting Myths: Aggregation Increases latency]]></title>
            <link>https://medium.com/electron-labs/busting-myths-aggregation-increases-latency-42ad811dd8a1?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/42ad811dd8a1</guid>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[zkp]]></category>
            <category><![CDATA[zkrollup]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Sun, 14 Jul 2024 04:34:35 GMT</pubDate>
            <atom:updated>2024-07-15T09:24:41.520Z</atom:updated>
            <content:encoded><![CDATA[<h3>In the next episode of MythBusters</h3><p>It is often incorrectly assumed by builders that aggregation layers are a trade-off between reducing your gas cost in return for increasing your latency. That’s not true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byGSIMeucRR4kA4iJT5rNw.png" /></figure><p>In fact, aggregation layers <strong>decrease both your latency and your gas cost.</strong> How? This is because the cost of verifying a proof is so high right now that projects can afford to send their proofs only after very long intervals ~ once every 3–4 hours. Using aggregation, we will reduce the cost of verifying proofs by so much, that you will be able to send your proofs to Ethereum in quick intervals.</p><p>Over time, as the cost per proof keeps getting lower, the projects will send proofs with higher and higher frequency.</p><p><strong>So in the long term, what is the lower limit of proof submission interval that customers can demand?</strong></p><p>Ans → 15s i.e. the Ethereum Blocktime. This is because you can add your proofs on Ethereum only as quickly as blocks are added to the chain.</p><p>This means that aggregation layers must generate their proofs in ~1s so that the projects’ proofs get added in the same block they would have been added in w/o aggregation latency. Note that projects must generate their own proofs as well within this 15s window, which means there would not be much time left for aggregation latency. This scenario will obviously play out over a long period of time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42ad811dd8a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/busting-myths-aggregation-increases-latency-42ad811dd8a1">Busting Myths: Aggregation Increases latency</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How my startup journey began]]></title>
            <link>https://garvitgoel.medium.com/how-my-startup-journey-began-478720542f59?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/478720542f59</guid>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 08:26:50 GMT</pubDate>
            <atom:updated>2024-07-10T08:26:50.762Z</atom:updated>
            <content:encoded><![CDATA[<h3>Startup Zero: The Biotech Idea</h3><p>I was in my final year at IIT Delhi, totally lost. There was this thesis I was supposed to write on the work I was doing in the biotech lab. However, it was impossible for me to find the motivation to do that work, and I had kind of given up on completing my degree as a result.</p><p>However, one day, my lab supervisor told me that the work I was doing was <em>commercially relevant</em>, and if I created the tech we were trying to develop, we could get paid millions per year in licensing fees from biotech companies.</p><p>And suddenly, the motivation I was missing was found. II went after this idea with everything I had.</p><p>Our idea was → Cutting down the analysis time for “Peptide Mass Fingerprinting”, by finding a way to use single-pass mass spectrometry to generate results with similar accuracy as tandom mass spectrometry.</p><p>After a couple of months, our work hit a dead-end, and the most we could do was publish a paper for it.</p><p>However the seed was sown. I now knew what I needed to do.</p><p>I told myself — “I just need to find a cutting-edge technology, make it commerically meaningful, and I can change the world.”</p><p>This was July 2017.</p><h3>The Darkest 14 days of my Life</h3><p>At this point i graduated, and I was supposed to join this analytics company in Mumbai. But I really wanted to startup right away. However, so far in my life, I had developed this habit of starting projects, abandoning them, and then regretting later. And I was <em>really scared</em> to repeat it. So I thought, “let’s me at least join the company and do something useful for them, before jumping into the startup blackhole.” Besides, the company was in Mumbai, where I wanted to go for starting-up anyways….</p><p>So I joined.</p><p>Up until this point in my life, I had thoughts in my head regarding technology, science and changing the world, but I could never find anyone to discuss them with. Joining this company was kind of my last hope of finding like minded people, and upon meeting people in the company, that was shattered too.</p><p>I was <em>really desperate</em> to discuss those thoughts with someone, and I could not find anyone. So I turned towards internet, trying to type out my thoughts on google and maybe something shows up? After 10 mins of search, I came across this random book by a guy I had never heard of → Peter Thiel, and I just thought I would give it a read. I found an online pdf version and start reading….</p><p>After reading the first paragraph, I was like — “Holy shit! This guy is talking about everything that’s in my head!” It took me 2 hours to process this, after which I began reading more…</p><p>Upon reaching the end of the page, I was barely able to breath, and i sort of froze up, and i could not hear anything anymore…</p><p>I still very vividly remember the exact place I was sitting on. It was in the middle of a training session by the company.</p><p>I managed to read till the first paragraph on the second page, after which it was very clear to me → “I either resign and startup right now, or I don’t think about starting up ever again.” I was worried that I might get insitituionzed if I spend too much time in that office….</p><p>After this, I snuck out of the office somehow, and started calling up everyone I knew → friends, dad and relatives. Everyone said the same thing — “Are you crazy?”.</p><p>In the evening I ended up meeting with a friend at Marine drive, a very famous road in Mumbai along the sealine. It was evening, high tide, and the sea was hitting the seawall quite aggresively, upon which we were sitting.</p><p>I told my friend → “I wanna startup”. He was like — “Yeah, obviously. I didn’t really understand why you joined a company in the first place. You are a startup kind of guy…”</p><p>I resigned the very next day.</p><p>After resigning, i was in the office for a couple of hours, and everyone told me the exact same thing — “congratulations”. I could not understand why they all said so, so I asked, and they told me — “everyone wants to startup, but you are actually doing it.” Lol, then I knew I had taken the right decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=478720542f59" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[zk-Ed25519: Underlying Mathematics]]></title>
            <link>https://medium.com/electron-labs/zk-ed25519-underlying-mathematics-8d4f64d9431b?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d4f64d9431b</guid>
            <category><![CDATA[crosschain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Tue, 15 Nov 2022 21:03:09 GMT</pubDate>
            <atom:updated>2022-12-01T18:40:07.300Z</atom:updated>
            <content:encoded><![CDATA[<p>Ed25519 has emerged as the signature scheme of choice in the blockchain ecosystems such as Cosmos, NEAR, Solana, and others. Verifying blockchain consensus requires verifying a large number of Ed25519 signatures (validators’ signatures). Hence, there is a need for succinct verification of a batch of Ed25519 signatures.</p><p>As such, we have developed a library that enables creating a zk-snark proof of a batch of Ed25519 signatures. The code can be found <a href="https://github.com/Electron-Labs/ed25519-circom">here</a>. Our circuits are built using Circom and we use Rapidsnark for proof generation.</p><p>Let&#39;s dive into how it works.</p><p>To implement the Ed25519 signature verification in a zk-circuits, we do the following 3 steps —</p><ol><li>Define the finite field used by Ed25519 inside the SNARK finite field</li><li>Defining basic operations such as addition, multiplication, and modulo for the Ed25519 finite field inside the zk-circuit</li><li>Defining the twisted Edwards curve inside the SNARK finite field</li></ol><h3>1. Defining Ed25519 Finite Field Inside SNARK Finite Field</h3><h4>The Problem Statement</h4><p>Verification of SNARKs can be particularly expensive in on-chain execution environments. For cheaper and efficient verification, Ethereum includes precompiles introduced in EIP 196 and EIP 197, which support curve operations and optimal ate pairing check for the elliptic curve alt_bn128. This means we should also use the alt_bn128 curve for generating our proofs if we want efficient proof verification on-chain.</p><p>The alt_bn128 curve is defined under a finite field modulo the prime p = 21888242871839275222246405745257275088548364400416034343698204186575808495617. (henceforth referred to as prime128). This means that operations inside a zk-circuit using this curve can only support numbers up to prime128.</p><p>Similarly, the generation and verification of Ed25519 signatures are operations on the twisted Edwards curve which is defined in a finite field under the prime p = 2²⁵⁵— 19 (hence referred to as prime 25519). Note that prime25519 &gt; prime128.</p><p>Now, in order to generate SNARK proofs of Ed25519 signatures that can be verified cheaply on Ethereum, we need to perform Ed25519 curve operations inside the alt_bn128 finite field.</p><p>To achieve this, since prime25519 &gt; prime128, we essentially need to represent a larger finite field inside a smaller one. This means we can not use the native/decimal representations for Ed25519 field elements since the numbers will overflow. Hence, we must define our field elements in an alternative number system.</p><p>We tried two different approaches—</p><h4>Approach 1: Binary (Base 2) representation</h4><p>The easiest approach is to represent all numbers in binary format, with each signal (field element) in Circom representing each bit. Since the only enumerable value for each signal/variable is 0 | 1, implementing addition, subtraction (using 2&#39;s complement), and multiplication is fairly straightforward. Any well-known algorithms can be used to do the same. However, using a binary representation is not efficient because we end up using only a fraction of the information each signal can capture, requiring a much larger number of signals to define the same computation. This, in turn, leads to a infeasibly large number of constraints.</p><h4>Approach 2: Using a larger base</h4><p>We can represent numbers in the same manner as a lot of BigInteger libraries do, by fitting smaller chunks inside the largest possible native element and using an array of such chunks to form larger numbers. We can fit at max d = largest_possible_field_element - 1 in a single signal. Instead of base 2 (binary), we can let each signal represent a &quot;digit&quot; up to this number d. In other words, a number system with base d+1. Now the information captured by each signal can be maximized, reducing the required computation for basic arithmetic operations compared to a binary representation.</p><blockquote>The base we used in our implementation is 2⁸⁵, which is much smaller than the maximum base that we can use. There’s a specific reason for this, related to our implementation of the modulus operation. This is discussed in later sections.</blockquote><h3>2. Finite Field with Base 2⁸⁵</h3><p>Now that we can represent the elements from the Ed25519 finite field inside the alt_bn128 finite field, let us see how we can perform operations on these numbers. Given that we are not using the native/decimal representations for field elements, we cannot used the native + and *operations provided by the CPU. We must define our own custom functions for operators such as addition, multiplication and modulus.</p><h4>Addition and Multiplication</h4><p>Find the implementation of base 2⁸⁵ adder <a href="https://github.com/Electron-Labs/circom-ed25519/blob/master/circuits/chunkedadd.circom#L52">here</a> and base 2⁸⁵ Multiplier <a href="https://github.com/Electron-Labs/circom-ed25519/blob/master/circuits/binmulfast.circom#L87">here</a>. The multiplication algorithm is basically standard long multiplication, where the carry is handled in the end.</p><h4>Modulus under prime25519</h4><p>We must perform the modulo operation in such a way that long division is avoided since it would be too expensive inside a zk-circuit. The algorithm we have used is as follows —</p><p>Let the prime p for the curve to be defined as p = 2²⁵⁵ - 19. Given input x, we need to calculate x % p</p><p>We define c = 2^255 and,<br>r = x % c(Note that r &lt; 2²⁵⁵. Also r is simply the least significant 255 bits of x )<br>q = x // c(q is simply x sans the least significant 255 bits of x )</p><blockquote>Note that 255 = 85*3 . This is the reason we have selected 2⁸⁵ as the base. Calculating r (and by extension q) becomes very efficient since we can simply take the first 3 elements of the array representing x to calculate r. Long division is not needed.</blockquote><p>Hence we derive equation (1)</p><pre>x = q*c + r<br>x = q*(p+19) + r   -- (1)</pre><p>Simplifying (1) and taking modulus p on both sides</p><pre>x % p = 19*q % p + r % p</pre><p>Now, calculate r % p as:</p><pre>if (r&gt;=p): r % p = r - p<br>if (r&lt;p): r % p = r</pre><p>However, there is no way to define conditional logic inside a circuit. Instead, we use a multiplexer which serves the same purpose when one out of multiple values needs to be selected. In this particular case, we provide both r and r-p as the input signals to the multiplexer, and assign the selector to be 0 | 1 based on whether r - p underflowed or not.</p><p>We can apply this algorithm recursively to calculate 19q % p. Recursion also means that x can be of arbitrary size.</p><p>Now that we have the basic operators in place for the Ed25519 finite field, we can use these as building blocks to define the twisted Edwards curve inside our zk-circuit.</p><h3>3. Defining the Twisted Edwards Curve in the alt_bn128 Finite Field</h3><p>We need to take two things into account —</p><ol><li>All the curve operations for Ed25519 must be implemented from scratch using our custom operators defined in the previous section.</li><li>We must represent all the Ed25519 operations as polynomials so that they can be represented in the R1CS constraint model.</li></ol><p>Let&#39;s start with point addition. Re-arranging the point addition equation for the twisted Edwards curve such that only + and * are used, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*2m1XSAIXBr2uL02pAC2jZA.png" /></figure><p>If three points (x1, y1), (x2, y2) and (x3,y3) satisfy these two polynomials, we can say that the third point is the sum of the first two points.</p><p>Please note that for the + and * operations in the equations above, we will use the custom adder, and multiplier (and modulo) defined in the previous section.</p><p>In our Circom implementation, rather than using cartesian coordinates, we use the radix format as defined in the reference implementation (given <a href="https://datatracker.ietf.org/doc/html/rfc8032#page-20">here</a>). This changes the polynomials a bit, but the core logic is the same. Please see the code <a href="https://github.com/Electron-Labs/ed25519-circom/blob/master/circuits/point-addition.circom">here</a>.</p><p>Scalar multiplication on the curve is essentially repeated point addition, hence it was easily implemented using the above circuit. Finally, we needed a Circom implementation for SHA512. We were able to modify the existing SHA256 implementation from the Circom library to achieve this.</p><p>Using the above as building blocks, we achieved a working implementation for Ed25519 signature verification, with the following performance parameters —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rmSklNhRL9k0lEb9bvfxPA.png" /><figcaption>All metrics were measured on a 16-core 3.0GHz, 32G RAM machine (AWS c5a.4xlarge instance).</figcaption></figure><h3>Next Steps</h3><p>Since the largest power of tau ceremony available is 256 mn constraints, we can fit a max of 99 signatures in a single SNARK. However, validator sets could contain 1000’s if not 100s of 1000s of validators, and hence there is a need to scale this.</p><p>We are currently working on STARK based implementations and exploring the use of recursive proofs to achieve logarithmic scaling of proof generation time. We are also working with hardware acceleration companies for reduce proof generation time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d4f64d9431b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/zk-ed25519-underlying-mathematics-8d4f64d9431b">zk-Ed25519: Underlying Mathematics</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Electron SDK: An Open Source Library for Building ZK Applications(Part 1)]]></title>
            <link>https://medium.com/electron-labs/presenting-electron-sdk-8c5774bd9d1b?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c5774bd9d1b</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zksnark]]></category>
            <category><![CDATA[electron-sdk]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Wed, 14 Sep 2022 08:27:19 GMT</pubDate>
            <atom:updated>2022-10-08T17:33:46.908Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This is the first article in a series of posts on Electron SDK.</em></p><p>Electron SDK is an open source library that ships with multiple cryptographic primitives that are required by virtually all zk powered applications. Currently, developers have to spend months figuring out circuit implementations of various encryption, hashing, and signature schemes. As a result, most builders shy away from building ZK-powered applications. The goal behind Electron SDK is to reduce the lead time for developers to learn ZK so that they can start building within 3 weeks rather than 6 months. We aim to abstract away the complexities of ZK systems and cryptographic constructs so that developers can focus on their use case.</p><p>Let’s look at the various cryptographic libraries provided as part of Electron SDK.</p><h4><strong>zk-Ed25519</strong></h4><p>zk-Ed25519 is a circuit implementation written in Circom to prove validity of a batch of Ed25519 signatures. Today, most ZK builders choose to use Snark-friendly signature schemes such as EdDSA on babyjubjub curve for their applications, in spite of the fact that this leads to compatibility issues with existing blockchains This is because it’s hard to create a zk-prover for Ed25519 since it uses a finite field which is bigger than the altbn128 finite itself, the one used by zk-snarks. We solved this problem by defining the prime 25519 finite field on base 2⁸⁵. This enables fast multiplication and modulo operations on the twisted Edwards curve while keeping all field elements within altbn128 finite field.</p><p>Potential use cases include compression of Light Client headers, making privacy dApps compatible with existing wallets, and powering scalability rollups on rust-based chains.</p><h4>E<strong>lectron-rs</strong></h4><p>Electron-rs enables on-chain proof verification in rust-based ecosystems like Solana, CosmWasm, and NEAR. Till now rust based provers like arkworks-rs were not directly compatible to run on-chain due to various reasons like their dependency on non-wasm/BPF compatible dependencies and heavy computations which generally exceed the gas limits for any chain. Electron-rs is a complete plug-and-play verifier that is available as a ready-to-deploy smart contract that allows you to :</p><ol><li>Store prepared verification keys in on-chain storage for quick access and updation.</li><li>Do fully optimized on-chain proof verification for as less as 150 TGas.</li></ol><p>Available on NEAR, Solana and CosmWasm</p><h4><strong>AES-circom</strong></h4><p>The Advanced Encryption Standard (AES) is a specification of data encryption. AES is a symmetric key algorithm.</p><p>We have implemented the AES-GCM-SIV encryption scheme in Circom in order to be able to generate zk-snark for encryption, which can then in turn be verified on-chain. Even though AES-GCM-SIV is not Snark friendly, we still chose this encryption scheme as the Snark-friendly schemes haven’t yet been fully verified.</p><h4><strong>sha512-circom</strong></h4><p>sha512-circom is a circuit implementation for SHA-512, or Secure Hash Algorithm 512, a hashing algorithm used to convert arbitrary byte stream to a fixed-size output. SHA-512 is used in popular signature schemes, for eg. Ed25519; and some merkle tree implementations.</p><p>So far, our work on Electron SDK has been focused on building cryptographic primitives. However, going forward, we are focussing on improving the proof generation infrastructure for applications.</p><h3>Future Roadmap for Electron SDK</h3><p>In the future, there are two places where proofs will be regularly generated — cloud machines and client-side such as browsers. We are working on accelerating proof generation in both these places.</p><h4><strong>Proof Generation in Browsers</strong></h4><p>Electron SDK is moving away from Snarks and towards Starks. Proof generation using Snarks required the use of a proving key which can be several gigabytes in size even for the simplest applications. For privacy use cases, this means users will be required to download very large files for every dApp they interact with and re-download it every time their existing dApps go through an upgrade. Starks are very interesting here since they do not have large proving keys, and require fewer resources for proof generation.</p><p>We have run tests using distaff VM, a Stark-based VM which is easily compilable to Wasm and hence easy to make compatible with browsers. We were able to achieve 300 ms proof generation time for a simple adder circuit. We will be conducting more tests going forward to set benchmarks. Eventually, the goal is to achieve sub 1 second proof generation time even for complex applications.</p><h4><strong>Proof Generation in Cloud and Recursion Proofs</strong></h4><p>Since the computational resources with a smart contract are limited, it would not be possible to submit a proof for every user interaction. This is where recursion comes in. Recursive proving allows combining several proofs into one, thus compressing a massive number of user interactions into a single proof.</p><p>Starks are preferable in this case also since stark-based proof recursion is much easier, making it possible to aggregate multiple stark proofs into a single stark.</p><p>We are working on using plonky2’s recursive engine to reduce the proof gen time for zk-Ed25519. Based on initial tests, we believe we are close to reducing proof generation time to ~ 90 seconds from the current 16 minutes. We aim to achieve sub-5-second proving times for large batches of ed25519 using GPU-based acceleration.</p><h4><strong>Putting it together</strong></h4><p>Based on the research so far, we believe the future of ZK infra will have 3 components -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0EZ2h0JS220ah7p0" /></figure><ol><li>Proof generation in the browser using prover-friendly schemes such as Starks.</li><li>Use of recursive proofs to aggregate client-side proofs.</li><li>Use of hardware acceleration for speeding up cloud-based proof generation.</li><li>Use of recursion to convert the final aggregated proof to a Snark or similar verifier-friendly scheme before submission to a blockchain.</li></ol><h3>Ending Note:</h3><p>We are already using Electron SDK to power the use cases we are building at Electron. Many members of the community have reached out to us to use our libraries, and we are happy very to provide support to projects that are building using our engine.</p><p>Continue reading part 2… (coming soon)</p><h3>Join Electron’s Community:</h3><p><a href="https://twitter.com/labs_electron"><strong>Twitter</strong></a><strong> | </strong><a href="https://t.me/joinchat/XUknutKGjyhiZTA9"><strong>Telegram</strong></a><strong> | </strong><a href="https://discord.gg/WWuCPw8QEB"><strong>Discord</strong></a><strong> | </strong><a href="https://electronlabs.org/"><strong>Website</strong></a><strong> | </strong><a href="https://github.com/Electron-Labs"><strong>GitHub</strong></a><strong> | </strong><a href="https://www.linkedin.com/company/electron-labs/"><strong>LinkedIn</strong></a><strong> | </strong><a href="https://www.youtube.com/channel/UCrv5QIrZ1kdlL8-X2LEi6Ow"><strong>Youtube</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c5774bd9d1b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/presenting-electron-sdk-8c5774bd9d1b">Electron SDK: An Open Source Library for Building ZK Applications(Part 1)</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is ZKLC and How it Works?]]></title>
            <link>https://medium.com/electron-labs/what-is-zklc-and-how-it-works-a5aaadf70fc0?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5aaadf70fc0</guid>
            <category><![CDATA[zkibc]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[tendermint]]></category>
            <category><![CDATA[zksnark]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Fri, 11 Feb 2022 09:47:18 GMT</pubDate>
            <atom:updated>2022-10-10T06:49:18.235Z</atom:updated>
            <content:encoded><![CDATA[<p>ZKLC stands for Zero-Knowledge Light Clients. ZK Light Clients allow us to prove the validity of a transaction, by constructing a zk-proof of its validity which can then be cheaply verified by everyone. Verifiers no longer have to run full consensus.</p><p>Let’s dive deeper into how we can construct zk-proofs of transaction validity.</p><p>Checking the validity of a transaction can be done via full block verification or light client verification. Both these techniques essentially involve verifying a large number of digital signatures. On rust-based chains, ED25519 is the most popular digital signature scheme.</p><p>Hence, we must now figure out an approach to construct a single zk-snark proof for a large batch of ED25519 signatures.</p><p>Our approach involves two steps:-</p><ol><li>Construct a snark proof of a single ED25519 signature.</li><li>Combine a batch of ED25519 snark proofs into a single snark proof.</li></ol><p>Let’s understand each step in detail.</p><h4><strong>Step1: Construct a Snark Proof of a Single ED25519 Signature</strong></h4><p>We first implement the ED25519 signature scheme in R1CS constraints format using circom. R1CS is basically a polynomial representation of the maths behind ED25519. However, this has a problem. All mathematical operations defined in circom and zk-snarks only work with numbers less than or equal to prime number p = 21888242871839275222246405745257275088548364400416034343698204186575808495617. This is because <em>altbn128 curve</em> uses this prime number.</p><p>But the mathematics of ED25519 requires number operations beyond this number. To solve this problem, we represent all numbers in base 2⁵¹. This means all numbers always stay below prime p. We select 2⁵¹ as the base since it allows us to exploit certain mathematical properties of the prime number used by ED25519 (q = 2²⁵⁵-19). Finally, we use snarkJS library to construct the zk-proof.</p><p>Check out our <a href="https://github.com/Electron-Labs/circom-ed25519">github repo</a> to see the implementation.</p><h4><strong>Step2: Recursively Combine many Snark Proofs into One Proof.</strong></h4><p>We must now combine multiple snarks proofs into one single proof. This single proof will prove all other proofs. How will we do that?</p><p>Say, we have two proofs <em>proof1</em> and <em>proof2</em>. We can construct a third proof <em>proof3</em> which proves that <em>proof1</em> and <em>proof2</em> are valid. The circom circuit would take <em>proof1</em> and <em>proof2</em> as input signals and then use a circom implementation of proof verification algorithm (on curve <em>altbn128</em>).</p><p>We can extend this to many proofs by creating a merkle tree sort of structure, where we successively combine proofs together to create a single proof.</p><p>This technique is adapted from recursive snark technology by Mina Protocol and <a href="https://github.com/mir-protocol/plonky2">plonky2</a> by Polygon Zero.</p><h4>Conclusion</h4><p>Zero-knowledge-based light clients have many applications. They allow us to prove transaction validity very cheaply anywhere, such as smart contracts on any blockchain or in cloud applications.</p><p>At Electron Labs, we are using them to build ultra-cheap cross-chain bridges. Many cross-chain transactions can be batched into a single snark proof. This makes cross-chain transaction costs very low, and nearly at par with normal blockchain transactions.</p><p>We are currently working on building ZKLC light clients for NEAR and tendermint blockchains. In the future, we plan to extend this technology to create proofs of an entire blockchain itself, which will have tremendous applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5aaadf70fc0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/what-is-zklc-and-how-it-works-a5aaadf70fc0">What is ZKLC and How it Works?</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our Reply to Vitalik’s Concerns on Cross-Chain Bridges.]]></title>
            <link>https://medium.com/electron-labs/our-views-onvitaliks-concerns-on-cross-chain-bridges-a68a2b60b64f?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/a68a2b60b64f</guid>
            <category><![CDATA[crosschain]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cross-chain-bridge]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Sun, 16 Jan 2022 17:13:40 GMT</pubDate>
            <atom:updated>2022-01-16T17:18:51.750Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/u/587a00dbce51">Vitalik Buterin</a> recently made a <a href="https://old.reddit.com/r/ethereum/comments/rwojtk/ama_we_are_the_efs_research_team_pt_7_07_january/hrngyk8/">Reddit post</a> about the limits of blockchain interoperability, and why cross-chain bridges won’t work. In this article, we attempt to assuage some of those concerns. Let’s dive deeper.</p><p>Vitalik essentially makes a simple argument that standalone blockchains can survive short-term 51% attacks, while bridges would go through catastrophic failure under these conditions. Actually, we will show that bridges can survive such attacks, in the same manner a standalone blockchain survives it.</p><p>Consider Vitalik’s first argument:-</p><blockquote>“suppose that you have 100 ETH on Ethereum, and Ethereum gets 51% attacked, so some transactions get censored and/or reverted. No matter what happens, you still have your 100 ETH.”</blockquote><p>This concept is often referred to as “finality”. It means that as a transaction (that gave you 100 ETH) gets deeper into the blockchain (as more blocks are added on top of it), the difficulty of reverting this transaction rises exponentially. This happens because, in order to revert a transaction, the 51% attacker would need to build a new chain starting from the block containing this transaction. If many blocks have been added on top of this transaction, the attacker would need to recreate all those blocks. This would be hard to do for old transactions. But for new transactions, only a few blocks would need to be spoofed, and hence a 51% attacker might be able to revert them. This is the reason Metamask users are advised to wait for several blocks of confirmations before considering their transaction complete.</p><p>So far, so good.</p><p>Now consider Vitalik’s second argument:-</p><blockquote>“if you move 100 ETH onto a bridge on Solana to get 100 Solana-WETH, and then Ethereum gets 51% attacked. The attacker deposited a bunch of their own ETH into Solana-WETH and then reverted that transaction on the Ethereum side as soon as the Solana side confirmed it. The Solana-WETH contract is now no longer fully backed, and perhaps your 100 Solana-WETH is now only worth 60 ETH.it.”</blockquote><p>In this case, Vitalik is assuming that the moment the user moves their assets into the bridge, the bridge will instantly make the cross-chain action on Solana. However, the bridge could easily wait for the transaction to be “finalized” on Ethereum (ie wait for the tx to become several blocks deep), before taking the cross-chain action. This is similar to how Metamask users wait for several blocks of confirmations. This way, the bridge can be sure that even if Ethereum is 51% attacked after it takes the cross-chain action, the transactions processed by the bridge will not be reversed, since they are already several blocks deep.</p><p>The rest of Vitalik’s arguments are built on top of this argument only, hence we will not discuss them separately.</p><h4>Going further with BFT consensus</h4><p>BFT consensus systems like tendermint and NEAR provide instant finality as a feature, and hence transactions do not have to wait for any block confirmations at all. Hence, for BFT chains, cross-chain transactions are indistinguishable from same-chain transactions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a68a2b60b64f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/our-views-onvitaliks-concerns-on-cross-chain-bridges-a68a2b60b64f">Our Reply to Vitalik’s Concerns on Cross-Chain Bridges.</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Security Analysis Of Validator Subset Approach]]></title>
            <link>https://medium.com/electron-labs/security-analysis-of-validator-subset-approach-cd6f70b25802?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd6f70b25802</guid>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Sat, 06 Nov 2021 18:03:10 GMT</pubDate>
            <atom:updated>2021-11-06T18:03:10.439Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="https://electronlabs.org/">Electron Protocol</a>, while verifying a blockheader using a Light Client, we postulate that instead of verifying 1000’s signatures from <em>all</em> validators, we can verify signatures from <em>a subset of all validators</em> containing just 19 validators, provided that the 19 validator subset is selected randomly.</p><p>Standard Setup — Verify <em>all</em> signatures. ⅔ should be valid.</p><p>Probabilistic Setup — Verify only 19 signatures. <em>All</em> should be valid.</p><p>Let us now show that both cases — standard setup and probabilistic setup, provide almost the same level of security. Let&#39;s dive in.</p><p>Consider that a blockchain has a total of N validators (we have tested our model for N between 100 and 1 Million). As assumed by most blockchains, we also assume that a max of N/3 validators could be malicious. As a worst-case scenario, we assume that all these N/3 malicious validators are colluding together to attack Electron Protocol.</p><p>In the standard setup, all validators’ signatures would be verified, and since we know that no more than N/3 are malicious, we know that at least two-thirds of total validators have signed correctly and that we can trust this block. This is the security provided by the blockchain itself.</p><p>Now, in the probabilistic setup, we are going to verify <em>all</em> signatures from x (x=19) randomly selected validators. As a source of randomness, we use the hash of some block (it could be previous block or current or some combination). We know that the crypto community at large believes that the hash of blocks is not a good source of randomness, since the hash can be manipulated, however, we shall show in a separate article that in our case (and in our case only), hash of block provides very good security. For the scope of this article, let us assume that hash of block is a good source of randomness.</p><p>So now, using the hash of block as randomness, we can calculate a random subset of x validators from the entire N validator set. Now, for Electron Protocol to be hacked, x must contain only malicious nodes. Even if one honest node is included in x, this honest node’s signature will not agree with the signatures from other x-1 validators, and the attack will be detected.</p><p>We can now state this as a maths problem:-</p><p>We must calculate the probability that when the x subset is calculated, the probability that <em>all</em> x are from the malicious N/3 validators show be very low. OR the probability that <em>at least one</em> honest validator (from ⅔ * N) is selected in the x subset should be very high.</p><p>We can restate this in simpler terms, removing all references to blockchain-specific things and reducing the above statement to the high school probability question. Here it goes:-</p><p>Consider a total of N balls. Out of this, N/3 balls are red, while the remaining ⅔ * N balls are blue. If you draw x balls at random, what is the probability that all x balls are red?</p><p>Solution:-</p><p>If all balls are drawn together:-</p><p>Probability that a given drawn ball is red = ⅓</p><p>Probability that all x drawn balls are red = ⅓ * ⅓ … x times = (⅓ )^x</p><p>For the network to be secure, the following condition must be met:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/1*JEEg6H1TsaTfuS5XbEr63g.png" /></figure><p>i.e. there is less than 1 in a billion chance that all validators selected in the subset are malicious.</p><p>If balls are drawn one by one:-</p><p>Probability that 1st ball is red = ⅓</p><p>Probability that 2nd ball is red = (N/3–1)/(N-1)</p><p>Probability that 3rd ball is red = (N/3–2)/(N-2)</p><p>…</p><p>Probability that xth ball is red = (N/3 — (x-1))/(N — (x-1))</p><p>Multiple all these terms together, we can write:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/157/1*T2Y3Pyj_PLr5an6w8bPxxA.png" /></figure><p>Now, for the network to be secure, the following condition must be met:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*iUXPq4mfE_Cfr_NlP3CN1g.png" /></figure><p>For large enough values of N, say 1000, this equation becomes the same as the case when all balls are drawn together.</p><p>The smallest integer value of x that satisfies the above two equations is 19.</p><p>Now someone might argue that 1 in a billion is not secure enough, they might ask for 1 in a trillion. We can easily do that. If you see these equations, the probability of hack diminishes exponentially with the value of x. So, by increasing x in small amounts, we can increase security by large amounts. So if I make x = 26, the probability of hack falls well below 1 in a trillion.</p><p>Ending Note:-</p><p>Electron Labs is building an interoperability protocol to make cross-chain products possible. Our goal is to enable the developer to think in blockchain agnostic terms. We are hiring!</p><p>Website :- <a href="https://electronlabs.org/">https://electronlabs.org/</a></p><p>Github :- <a href="https://github.com/Atom-Labs-one">https://github.com/Atom-Labs-one</a></p><p>Discord :- <a href="https://discord.gg/WWuCPw8QEB">https://discord.gg/WWuCPw8QEB</a></p><p>Telegram :- <a href="https://t.me/joinchat/XUknutKGjyhiZTA9">https://t.me/joinchat/XUknutKGjyhiZTA9</a></p><p>Twitter :- <a href="https://twitter.com/labs_electron">https://twitter.com/labs_electron</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd6f70b25802" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/security-analysis-of-validator-subset-approach-cd6f70b25802">Security Analysis Of Validator Subset Approach</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Homomorphic Encryption]]></title>
            <link>https://garvitgoel.medium.com/understanding-homomorphic-encryption-3869f228ecfa?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/3869f228ecfa</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[homomorphic-encryption]]></category>
            <category><![CDATA[zero-knowledge-proofs]]></category>
            <category><![CDATA[zksnark]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Thu, 21 Oct 2021 19:39:09 GMT</pubDate>
            <atom:updated>2021-10-21T19:39:09.114Z</atom:updated>
            <content:encoded><![CDATA[<p>ZK-SNARKS rely on a certain encryption function called Homomorphic encryption. I believe it’s important to understand the mathematical properties of this particular operator to truly understand ZK-SNARKS and hence I decided to prepare this document. Let us dive deeper.</p><p><strong>Definition:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*HzNEVwp7Ux3xDStI.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*VyzPPwqVIkDDlWWc.png" /></figure><p>Where <em>g^x</em> is exponentiation and <em>mod m</em> is the modulo operator.</p><p><strong>The Module Operator</strong><br>Let us understand the (mod m) operator deeper first. If <em>y = x mod m</em>, this means that <em>y</em> is the remainder when <em>x</em> is divided by <em>m</em>. Hence, one could write:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/0*CcUbu1EB891kCnTP.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*nCsGWvOPaexQVBge.png" /></figure><p>where <em>q</em> is the quotient when <em>x</em> is divided by <em>m</em></p><p>Let us look at some interesting properties of the mod <em>m</em> operator</p><p><strong>Property 1:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/0*eAHH-enLjTD4wt1u.png" /></figure><p><strong>Proof:-</strong><br>Both a and b can be written as:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/190/0*Rf1uedTYFmJgkh3B.png" /></figure><p>Substituting these values of a and b in right side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*_gOEY0Wr46sAkHzF.png" /></figure><p>Substituting the values of a and b in left side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/0*OVmLl5XeMMIufaXH.png" /></figure><p>As we can see, both the equations evaluate to the same value.</p><p><strong>Property 2:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/0*qNTs-HD-wEs3N-gM.png" /></figure><p><strong>Proof:-</strong><br>Substituting the previous values of a and b in left side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/0*afHNt9w4dEL6iTdF.png" /></figure><p>Substituting in right side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/0*7fN7AztGtO9Z14En.png" /></figure><p>As we can see, both the equations evaluate to the same value.</p><p><strong>The E(x) Operator</strong><br>Now that we are comfortable with the modulo operator, let us turn our attention back to the E(x) encryption function we defined earlier. E(x) is called an encryption operation since it’s not easy to find the value of x given the value of E(x). Hence, E(x) is a one-way function. The cool thing about E(x) is that it allows us to perform basic arithmetic operations on x, even when only E(x) is known, but x is not known.<br>Let’s dive deeper into these interesting properties of the E(x) operator:-</p><p><strong>Property 1:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/0*27FGBejzimP6WWKL.png" /></figure><p><strong>Proof:-</strong><br>Expanding the left side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/0*jSk4fjZ8pSvZ4EM-.png" /></figure><p>Using the property 2 of modulo multiplication defined previously, we can write:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/0*JUmb63yQSbCYyM0w.png" /></figure><p>Which is the same as the right side of the equation.</p><p><strong>Property 2:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*E2iSYyytFTmGBYWu.png" /></figure><p><strong>Proof:</strong><br>Expanding the left side of the equation, we get:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*IWifRTwfTDrxJJmt.png" /></figure><p>Using the property 2 of modulo multiplication defined previously, we can write:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/0*WND-4sqA-ILJ5ioh.png" /></figure><p>Which is the same as the right side of the equation</p><p>This was a basic intro to some of the maths used in ZK-SNARKS. In the next article, I will attempt to create a basic zero-knowledge scheme using the Homomorphic encryption defined here.</p><p><strong>References:<br></strong>Here is an awesome article series by Makesym on ZK technology — <a href="https://medium.com/@imolfar/why-and-how-zk-snark-works-2-proving-knowledge-of-a-polynomial-f817760e2805">Why and How zk-SNARK Works 2: Proving Knowledge of a Polynomial | by Maksym | Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3869f228ecfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is BDLC and how it Works?]]></title>
            <link>https://medium.com/electron-labs/what-is-bdlc-and-how-it-works-5716fbbacde8?source=rss-1b75b9e1f362------2</link>
            <guid isPermaLink="false">https://medium.com/p/5716fbbacde8</guid>
            <category><![CDATA[crosschain]]></category>
            <category><![CDATA[cross-chain-transfers]]></category>
            <category><![CDATA[crosschain-bridge]]></category>
            <category><![CDATA[cross-chain-bridge]]></category>
            <category><![CDATA[cross-chain-swap]]></category>
            <dc:creator><![CDATA[Garvit Goel]]></dc:creator>
            <pubDate>Wed, 08 Sep 2021 12:45:20 GMT</pubDate>
            <atom:updated>2022-10-08T17:34:49.412Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are Light Client Bridges and How do they Work?</h3><p>In this article, we will discuss a key piece of <a href="http://electronlabs.org/">Electron Protocol’s</a> Interoperability technology — Bidirectional Light Clients. BDLC enables a smart contract to verify transactions from a different blockchain, without additional trust assumptions.</p><p>Let’s dive in.</p><p>Consider that two cross-chain smart contracts are trying to communicate with each other.</p><p>Since smart contracts can only work with on-chain data, and the underlying blockchain does not support connecting with the “outside” world, an off-chain entity (called relayer) is required that will read data from one contract and make it available on the cross-chain contract.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*nv6dZWo3RS7VXIGz" /></figure><p>However, now we must devise a way so that we don’t need to trust the relayer to act honestly. One way to do this is to enable the smart contracts to verify the translation themselves.</p><p>We achieve this by running the Light Node of Chain A inside the smart contract on chain B, and vice versa. This way, whenever the relayers submit faulty/malicious transactions from chain A, the B smart contract can simply verify each transaction using the A light client it now has access to. Since Light Clients of both the chains are run inside the opposite chains’ smart contracts, this approach is called Bi-Directional Light Client (BDLC).</p><p>Lets us now understand the details of how this works, and how we fit a Light Node inside a smart contract.</p><p>Before that, let us understand what a light client is, and how it works?</p><blockquote>Light Client is a piece of code that can independently verify whether a particular transaction is a valid blockchain transaction or not. The exact logic of this code is open source and fixed for a given blockchain. Light Clients do not require access to the entire blockchain data, and require little compuational power. They were originally designed to be implemented within IoT devices.</blockquote><p>A Light Client works in two steps:-</p><ol><li>First, check whether the concerned transaction is part of a given block or not.</li><li>Then, check whether the given block is “valid” or not. Valid means that it is part of the canonical chain.</li></ol><p>Let us understand each step in more detail.</p><p><strong>Step 1: Check whether the concerned transaction is part of a given block or not?</strong></p><p>We do this by following the Merkle path. As shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/0*etJgkTBNFNzyUARe" /></figure><p>Blockchains store transactions by organizing them in a Merkle tree. A Merkle tree is formed by successively hashing transactions with each other in pairs, until one single hash is left, which is called the Merkle root. This Merkle root is included in the block header. In essence, the Merkle root encapsulates all the transactions of that block.</p><p>Now, if we want to check whether tx[6] was part of the given block, we simply need to hash tx[6] (along with the data on the Merkle path, as shown in the diagram) successively until we reach a single hash. If this hash matches the Merkle root, then we know that tx[6] was indeed included in this block.</p><p>Now, if we can show that this block is “valid”, we can be confident that this transaction is indeed part of the blockchain.</p><p><strong>Step 2: Check whether the given block is “valid” or not?</strong></p><p>In order to be called a valid block, the given block (or rather block header) must be signed by at least ⅔ validators, and, the block must point to the previous valid block.</p><p>Now, checking signatures from thousands of validators on a smart contract would be computationally very expensive (and infeasible within a smart contract). But, we don’t need to verify all signatures, just 19 actually. Let us discuss how.</p><p><strong>Verifying a S<em>ubset</em> of Validators instead of <em>All</em></strong></p><p>To check validity, typically one needs to check that the block has at least two-thirds of validator signatures. However, instead, if one takes a random subset of just 19 validators, and checks <em>all</em> the 19 signatures, then almost the same level of security is achieved.</p><p>This is shown through the probabilistic analysis below.</p><p>Consider <em>n</em> validators, out of which ⅓ validators are malicious (⅓ is the maximum dishonest nodes that PoS blockchains can tolerate). <em>n</em> can be any number between 10 and 1 million.</p><p>Now we must select ‘<em>x</em>’ random validators from total ’<em>n</em>’, such that the probability that all ‘<em>x</em>’ validators are malicious is less than 1 in a billion. This can be described in the below formula (derivation of this formula can be found <a href="https://garvitgoel.medium.com/security-analysis-of-validator-subset-approach-cd6f70b25802">here</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*g3BBRd0sPv2y8euA" /></figure><p>Solving this equation, we get the result that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/0*vtg621nOKgYzgA8A" /></figure><p>Verifying 19 signatures inside a smart contract is computationally feasible. (More about this will be added here as link)</p><p>Now, we must check if our block points to the previous canonical block or not. At first, it might seem that we would need to download all previous block headers. However, light clients avoid this by using a trick called block checkpoints. For now, we will not discuss this in detail, instead please see how Tendermint does this <a href="https://blog.cosmos.network/light-clients-in-tendermint-consensus-1237cfbda104">here</a> and see Vitalik’s thoughts on this <a href="https://blog.ethereum.org/2015/01/10/light-clients-proof-stake/">here</a> (which is also the basis for Ethereum PoS light client). If you want this discussed in detail, please leave a comment.</p><p>At <a href="http://electronlabs.org/">Electron Labs</a>, we have used BDLC technology to build an interoperability protocol that exists completely as L2 smart contracts and only relies on the security of the underlying chains themselves. This is as opposed to existing protocols in the ecosystem that use either multi-sig, oracle, or some other centralized approach.</p><p><strong>Ending Note</strong></p><p>BDLC is the same technology that is powering Cosmos IBC, and NEAR’s rainbow bridge. It seems that Solana wormhole aims to implement this tech in the future as well.</p><p>Since posting this article, we have upgraded our technology to zero knowledge proofs based light clients. Check out <a href="https://medium.com/electron-labs/what-is-zklc-and-how-it-works-a5aaadf70fc0">https://medium.com/electron-labs/what-is-zklc-and-how-it-works-a5aaadf70fc0</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5716fbbacde8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/electron-labs/what-is-bdlc-and-how-it-works-5716fbbacde8">What is BDLC and how it Works?</a> was originally published in <a href="https://medium.com/electron-labs">Electron Labs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>