<?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 Nicolás Vescovo on Medium]]></title>
        <description><![CDATA[Stories by Nicolás Vescovo on Medium]]></description>
        <link>https://medium.com/@nicolas.vescovo?source=rss-848f289098c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jUWxcTJ1agqNaS1gceLO_w.jpeg</url>
            <title>Stories by Nicolás Vescovo on Medium</title>
            <link>https://medium.com/@nicolas.vescovo?source=rss-848f289098c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:57:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicolas.vescovo/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[Choosing the right curve]]></title>
            <link>https://medium.com/rootstock-tech-blog/choosing-the-right-curve-bf183d477a?source=rss-848f289098c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf183d477a</guid>
            <category><![CDATA[rsksmart]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[sidechains]]></category>
            <category><![CDATA[elliptic-curve]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Nicolás Vescovo]]></dc:creator>
            <pubDate>Thu, 05 Aug 2021 14:15:53 GMT</pubDate>
            <atom:updated>2021-08-05T14:15:53.190Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h9ZO1EznbFgdGvxKJL7c8A.jpeg" /></figure><p>I was tasked to research how second layer aggregation and privacy protocols work, especially Aztec and zkSync. My research project included an analysis on how these two protocols use elliptic curves and determine if it is possible to use the same elliptic curve for privacy and second layer aggregation. While I was working on it I decided to take the opportunity to explain how elliptic curves are chosen, what is important and what isn’t.</p><p>This article is meant to be a guide and understand what is important when we have to choose an elliptic curve to use for our smart contracts that require zero-knowledge cryptography. The first condition is that it has to support an efficient pairing, and of course we have to state what an efficient pairing is.</p><p>Although the research objective is to analyze elliptic curves for privacy and second layer aggregation protocols in general, the research focuses on porting Aztec and zkSync to RSK, and eventually combining them. This requires an understanding of what are the implications of using the same elliptic curve and the evaluation of which one is the best option.</p><p>Before we start, we should clarify that these protocols do not just use elliptic curves in the classical cryptographic way (e.g. discrete logarithm problem or Diffie-Hellman). These protocols use zero knowledge proofs based on pairing and therefore having an efficient pairing in the elliptic curve is a must. A pairing is a math operation over an elliptic curve and efficient means that the EVM is able to compute it with a low amount of gas.</p><h3>Embedding degree</h3><p>We’ll explain what the embedding degree is and why it is important when we are choosing a curve.</p><p>The embedding degree is a map that sends an EC system into a classical discrete log system. We are not actually embedding the whole EC group but rather just the biggest cyclic subgroup ⟨𝑃⟩ generated by the point 𝑃 which is the base of the logarithm problem (i.e. [𝑑] 𝑃 = 𝑄).</p><p>We assume that the order |⟨𝑃⟩|=𝑙 is prime (this will be true for pretty much all standard ECC applications). And our goal will be to embed ⟨𝑃⟩ into the group of roots of 1 (or what is the same, numbers that produce 1 when raised to some positive integer power) over some appropriate 𝔽𝑝𝑘. For this to be possible there must be enough roots of 1 in the appropriate field and this happens when 𝑙 | (𝑝𝑘 −1).</p><p>Since we are trying to be efficient we will want the lowest such 𝑘 which we call the embedding degree. Note this should be the embedding degree of 𝑃 but since there normally is only one reasonable subgroup of an EC for ECC purposes it seems to be often called the embedding degree of the curve.</p><p>To find the embedding degree we first note that 𝑙 | (𝑝𝑘 −1) is the same as saying that 𝑝𝑘 ≡ 1 mod 𝑙. Wanting the minimal such 𝑘 is then equivalent to asking for the multiplicative order of 𝑝 in 𝔽𝑙. Note that since both 𝑝 and 𝑙 are prime 𝑝 must be a unit in 𝔽𝑙. Moreover we get p (𝑙 −1) ≡1 mod 𝑙 by Fermat’s little theorem. This gives us an upper bound on 𝑘. Further we can see that the order of 𝑝 must divide 𝑙−1 and so factoring 𝑙−1 gives us all candidates for 𝑘.</p><p>Since there is a map from our elliptic curve group to a subgroup of roots of 1 or a classic Diffie Hellman group. Our elliptic curve system will be as secure as our Diffie Hellman group will be. When you try to implement the MOV attack (or try to guard from it) what you need to do is transfer the discrete logarithm problem from an EC over 𝔽𝑝 to a finite field 𝔽𝑝𝑘. Higher embedding degree implies bigger field 𝔽𝑝𝑘 and thus it is harder to solve DLP. So it’s important that 𝑘 should be large, but is larger always better? If we only focus on Diffie Hellman’s problem the answer is yes, but as we said above our main tool will be the pairing and so we want an efficient pairing. And with a lower embedding degree will get faster pairing. So we need to balance between security and performance. A good balance is found with embedding degree 𝑘=12. This produced reasonable security levels and also had very efficient implementation properties. 𝑘=24 is another good choice but 𝑘=12 is more common.</p><h3>BN curves</h3><p>We need a curve over a finite field appropriate for doing cryptographic operations and with an efficient pairing. But how to pick one? There are infinite curves so it is like looking for a needle in a haystack. But thanks to mathematicians and cryptographers the task is easier, they have built and selected families of curves with these characteristics. One of these families are <a href="https://link.springer.com/content/pdf/10.1007%2F11693383_22.pdf">BN curves</a>. BN refers to the surnames of the mathematicians who found them back in 2006, Paulo Barreto and Michael Naehrig.</p><p>These are pairing-friendly curves over 𝔽𝑝 which means that computations in the field 𝔽𝑝𝑘 are feasible and have an embedding degree of k=12.</p><h3>BLS curves</h3><p>This is another family of curves and a procedure to construct them. They were proposed by Paulo Barreto, Ben Lynn and Michael Scott in September 2002 in <a href="https://eprint.iacr.org/2002/088.pdf">‘Constructing Elliptic Curves with Prescribed Embedding Degrees’</a></p><p>In that article the authors present a method to build curves containing a subgroup with embedding degree k that is big enough to prevent the Frey-Rück attack, but small enough that the Tate pairing is efficiently computable, which in turn means that arithmetic in 𝔽𝑝𝑘 is feasible. In their paper they investigated generalizations of prior researchers and addressed construction of curves with the properties desired where k &gt; 6 but still small enough for efficient pairing.</p><h3>Aztec and its curves</h3><p>Aztec is an open source layer 2 network bringing scalability and privacy to Ethereum. Aztec uses zkSNARK proofs to provide privacy and scaling via a zkRollup service. AZTEC protocol enables confidential transactions in a generic form that can be implemented on blockchains that support general-purpose computation. An AZTEC note is an encrypted representation of abstract value.</p><p>Aztec uses <a href="https://github.com/AztecProtocol/AZTEC/tree/develop/packages/bn128">bn254</a> curve for almost all the computation.The curve belongs to the BN family and is colloquially called bn128 in reference to the nominal security of the curve, or bn254 in reference to the bit-length of the relevant prime field. Only the note’s spending key is defined over the secp256k1 curve, because it is the same curve Ethereum uses and Ethereum is optimized to verify ECDSA over this curve. The gas cost to verify an ECDSA signature on the secp256k1 curve is 3,000 gas, while the gas cost of performing a scalar multiplication on the bn128 curve is 40,000 gas )</p><h3>ZkSync and its curve</h3><p>ZKSync is a layer two scaling solution providing privacy in a trustless setup for Ethereum. It is based on ZK Rollups. This means that all funds are held by a smart contract on the main-chain, while computation and storage are performed off-chain. For every Rollup block, a SNARK is generated and verified by the main-chain contract. This SNARK includes the proof of the validity of every single transaction in the Rollup block.</p><p>ZkSync uses the bn256 curve, the 256 references to the length of the prime field and bn are the capital letters of Baretto and Naehrig.</p><p>Before 2016 <a href="https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm">Pollard’s rho algorithm</a> was the most efficient algorithm to break the cryptographic of the curve. That justifies why BN256 was claimed to have 128 bit of security. But in 2016, Kim and Barbulescu proposed a new variant of the NFS algorithms, the extended number field sieve (exTNFS). After this new variant was discovered, the security of both curves has decreased to <a href="https://tools.ietf.org/id/draft-yonezawa-pairing-friendly-curves-01.html#rfc.section.5">100 bits.</a> (there are some references that state they only offer 80 bits of security). I believe that the level of security is at the limit of what is acceptable. For that reason I decided to explore some other options.</p><h3>BLS 12–381</h3><p><a href="https://hackmd.io/@benjaminion/bls12-381#:~:text=BLS12%2D381%20is%20a%20pairing%2Dfriendly%20elliptic%20curve.&amp;text=Pairing%2Dfriendly%20elliptic%20curves%20are,chance%20of%20being%20pairing%2Dfriendly.">BLS12–381</a> is part of the family of elliptic curves described by <a href="https://eprint.iacr.org/2002/088.pdf">Barreto, Lynn, and Scott</a>. As in the other two curves its embedding degree is 12. The basic equation of the BLS12–381 curve is y2=x3+4.</p><p>x has “low Hamming weight”, meaning that it has very few bits set to 1. This is particularly important for the efficiency of the algorithm that calculates pairings. The security target of this curve is 128 bits.</p><p>Although it’s a relatively new curve (2017), both Ethereum and RSK precompiles to perform efficient operations over this curve have been implemented. These operations allow efficient BLS signature verification and SNARKs verifications. However, neither RSK nor Ethereum have activated native support for this curve. In <a href="https://eprint.iacr.org/2019/403.pdf">this paper</a> the authors analyze and implement performance improvements of hash functions over BLS 12–381. They show that this curve admits fast, simple, and constant-time implementations.</p><h3>Comments</h3><p>Aztec and zkSync do not require any curve with other particularities than those already mentioned (cryptographically secure, efficient pairing). The curves are tools. Both of the BN curves are implemented in many applications and both support the same operations. BLS12–381 is more recent but has become something of a celebrity in recent years.</p><p>The level of security of both of the BN curves is the same and both belong to the same family. Both are suited for implementing Aztec and zkSync. Choosing one or another depends on performance of the pairing and the type of operations that are needed. But from a cryptographic point of view, both are equally good.</p><p>BLS12–381 has 128 bits of security, so it is more robust in that aspect. The down side of this curve is that Ethereum and RSK still don’t support it.</p><h3>Conclusion</h3><p>Both BN curves are great, however the level of security is at the limit of what is acceptable. For that reason, and considering that there is no need to maintain backward compatibility, I suggest using the curve BLS12–381. With this selection, we are one step ahead of the security threshold, and its pairing performance is excellent.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf183d477a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rootstock-tech-blog/choosing-the-right-curve-bf183d477a">Choosing the right curve</a> was originally published in <a href="https://medium.com/rootstock-tech-blog">RootstockLabs: Research &amp; Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>