<?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 Mehry Rezaei on Medium]]></title>
        <description><![CDATA[Stories by Mehry Rezaei on Medium]]></description>
        <link>https://medium.com/@mehialiabadi?source=rss-c70462ec90f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*E2G7tILpp6GLfZ8YJj2KpQ.jpeg</url>
            <title>Stories by Mehry Rezaei on Medium</title>
            <link>https://medium.com/@mehialiabadi?source=rss-c70462ec90f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:54:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mehialiabadi/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[In the realm of blockchain, what exactly does privacy entail?]]></title>
            <link>https://medium.com/@mehialiabadi/what-does-privacy-mean-in-the-blockchain-1-5e529a5b41c7?source=rss-c70462ec90f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e529a5b41c7</guid>
            <category><![CDATA[homomorphic-encryption]]></category>
            <category><![CDATA[private-tranasctions]]></category>
            <category><![CDATA[private-smart-contract]]></category>
            <category><![CDATA[multi-party-computation]]></category>
            <category><![CDATA[zkproof]]></category>
            <dc:creator><![CDATA[Mehry Rezaei]]></dc:creator>
            <pubDate>Sun, 01 Oct 2023 02:38:00 GMT</pubDate>
            <atom:updated>2023-10-17T04:07:38.434Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>In the realm of blockchain, what exactly does privacy entail?</strong></p><p><strong>Cryptographic Primitive</strong></p><p>Homomorphic Encryption</p><p><strong>Private Transactions</strong></p><p><strong>From private transactions to private smart contracts</strong></p><p>Approaches to Smart Contract I/O Privacy</p><p>On-chain HE-based approach</p><p>Off-chain Zkp-based approach</p><p>Off-chain Solutions without ZKPs</p><p><strong>Function privacy</strong></p><h3>In the realm of blockchain, what exactly does privacy entail?</h3><p>In a general sense, privacy is defined as methods to mask user data; however, within the context of blockchain, privacy is not binary, but rather falls across an entirely public to completely private spectrum and it can take on many levels.</p><p>The first and basic level of privacy within the blockchain is anonymity, achieved by assigning users random-looking addresses (user&#39;s public key) that conceal their identity. This enables users to transfer cryptocurrencies, tokens, or data without revealing personal identity information. Despite the inherent privacy of public keys in all blockchain networks, there are still methods, such as heuristics, that can potentially connect these seemingly random addresses to their actual owners.</p><p>Furthermore, at this level, all the contents are stored transparently on the blockchain, permitting anyone to access and read all transaction and payment details.</p><p>The absence of privacy carries various consequences, including but not limited to the following:</p><ul><li>Allowing anyone to read not only users’ payment activities but also more sensitive data such as votes or health-related information.</li><li>Making users exposed to front-running attacks, where malicious actors (miners) benefit from prior access to transactions on incoming trade.</li><li>Disclosing the history of cryptocurrency can lead to tainted currency.</li></ul><p>Due to the lack of transaction privacy in networks like Bitcoin, Ethereum, and others, several new cryptocurrencies have surfaced to facilitate private transactions. The second level, known as “private transactions,” makes use of cryptographic techniques like Zero-Knowledge Proofs (Zkp) and commitment schemes to conceal both the transferred amounts and the addresses of the users involved in the transaction. Notable examples within this category include Zcash and Monero.</p><p>With the development of smart contracts, the focus was devoted to the next level of privacy with a desire to build private smart contracts. The expected privacy at this level includes the ability to perform the computation of a smart contract while its inputs and outputs are hidden. We refer to this level as I/O privacy.</p><p>The last and the most ambitious level of privacy, so-called function privacy (execution privacy) extends the achievements further, interest in protecting the privacy of the function has arisen so that even the computation itself is hidden.</p><p>An overview of achieving privacy in blockchain is presented in Figure 1. Further details will be provided below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8hrSPaF1jjFbWGqH" /></figure><p>Figure 1</p><h3>Cryptographic Primitive</h3><p>When addressing privacy concerns in blockchain, cryptography is an indispensable tool. Let’s give a brief introduction to Homomorphic Encryption (HE), a technique primarily employed in privacy-preserving solutions.</p><h4>Homomorphic Encryption</h4><p>Homomorphic encryption allows for performing computations on encrypted data without needing to decrypt it. The resulting computations remain in an encrypted form that, when decrypted, produces an output similar to that produced when operations are performed on unencrypted data.</p><p>Let c1 = enc(m1) be a ciphertext of m1,</p><p>and c2 = enc(m2) be a ciphertext of m2,</p><p>then the addition and multiplication on c1 and c2 can be performed as follows:</p><p>c1 = enc(m1)</p><p>c2 = enc(m2)</p><p>c1 + c2 = enc(m1) + enc(m2) = enc(m1+m2)</p><p>c1 * c2 = enc(m1) * enc(m2) = enc( m1 * m2)</p><p>The above equations demonstrate that with having enc(m1) and enc(m2), it is possible to compute the encryption of a more complex polynomial function involving m1 and m2.</p><p>For instance, enc(5 * m1 + m2) can be computed as enc(5) * enc(m1) + enc(m2).</p><p>Suppose user A, with a balance of ‘ba’ in her wallet, wishes to send a certain amount of currency ‘x’ to user B, who has a balance of ‘Bb’ in his wallet. Both users, A and B, can proceed as follows to maintain privacy and achieve the transfer without revealing the transfer amount or their respective balances:</p><p>Both users A and B encrypt their balances under their respective public keys and make them publicly available.</p><p>These values are denoted as ‘Ba = enc(balance A, pka)’ and ‘Bb = enc(balance B, pkb).’</p><p>Following this, user A encrypts the transfer amount ‘x’ using both her public key and B’s public key separately.</p><p>These are referred to as ‘Cxa = Enc(x, pka)’ and ‘Cxb = enc(x, pkb)’ respectively.</p><p>As shown in Figure 2, miners utilize homomorphic addition to perform the computation and update the encrypted balances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/0*EF-P8ZOI6jTPf9Cx" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/0*hCW11WBQunvNZsfK" /></figure><p>In this example, users should provide Zkps, showing that they haven’t cheated in the transaction; however, for the sake of simplicity, these ZKPs have been omitted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OZWfqx70zuZdvcLo" /></figure><p>Figure 2</p><h3>Private Transactions</h3><p>Private transactions in which the amount of transfer, and the addresses of both sender and receiver remain hidden from anyone are no longer considered a big deal in the blockchain area. Monero, Zcash, and Quisquis address it in their own ways. Under these schemes, a user hides a transaction value inside a commitment and provides ZKps indicating that the transaction signer owns the hidden coins she wants to spend and that she cannot spend more than the input value. Eventually, the issuer and recipient’s addresses are masked using anonymity sets.</p><h3>From private transactions to private smart contracts</h3><p>Unlike transaction privacy, bringing privacy to smart contracts deals with several challenges.</p><p>First of which is that a smart contract can be any arbitrary program including complex operations and a set of non-predefined conditions.</p><p>While in private transactions we face determined conditions such as the sender has enough money and the transfer amount should be positive, in private smart contracts, conditions depend on the contract applications.</p><p>The next challenge would be performing private computations on inputs belonging to different users. While smart contracts may operate on inputs from different users, in transactions, all operations are limited to values belonging to the same user.</p><p>Finally, the combination of the complex smart contract with cryptographic tools uplifts several questions related to the accuracy and legitimacy of the code deployed.</p><h3>Approaches to Smart Contract I/O Privacy</h3><h3>On-chain HE-based approach</h3><p>As illustrated in Figure 3, a user provides encrypted inputs along with a ZKP showing that certain application-specific conditions have been satisfied for their inputs. Then, miners verify the proof and use homomorphic addition and multiplication to operate on the encrypted inputs (ciphertexts). Since performing multiplication operations has a high computational cost, miners are eager to perform various functions including only homomorphic addition. Given that the majority of the computation on the encrypted data is done by miners, this approach can be viewed as the on-chain mechanism. Zether has taken this method to provide I/O privacy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d57m7ANmzR3UN_Ri" /></figure><p><strong>Figure 3</strong></p><h3>Off-chain Zkp-based approach</h3><p>As depicted in Figure 4, in this paradigm the user is asked to perform almost all the computations offline on her plaintext input to get plaintext output. Then she encrypts and publishes the encrypted input and the encrypted output for the computation. Since the computation was done offline she has to provide a ZKPp indicating that the computation was performed correctly. All miners do in this approach is check that the ZKP is valid and then update the blockchain state accordingly. Kachina, Zexe, and Zkay are schemes that utilized this approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yuu2hg1j_6Wjp_cp" /></figure><p>Figure 4</p><h3>Off-chain Solutions without ZKPs</h3><p>While ZKps are a rapidly evolving field and more efficient constructions that are transparent will likely be created, other private smart contracts such as Ekiden, and Arbitrum require some sort of trusted manager or trusted hardware</p><p>Ekiden benefits from a delegation-based approach where users delegate the computation to a third party with a trusted execution environment (TEE). Here, the collective party (aka compute nodes) performs the computations and affirms the correctness of the update using digital signatures. With the secret key used to generate the signature only known to the trusted hardware (Intel SGX), there are some security concerns about this approach.</p><p>In Arbitrum, smart contracts are implemented as self-standing virtual machines (VMs) and managed by some set of managers. These managers are responsible for keeping track of VMs’ progress and ensuring that they behave correctly. Managers behave optimistically; they accept state changes without repeating the chain computation unless there is a disagreement. Same as Ekiden, Arbitrum has minimized the work of miners by only requesting them to verify the signatures of managers upon receipt of general ledger status updates.</p><h3>Function privacy</h3><p>The final level of privacy which is acknowledged as the most ambitious and strongest one aims to hide the computation itself along with hiding inputs/outputs. This allows for protecting proprietary code or preventing information leaks that may result from knowing the computation. Function privacy can also be useful to hide the exchange of user-defined assets since leaking the function may reveal the token type. Zexe is the only scheme that provides function privacy by the off-chain ZKp-based method.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e529a5b41c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Plonk vs Groth16]]></title>
            <link>https://medium.com/@mehialiabadi/plonk-vs-groth16-50254c157196?source=rss-c70462ec90f------2</link>
            <guid isPermaLink="false">https://medium.com/p/50254c157196</guid>
            <dc:creator><![CDATA[Mehry Rezaei]]></dc:creator>
            <pubDate>Mon, 26 Jun 2023 11:57:24 GMT</pubDate>
            <atom:updated>2023-10-16T20:10:46.022Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we’ll give a quick rundown of two ZK-SNARK protocols, Groth16 and Plonk. We’ll pinpoint their key fetures and then put them side by side for a usability, performance, and security comparison.</p><p><strong>Background on ZK-SNARK <br></strong>Zero Knowledge Proof (ZKP) protocol consists of two parties, prover (P) who wants to convince another party, and verifier (V), that a statement <em>x</em> is true, using a secret witness w<em>,</em> without revealing w<em> </em>to the verifier or anyone else.<br>As an example, suppose I wish to assure someone that my bank account contains ample funds, but I’m unwilling to disclose the exact balance. In this scenario, the “my account balance exceeds 10 million dollars” serves as the public statement, while my actual balance functions as the private witness or secret input.</p><p>The following basic requirements are required for every ZKP protocol:</p><p><strong>Completeness</strong>: honest P always will convince the honest V.<br> <strong>Soundness</strong>: dishonest P will not convince honest V<br> <strong>Zero-knowledge</strong>: dishonest V learns nothing more than the truth of the statement.</p><p>For integration into the blockchain, the ZKP protocol must satisfy the demands of having a short proof size and maintaining a reasonable time complexity for both the prover and verifier. Furthermore, given the scalability and performance challenges in blockchain technology, minimizing the interaction between the prover and verifier, especially avoiding multiple rounds, is highly preferable. Ideally, we are interested in a protocol where the prover generates a proof and transmits it to the verifier in a single round. Addressing the mentioned issues, resulted in a novel category of ZKP protocol, namely Knowledge Succinct Non-Interactive Argument of Knowledge (ZK-SNARK). <br>Eliminating multiple rounds of communication not only improves the protocol’s performance but also removes the requirement for both parties to be simultaneously available. To achieve this reduction in rounds, two approaches are commonly used: the Random Oracle Model and the Common Reference String (CRS). We will focus on the Common Reference String (CRS) approach, which has been employed by both the Groth16 and Plonk protocols. In theory, a trusted and honest third party is responsible for generating a random value “r” and using it to create CRS parameters, including the proving key “pk” and the verification key “vk.” It’s important to note that anyone with access to the randomness “r” can potentially generate fraudulent proof. To enhance the security of the ZK-SNARK protocol, it often leverages <a href="https://en.wikipedia.org/wiki/Secure_multi-party_computation">Multi-Party Computation</a>, where all parties collaboratively compute a function without the need for a trusted third authority.</p><p>According to<a href="https://eprint.iacr.org/2017/1050"> this paper</a>, as long as there is at least one honest party the final parameters are secure.<br><strong>Note</strong>: All secure parameters generated by the MPC ceremony should be removed by a secure process.</p><p>Let’s define the properties of SNARK as we did for the ZK protocol:</p><p><strong>Succinct</strong>: the size of the proof is very small compared to the size of the statement or the witness.<br> <strong>Non-Interactive</strong>: no need for several interactions between P and V<br><strong> The argument of Knowledge</strong>: dishonest P cannot convince honest V unless he knows some secret ‘witness’<br> <strong>Zero-knowledge</strong>: disclose no more than public.</p><p>To wrap up, ZK-SNARK consists of three phases: Conducting trusted setup by MPC protocol to generate proving and verification keys, generating proof by prover using prover key, public input, and secret input (witness), and verifying the proof by verifier.</p><blockquote><strong>CRS</strong>( randomness <em>r</em> , statement <em>x</em>) → (<em>pk</em>,<em>vk</em>)<br><strong>Prover</strong> (<em>pk,</em> statement <em>x</em>, <em>witness w</em>)→ proof <em>pi</em><br><strong>Verifier</strong>( <em>vk</em>, <em>pi</em>, statement <em>x</em>) → accept or reject proof <em>pi</em></blockquote><h3><strong>Groth16</strong></h3><p>In 2016, Groth introduced a ZK-SNARK protocol, constructed based on a set of polynomial equations and asymmetric pairing cryptography. <br>Pairing-based SNARKs follow a simple paradigm where the prover computes a number of group elements using generic group operations<br>and the verifier checks the proof using a number of pairing product equations.<br>In the Groth16 scheme, any program <em>F</em>(<em>x,w</em>) = <em>y</em> with public input <em>x</em> and private witness <em>w</em> is converted into an arithmetic circuit <strong><em>C</em></strong>.<br>To prove the correctness of circuit C, we must verify the correctness of each gate. To do this, groth16 uses Quadratic Arithmetic Languages (QAP) to encode the circuit. The intuition behind encoding circuit <strong><em>C</em></strong> into QAP is that we define polynomial <em>P(z)=Ui(z).Vi(z)-Wi(z)</em> that encodes all multiplication gate equations where polynomials <em>Ui</em>, <em>Vi,</em> and <em>Wi</em> represent the left, right, and output of gate <em>ith</em> over (<em>a1,…, am</em>) which represent the circuit wire values.</p><p>Now we define a target polynomial <em>T(z)=(z-r1)(z-r2)…(z-rn)</em> where <em>r1, …, rn </em>are random variables, and <em>n</em> denotes the number of multiplication gates in our circuit. The basic idea is that the polynomial <em>P(z)</em> has been defined such that is divisible by<em> T(z)</em>. It means there is a polynomial <em>H(z)</em> that <em>P(z)=H(z)T(z)</em>. Therefore if there is a trusted party who evaluates these polynomials (<em>U(z), V(z), W(z)</em>) at a random point such <em>s</em>, putting them into CRS, then the prover can make a proof and the verifier is able to verify it.</p><h3><strong>Plonk</strong></h3><p>PlonK protocol addresses the one-time and non-unpalatable trusted setup issues by introducing universal and updatable SRS. In other words, several programs can share CRS, so long as their circuit size does not exceed the CRS threshold limit.</p><p>Likewise Groth16, in Plonk every program is converted into an arithmetic circuit of multiplicative and additive gates. However, the way that Plonk proves the correctness and consistency of the circuit is different. To prove the correctness of Plonk’s circuit, we need to prove the validity of each gate constraint, as well as the gate relationship. In addition to the verification of the polynomial equation, a mathematical method of permutation argument is adopted to verify the constraint relationship between the gates, that is, the copy constraint.</p><p><strong>Efficiency Comparison <br></strong><br>PlonK provides two variants, one with 9(<em>n</em>+<em>a</em>) combined degree of polynomials, and one with 11(<em>n</em>+<em>a</em>). The former has a larger proof size but reduced prover computation by about 10% compared to the latter one. Here, <em>n</em> stands for multiplication gates, and ‘<em>a’</em> stands for addition gates in the circuit.<br>The performance and security comparison of Groth16 and two variants of Plonk are shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwUBmV_IKlgJdFM1y8M8sg.jpeg" /></figure><p><strong>Proof complexity Analysis<br></strong>In common circuits, the ratio between additive gates and multiplicative gates is 2:1. Under this circuit assumption, this means PlonK is 2.25 times worse than Groth16 on proof time. With the capability for proof generation to be executed offline and off-chain, there is no necessity to be concerned about the time complexity of proof generation. However, proof size should be taken into consideration, affecting transaction size and consequently blockchain network throughput. Recall that each group element is a pair of x and y points in <strong><em>F</em></strong><em>.</em></p><p>Groth16 proof size: 2<strong><em>G1</em></strong>.(2 <strong><em>F</em></strong>) + 1 <strong><em>G2</em></strong> ( counts 4<strong><em>F </em></strong>elements) = 6<strong><em>F</em></strong><br> Plonk proof size: 9<strong><em>G1</em></strong>+ 7<strong><em>F </em></strong>= 16<strong><em>F</em></strong></p><p>Assuming that each element takes <em>256</em> bits. According to <a href="https://vitalik.ca/general/2019/09/22/plonk.html">Vitalik&#39;s post</a>, Groth16 proof size would be around 200 bytes at an estimated level of 128 bits of security, whereas PLonk requires around 500–1000 bytes for the same security level.</p><p><strong>Verification Complexity Analysis</strong></p><p>Groth16’s verification algorithm is linear in its public input size, while Plonk requires a fixed number of exponential and pairing computations.</p><p>Note: needs benchmark implementation to estimate the gas cost</p><p><strong>Conclusion</strong></p><p>Theoretically, both Groth16 and Plonk rely on the assumption of mathematical problems and aren’t quantum-resistant. Nevertheless, Plonk requires weaker security assumptions rather than Groth16. <br>Regarding proof size, Plonk has a proof size of around 2x-5x that of Groth16, however, Plonk has a major advantage of universal and undatable SRS over Groth16. Consequently, the probability that the setup was compromised by collision is reduced, and no need to re-run the MPC ceremony for any changes in the program.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50254c157196" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>