
<rss version="2.0" 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" xmlns:media="http://search.yahoo.com/mrss/">
    <channel>
        <title><![CDATA[ The Cloudflare Blog ]]></title>
        <description><![CDATA[ Get the latest news on how products at Cloudflare are built, technologies used, and join the teams helping to build a better Internet. ]]></description>
        <link>https://blog.cloudflare.com</link>
        <atom:link href="https://blog.cloudflare.com/" rel="self" type="application/rss+xml"/>
        <language>en-us</language>
        <image>
            <url>https://blog.cloudflare.com/favicon.png</url>
            <title>The Cloudflare Blog</title>
            <link>https://blog.cloudflare.com</link>
        </image>
        <lastBuildDate>Tue, 07 Apr 2026 09:30:39 GMT</lastBuildDate>
        <item>
            <title><![CDATA[The TLS Post-Quantum Experiment]]></title>
            <link>https://blog.cloudflare.com/the-tls-post-quantum-experiment/</link>
            <pubDate>Wed, 30 Oct 2019 13:00:00 GMT</pubDate>
            <description><![CDATA[ In a June 2019 experiment with Google, we implemented two post-quantum key exchanges, integrated them into our TLS stack and deployed the implementation on edge servers and in Chrome Canary clients. ]]></description>
            <content:encoded><![CDATA[ <p></p><p>In June, we <a href="/towards-post-quantum-cryptography-in-tls/">announced</a> a wide-scale post-quantum experiment with Google. We implemented two post-quantum (i.e., not yet known to be broken by quantum computers) key exchanges, integrated them into our TLS stack and deployed the implementation on our edge servers and in Chrome Canary clients. The goal of the experiment was to evaluate the performance and feasibility of deployment in TLS of two post-quantum key agreement ciphers.</p><p>In our <a href="/towards-post-quantum-cryptography-in-tls/">previous blog post</a> on <a href="https://www.cloudflare.com/learning/ssl/quantum/what-is-post-quantum-cryptography/">post-quantum cryptography</a>, we described differences between those two ciphers in detail. In case you didn’t have a chance to read it, we include a quick recap here. One characteristic of post-quantum key exchange algorithms is that the public keys are much larger than those used by "classical" algorithms. This will have an impact on the duration of the TLS handshake. For our experiment, we chose two algorithms: <a href="/towards-post-quantum-cryptography-in-tls/#cecpq2b-isogeny-based-post-quantum-tls">isogeny</a>-based SIKE and <a href="https://en.wikipedia.org/wiki/Lattice-based_cryptography">lattice</a>-based HRSS. The former has short key sizes (~330 bytes) but has a high computational cost; the latter has larger key sizes (~1100 bytes), but is a few orders of magnitude faster.</p><p>During NIST’s <i>Second PQC Standardization Conference</i>, Nick Sullivan <a href="https://csrc.nist.gov/CSRC/media/Presentations/measuring-tls-key-exchange-with-post-quantum-kem/images-media/sullivan-session-1-paper-pqc2019.pdf">presented</a> our approach to this experiment and some initial results. Quite accurately, he compared NTRU-HRSS to an ostrich and SIKE to a turkey—one is big and fast and the other is small and slow.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/5600IZEbaJcZ2V0k94geH3/ab7f92737bba59c2ca9f53484bcbeba8/Screen-Shot-2019-10-29-at-1.33.21-PM.png" />
            
            </figure>
    <div>
      <h2>Setup &amp; Execution</h2>
      <a href="#setup-execution">
        
      </a>
    </div>
    <p>We based our experiment on TLS 1.3. Cloudflare operated the server-side TLS connections and Google Chrome (Canary and Dev builds) represented the client side of the experiment. We enabled both CECPQ2 (HRSS + X25519) and CECPQ2b (SIKE/p434 + X25519) key-agreement algorithms on all TLS-terminating edge servers. Since the post-quantum algorithms are considered experimental, the X25519 key exchange serves as a fallback to ensure the classical security of the connection.</p><p>Clients participating in the experiment were split into 3 groups—those who initiated TLS handshake with post-quantum CECPQ2, CECPQ2b or non post-quantum X25519 public keys. Each group represented approximately one third of the Chrome Canary population participating in the experiment.</p><p>In order to distinguish between clients participating in or excluded from the experiment, we added a custom extension to the TLS handshake. It worked as a simple flag sent by clients and echoed back by Cloudflare edge servers. This allowed us to measure the duration of TLS handshakes only for clients participating in the experiment.</p><p>For each connection, we collected telemetry metrics. The most important metric was a TLS server-side handshake duration defined as the time between receiving the Client Hello and Client Finished messages. The diagram below shows details of what was measured and how post-quantum key exchange was integrated with TLS 1.3.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/k6tBsggyYQ4ZSdjewV5kh/fe555ffe2b4fbf517cd88167416ee9b0/image1.png" />
            
            </figure><p>The experiment ran for 53 days in total, between August and October. During this time we collected millions of data samples, representing 5% of (anonymized) TLS connections that contained the extension signaling that the client was part of the experiment. We carried out the experiment in two phases.</p><p>In the first phase of the experiment, each client was assigned to use one of the three key exchange groups, and each client offered the same key exchange group for every connection. We collected over 10 million records over 40 days.</p><p>In the second phase of the experiment, client behavior was modified so that each client randomly chose which key exchange group to offer for each new connection, allowing us to directly compare the performance of each algorithm on a per-client basis. Data collection for this phase lasted 13 days and we collected 270 thousand records.</p>
    <div>
      <h2>Results</h2>
      <a href="#results">
        
      </a>
    </div>
    <p>We now describe our server-side measurement results. Client-side results are described at <a href="https://www.imperialviolet.org/2019/10/30/pqsivssl.html">https://www.imperialviolet.org/2019/10/30/pqsivssl.html</a>.</p>
    <div>
      <h3>What did we find?</h3>
      <a href="#what-did-we-find">
        
      </a>
    </div>
    <p>The primary metric we collected for each connection was the server-side handshake duration. The below histograms show handshake duration timings for all client measurements gathered in the first phase of the experiment, as well as breakdowns into the top five operating systems. The operating system breakdowns shown are restricted to only desktop/laptop devices except for Android, which consists of only mobile devices.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3DhkWkx8LGaOZpiziA6cWv/850d3d3fbd38bfd8b80c0550158af323/Screen-Shot-2019-10-29-at-2.04.13-PM.png" />
            
            </figure><p>It’s clear from the above plots that for most clients, CECPQ2b performs worse than CECPQ2 and CONTROL. Thus, the small key size of CECPQ2b does not make up for its large computational cost—the ostrich outpaces the turkey.</p>
    <div>
      <h3>Digging a little deeper</h3>
      <a href="#digging-a-little-deeper">
        
      </a>
    </div>
    <p>This means we’re done, right? Not quite. We are interested in determining if there are <i>any</i> populations of TLS clients for which CECPQ2b consistency outperforms CECPQ2. This requires taking a closer look at the long tail of handshake durations. The below plots show <a href="https://en.wikipedia.org/wiki/Cumulative_distribution_function">cumulative distribution functions</a> (CDFs) of handshake timings zoomed in on the 80th percentile (e.g., showing the top 20% of slowest handshakes).</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3ZK481qKXDJSN9exzz2DnN/eca75f3df9dadc29c41416632395a0a5/Screen-Shot-2019-10-29-at-2.04.33-PM-4.png" />
            
            </figure><p>Here, we start to see something interesting. For Android, Linux, and Windows devices, there is a <i>crossover</i> point where CECPQ2b actually starts to outperform CECPQ2 (Android: ~94th percentile, Linux: ~92nd percentile, Windows: ~95th percentile). macOS and ChromeOS do not appear to have these crossover points.</p><p>These effects are small but statistically significant in some cases. The below table shows approximate 95% <a href="https://en.wikipedia.org/wiki/Confidence_interval">confidence intervals</a> for the 50th (median), 95th, and 99th percentiles of handshake durations for each key exchange group and device type, calculated using <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mstats.mquantiles_cimj.html">Maritz-Jarrett estimators</a>. The numbers within square brackets give the lower and upper bounds on our estimates for each percentile of the “true” distribution of handshake durations based on the samples collected in the experiment. For example, with a 95% confidence level we can say that the 99th percentile of handshake durations for CECPQ2 on Android devices lies between 4057ms and 4478ms, while the 99th percentile for CECPQ2b lies between 3276ms and 3646ms. Since the intervals do not overlap, we say that with <i>statistical significance</i>, the experiment indicates that CECPQ2b performs better than CECPQ2 for the slowest 1% of Android connections. Configurations where CECPQ2 or CECPQ2b outperforms the other with statistical significance are marked with green in the table.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/QEGlVhyK9fxu4gFAlhIq8/a8e8271d4965d40ce64b55ed634e06be/Screen-Shot-2019-10-29-at-2.23.52-PM.png" />
            
            </figure>
    <div>
      <h3>Per-client comparison</h3>
      <a href="#per-client-comparison">
        
      </a>
    </div>
    <p>A second phase of the experiment directly examined the performance of each key exchange algorithm for individual clients, where a client is defined to be a unique (anonymized) IP address and user agent pair. Instead of choosing a single key exchange algorithm for the duration of the experiment, clients randomly selected one of the experiment configurations for each new connection. Although the duration and sample size were limited for this phase of the experiment, we collected at least three handshake measurements for each group configuration from 3900 unique clients.</p><p>The plot below shows for each of these clients the difference in latency between CECPQ2 and CECPQ2b, taking the minimum latency sample for each key exchange group as the representative value. The CDF plot shows that for 80% of clients, CECPQ2 outperformed or matched CECPQ2b, and for 99% of clients, the latency gap remained within 70ms. At a high level, this indicates that very few clients performed significantly worse with CECPQ2 over CECPQ2b.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3FdAbGJuJBIDIjT0zExyvF/2a4cbf6befc35e6faa50492ca34d1dc0/TLS-handshake-latency-gap-per-client--All-_logspace_symlog_randomconfig.png" />
            
            </figure>
    <div>
      <h3>Do other factors impact the latency gap?</h3>
      <a href="#do-other-factors-impact-the-latency-gap">
        
      </a>
    </div>
    <p>We looked at a number of other factors—including session resumption, IP version, and network location—to see if they impacted the latency gap between CECPQ2 and CECPQ2b. These factors impacted the overall handshake latency, but we did not find that any made a significant impact on the latency gap between post-quantum ciphers. We share some interesting observations from this analysis below.</p>
    <div>
      <h4>Session resumption</h4>
      <a href="#session-resumption">
        
      </a>
    </div>
    <p>Approximately 53% of all connections in the experiment were completed with <a href="https://tools.ietf.org/html/rfc8446#section-2.2">TLS handshake resumption</a>. However, the percentage of resumed connections varied significantly based on the device configuration. Connections from mobile devices were only resumed ~25% of the time, while between 40% and 70% of connections from laptop/desktop devices were resumed. Additionally, resumption provided between a 30% and 50% speedup for all device types.</p>
    <div>
      <h4>IP version</h4>
      <a href="#ip-version">
        
      </a>
    </div>
    <p>We also examined the impact of IP version on handshake latency. Only 12.5% of the connections in the experiment used IPv6. These connections were 20-40% faster than IPv4 connections for desktop/laptop devices, but ~15% slower for mobile devices. This could be an artifact of IPv6 being generally deployed on newer devices with faster processors. For Android, the experiment was only run on devices with more modern processors, which perhaps eliminated the bias.</p>
    <div>
      <h4>Network location</h4>
      <a href="#network-location">
        
      </a>
    </div>
    <p>The slow connections making up the long tail of handshake durations were not isolated to a few countries, Autonomous Systems (ASes), or subnets, but originated from a globally diverse set of clients. We did not find a correlation between the relative performance of the two post-quantum key exchange algorithms based on these factors.</p>
    <div>
      <h2>Discussion</h2>
      <a href="#discussion">
        
      </a>
    </div>
    <p>We found that CECPQ2 (the ostrich) outperformed CECPQ2b (the turkey), for the majority of connections in the experiment, indicating that fast algorithms with large keys may be more suitable for TLS than slow algorithms with small keys. However, we observed the opposite—that CECPQ2b outperformed CECPQ2—for the slowest connections on some devices, including Windows computers and Android mobile devices. One possible explanation for this is packet fragmentation and packet loss. The maximum size of TCP packets that can be sent across a network is limited by the maximum transmission unit (MTU) of the network path, which is often ~1400 bytes. During the TLS handshake the server responds to the client with its public key and ciphertext, the combined size of which exceeds the MTU, so it is likely that handshake messages must be split across multiple TCP packets. This increases the risk of lost packets and delays due to retransmission. A repeat of this experiment that includes collection of fine-grained TCP telemetry could confirm this hypothesis.</p><p>A somewhat surprising result of this experiment is just how fast HRSS performs for the majority of connections. Recall that the CECPQ2 cipher performs key exchange operations for both X25519 and HRSS, but the additional overhead of HRSS is barely noticeable. Comparing benchmark results, we can see that HRSS will be faster than X25519 on the server side and slower on the client side.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/1fH5vILIYldcwbFurzWlt5/05136ac598d8255bf108138854d88c0e/Screen-Shot-2019-10-29-at-2.24.57-PM.png" />
            
            </figure><p>In our design, the client side performs two operations—key generation and KEM decapsulation. Looking at those two operations we can see that the key generation is a bottleneck here.</p>
            <pre><code>Key generation: 	3553.5 [ops/sec]
KEM decapsulation: 	17186.7 [ops/sec]</code></pre>
            <p>In algorithms with quotient-style keys (like NTRU), the key generation algorithm performs an inversion in the quotient ring—an operation that is quite computationally expensive. Alternatively, a TLS implementation could generate ephemeral keys ahead of time in order to speed up key exchange. There are several other lattice-based key exchange candidates that may be worth experimenting with in the context of TLS key exchange, which are based on different underlying principles than the HRSS construction. These candidates have similar key sizes and faster key generation algorithms, but have their own drawbacks. <b>For now, HRSS looks like the more promising algorithm for use in TLS</b>.</p><p>In the case of SIKE, we <a href="https://github.com/post-quantum-cryptography/c-sike/">implemented</a> the most recent version of the algorithm, and instantiated it with the most performance-efficient parameter set for our experiment. The algorithm is computationally expensive, so we were required to use assembly to optimize it. In order to ensure best performance on Intel, most performance-critical operations have two different implementations; the library detects CPU capabilities and uses <a href="https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/ia-large-integer-arithmetic-paper.pdf">faster instructions</a> if available, but otherwise falls back to a slightly slower generic implementation. We developed our own optimizations for 64-bit ARM CPUs. Nevertheless, our results show that SIKE incurred a significant overhead for every connection, especially on devices with weaker processors. It must be noted that high-performance isogeny-based public key cryptography is arguably much less developed than its lattice-based counterparts. Some ideas to develop this are <a href="https://www.youtube.com/watch?v=UfF3_YtYzPA">floating around</a>, and we expect to see performance improvements in the future.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/1nRjTCxKGIX2eghIjIGTXb/9cfaf88594f50d09738177372fefb4d0/tales-from-the-crypto-team_2x-6.png" />
            
            </figure><p></p> ]]></content:encoded>
            <category><![CDATA[Crypto Week]]></category>
            <category><![CDATA[TLS]]></category>
            <category><![CDATA[Security]]></category>
            <category><![CDATA[Research]]></category>
            <category><![CDATA[Post-Quantum]]></category>
            <category><![CDATA[Cryptography]]></category>
            <guid isPermaLink="false">3bVzoY16y2yy4PGR8r0cL5</guid>
            <dc:creator>Kris Kwiatkowski</dc:creator>
            <dc:creator>Luke Valenta</dc:creator>
        </item>
        <item>
            <title><![CDATA[Towards Post-Quantum Cryptography in TLS]]></title>
            <link>https://blog.cloudflare.com/towards-post-quantum-cryptography-in-tls/</link>
            <pubDate>Thu, 20 Jun 2019 13:01:00 GMT</pubDate>
            <description><![CDATA[ In anticipation of wide-spread quantum computing, the transition from classical public-key cryptography primitives to post-quantum (PQ) alternatives has started. ]]></description>
            <content:encoded><![CDATA[ <p></p><p>We live in a completely connected society. A society connected by a variety of devices: laptops, mobile phones, wearables, self-driving or self-flying <i>things</i>. We have standards for a common language that allows these devices to communicate with each other. This is critical for wide-scale deployment – especially in cryptography where the smallest detail has great importance.</p><p>One of the most important standards-setting organizations is the National Institute of Standards and Technology (NIST), which is hugely influential in determining which standardized cryptographic systems see worldwide adoption. At the end of 2016, NIST announced it would hold a multi-year open project with the goal of standardizing new <a href="https://www.cloudflare.com/learning/ssl/quantum/what-is-post-quantum-cryptography/">post-quantum (PQ) cryptographic algorithms</a> secure against both quantum and classical computers.</p><p>Many of our devices have very different requirements and capabilities, so it may not be possible to select a “one-size-fits-all” algorithm during the process. NIST mathematician, Dustin Moody, indicated that institute will likely select more than one algorithm:</p><blockquote><p><i>“There are several systems in use that could be broken by a quantum computer - public-key encryption and digital signatures, to take two examples - and we will need different solutions for each of those systems.”</i></p></blockquote><p>Initially, NIST selected 82 candidates for further consideration from all submitted algorithms. At the beginning of 2019, this process entered its second stage. Today, there are 26 algorithms still in contention.</p>
    <div>
      <h3>Post-quantum cryptography: what is it really and why do I need it?</h3>
      <a href="#post-quantum-cryptography-what-is-it-really-and-why-do-i-need-it">
        
      </a>
    </div>
    <p>In 1994, Peter Shor made a significant <a href="https://arxiv.org/abs/quant-ph/9508027">discovery</a> in quantum computation. He found an algorithm for integer factorization and computing discrete logarithms, both believed to be hard to solve in classical settings. Since then it has become clear that the 'hard problems' on which cryptosystems like RSA and elliptic curve cryptography (ECC) rely – integer factoring and computing discrete logarithms, respectively – are efficiently solvable with quantum computing.</p><p>A quantum computer can help to solve some of the problems that are intractable on a classical computer. In theory, they could efficiently solve some <a href="https://www.quantamagazine.org/finally-a-problem-that-only-quantum-computers-will-ever-be-able-to-solve-20180621/">fundamental problems</a> in mathematics. This amazing computing power would be highly beneficial, which is why companies are actually trying to build quantum computers. At first, Shor’s algorithm was merely a theoretical result – quantum computers powerful enough to execute it did not exist – but this is quickly changing. In March 2018, Google announced a 72-qubit universal quantum computer. While this is not enough to break say RSA-2048 (still <a href="https://arxiv.org/abs/1905.09749">more is needed</a>), many fundamental problems have already been solved.</p><p>In anticipation of wide-spread quantum computing, we must start the transition from classical public-key cryptography primitives to post-quantum (PQ) alternatives. It may be that consumers will never get to hold a quantum computer, but a few powerful attackers who will get one can still pose a serious threat. Moreover, under the assumption that current TLS handshakes and ciphertexts are being captured and stored, a future attacker could crack these stored individual session keys and use those results to decrypt the corresponding individual ciphertexts. Even strong security guarantees, like <a href="/staying-on-top-of-tls-attacks/">forward secrecy</a>, do not help out much there.</p><p>In 2006, the academic research community launched a conference series dedicated to finding alternatives to RSA and ECC. This so-called <i>post-quantum cryptography</i> should run efficiently on a classical computer, but it should also be secure against attacks performed by a quantum computer. As a research field, it has grown substantially in popularity.</p><p>Several companies, including Google, Microsoft, Digicert and Thales, are already testing the impact of deploying PQ cryptography. Cloudflare is involved in some of this, but we want to be a company that leads in this direction. The first thing we need to do is understand the real costs of deploying PQ cryptography, and that’s not obvious at all.</p>
    <div>
      <h3>What options do we have?</h3>
      <a href="#what-options-do-we-have">
        
      </a>
    </div>
    <p>Many submissions to the NIST project are still under study. Some are very new and little understood; others are more mature and already standardized as RFCs. Some have been broken or withdrawn from the process; others are more conservative or <a href="https://eprint.iacr.org/2017/351.pdf">illustrate</a> how far classical cryptography would need to be pushed so that a quantum computer could not crack it within a reasonable cost. Some are very slow and big; others are not. But most cryptographic schemes can be categorized into these families: <a href="https://web.eecs.umich.edu/~cpeikert/pubs/lattice-survey.pdf">lattice-based</a>, <a href="http://www.cryptosystem.net/hfe.pdf">multivariate</a>, <a href="https://link.springer.com/content/pdf/10.1007%2F0-387-34805-0_21.pdf">hash-based</a> (signatures only), <a href="https://ipnpr.jpl.nasa.gov/progress_report2/42-44/44N.PDF">code-based</a> and <a href="https://eprint.iacr.org/2011/506.pdf">isogeny-based</a>.</p><p>For some algorithms, nevertheless, there is a fear they may be too inconvenient to use with today’s Internet. We must also be able to integrate new cryptographic schemes with existing protocols, such as <a href="https://www.cloudflare.com/learning/access-management/what-is-ssh/">SSH</a> or TLS. To do that, designers of PQ cryptosystems must consider these characteristics:</p><ul><li><p>Latency caused by encryption and decryption on both ends of the communication channel, assuming a variety of devices from big and fast servers to slow and memory constrained IoT (Internet of Things) devices</p></li><li><p>Small public keys and signatures to minimize bandwidth</p></li><li><p>Clear design that allows cryptanalysis and determining weaknesses that could be exploited</p></li><li><p>Use of existing hardware for fast implementation</p></li></ul><p>The work on post-quantum public key cryptosystems must be done in a full view of organizations, governments, cryptographers, and the public. Emerging ideas must be properly vetted by this community to ensure widespread support.</p>
    <div>
      <h3>Helping Build a Better Internet</h3>
      <a href="#helping-build-a-better-internet">
        
      </a>
    </div>
    
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3oHEFoSgnIAeuq111tpnEw/18189d2954df7b8c991258f1439a2e2f/pasted-image-0-5.png" />
            
            </figure><p>To better understand the post-quantum world, Cloudflare began experimenting with these algorithms and used them to provide confidentiality in TLS connections.</p><p>With Google, we are proposing a wide-scale experiment that combines client- and server-side data collection to evaluate the performance of key-exchange algorithms on actual users’ devices. We hope that this experiment helps choose an algorithm with the best characteristics for the future of the Internet. With Cloudflare’s highly distributed network of access points and Google’s Chrome browser, both companies are in a very good position to perform this experiment.</p><p>Our goal is to understand how these algorithms act when used by real clients over real networks, particularly candidate algorithms with significant differences in public-key or ciphertext sizes. Our focus is on how different key sizes affect handshake time in the context of Transport Layer Security (TLS) as used on the web over HTTPS.</p><p>Our primary candidates are an NTRU-based construction called HRSS-SXY (by <b>H</b>ülsing - <b>R</b>ijneveld - <b>S</b>chanck - <b>S</b>chwabe, and Tsunekazu <b>S</b>aito - Keita <b>X</b>agawa - Takashi <b>Y</b>amakawa) and an isogeny-based Supersingular Isogeny Key Encapsulation (SIKE). Details of both algorithms are described in more detail below in section "Dive into post-quantum cryptography". This table shows a few characteristics for both algorithms. Performance timings were obtained by running the BoringSSL speed test on an Intel Skylake CPU.</p><table> <tr> 
    <th>KEM</th> 
    <th>Public Key size (bytes)</th> 
    <th>Ciphertext (bytes)</th>
    <th>Secret size (bytes)</th> <th>KeyGen (op/sec)</th> <th>Encaps (op/sec)</th> <th>Decaps (op/sec)</th> <th>NIST level</th> </tr> 
<tr><td>HRSS-SXY</td> <td>1138</td> <td>1138</td> <td>32</td> <td>3952.3</td> <td>76034.7</td> <td>21905.8</td> <td>1</td> </tr> 
    
<tr> <td>SIKE/p434</td> <td>330</td> <td>346</td> <td>16</td> <td>367.1</td> <td>228.0</td> <td>209.3</td> <td>1</td> </tr> </table><p>Currently the most commonly used key exchange algorithm (according to Cloudflare’s data) is the non-quantum X25519. Its public keys are 32 bytes and BoringSSL can generate 49301.2 key pairs, and is able to perform 19628.6 key agreements every second on my Skylake CPU.</p><p>Note that HRSS-SXY shows a significant speed advantage, while SIKE has a size advantage. In our experiment, we will deploy these two algorithms on both the server side using Cloudflare’s infrastructure, and the client side using Chrome Canary; both sides will collect telemetry information about TLS handshakes using these two PQ algorithms to see how they perform in practice.</p>
    <div>
      <h3>What do we expect to find?</h3>
      <a href="#what-do-we-expect-to-find">
        
      </a>
    </div>
    <p>In 2018, Adam Langley conducted an <a href="https://www.imperialviolet.org/2018/04/11/pqconftls.html">experiment</a> with the goal of evaluating the likely latency impact of a post-quantum key exchange in TLS. Chrome was augmented with the ability to include a dummy, arbitrarily-sized extension in the TLS ClientHello (fixed number of bytes of random noise). After taking into account the performance and key size offered by different types key-exchange schemes, he concluded that constructs based on structured lattices may be most suitable for future use in TLS.</p><p>However, Langley also observed a peculiar phenomenon; client connections measured at 95th percentile had much higher latency than the median. It means that in those cases, isogeny-based systems may be a better choice. In the "Dive into post-quantum cryptography", we describe the difference between isogeny-based SIKE and lattice-based NTRU cryptosystems.</p><p>In our experiment, we want to more thoroughly evaluate and ascribe root causes to these unexpected latency increases. We would particularly like to learn more about the characteristics of those networks: what causes increased latency? how does the performance cost of isogeny-based algorithms impact the TLS handshake? We want to answer key questions, like:</p><ul><li><p>What is a good ratio for speed-to-key size (or how much faster could SIKE get to achieve the client-perceived performance of HRSS)?</p></li><li><p>How do network middleboxes behave when clients use new PQ algorithms, and which networks have problematic middleboxes?</p></li><li><p>How do the different properties of client networks affect TLS performance with different PQ key exchanges? Can we identify specific autonomous systems, device configurations, or network configurations that favor one algorithm over another? How is performance affected in the long tail?</p></li></ul>
    <div>
      <h3>Experiment Design</h3>
      <a href="#experiment-design">
        
      </a>
    </div>
    <p>Our experiment will involve both server- and client-side performance statistics collection from real users around the world (all the data is anonymized). Cloudflare is operating the server-side TLS connections. We will enable the <a href="https://www.imperialviolet.org/2018/12/12/cecpq2.html">CECPQ2</a> (HRSS + X25519) and <a href="https://tools.ietf.org/html/draft-kiefer-tls-ecdhe-sidh-00">CECPQ2b</a> (SIKE + X25519) key-agreement algorithms on all TLS-terminating edge servers.</p><p>In this experiment, the ClientHello will contain a CECPQ2 or CECPQ2b public key (but never both). Additionally, Chrome will always include X25519 for servers that do not support post-quantum key exchange. The post-quantum key exchange will only be negotiated in TLS version 1.3 when both sides support it.</p><p>Since Cloudflare only measures the server side of the connection, it is impossible to determine the time it takes for a ClientHello sent from Chrome to reach Cloudflare’s edge servers; however, we can measure the time it takes for the TLS ServerHello message containing post-quantum key exchange, to reach the client and for the client to respond.</p><p>On the client side, Chrome Canary will operate the TLS connection. Google will enable either CECPQ2 or CECPQ2b in Chrome for the following mix of architecture and OSes:</p><ul><li><p>x86-64: Windows, Linux, macOS, ChromeOS</p></li><li><p>aarch64: Android</p></li></ul><p>Our high-level expectation is to get similar results as Langley’s original experiment in 2018 — slightly increased latency for the 50th percentile and higher latency for the 95th. Unfortunately, data collected purely from real users’ connections may not suffice for diagnosing the root causes of why some clients experience excessive slowdown. To this end, we will perform follow-up experiments based on per-client information we collect server-side.</p><p>Our primary hypothesis is that excessive slowdowns, like those Langley observed, are largely due to in-network events, such as middleboxes or bloated/lossy links. As a first-pass analysis, we will investigate whether the slowed-down clients share common network features, like common ASes, common transit networks, common link types, and so on. To determine this, we will run a traceroute from vantage points close to our servers back toward the clients (not overloading any particular links or hosts) and study whether some client locations are subject to slowdowns for all destinations or just for some.</p>
    <div>
      <h3>Dive into post-quantum cryptography</h3>
      <a href="#dive-into-post-quantum-cryptography">
        
      </a>
    </div>
    <p>Be warned: the details of PQ cryptography may be quite complicated. In some cases it builds on classical cryptography, and in other cases it is completely different math. It would be rather hard to describe details in a single blog post. Instead, we are giving you an intuition of post-quantum cryptography, rather than provide deep academic-level descriptions. We’re skipping a lot of details for the sake of brevity. Nevertheless, settle in for a bit of an epic journey because we have a lot to cover.</p>
    <div>
      <h3>Key encapsulation mechanism</h3>
      <a href="#key-encapsulation-mechanism">
        
      </a>
    </div>
    <p>NIST requires that all key-agreement algorithms have a form of key-encapsulation mechanism (KEM). The KEM is a simplified form of public key encryption (PKE). As PKE, it also allows agreement on a secret, but in a slightly different way. The idea is that the session key is an output of the encryption algorithm, conversely to public key encryption schemes where session key is an input to the algorithm. In a KEM, Alice generates a random key and uses the pre-generated public key from Bob to encrypt (encapsulate) it. This results in a ciphertext sent to Bob. Bob uses his private key to decrypt (decapsulate) the ciphertext and retrieve the random key. The idea was initially introduced by <a href="https://eprint.iacr.org/2001/108">Cramer and Shoup</a>. Experience shows that such constructs are easier to design, analyze, and implement as the scheme is limited to communicating a fixed-size session key. Leonardo Da Vinci said, “Simplicity is the ultimate sophistication,” which is very true in cryptography.</p><p>The key exchange (KEX) protocol, like <a href="https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange">Diffie-Hellman</a>, is yet a different construct: it allows two parties to agree on a shared secret that can be used as a symmetric encryption key. For example, Alice generates a key pair and sends a public key to Bob. Bob does the same and uses his own key pair with Alice’s public key to generate the shared secret. He then sends his public key to Alice who can now generate the same shared secret. What’s worth noticing is that both Alice and Bob perform exactly the same operations.</p><p>KEM construction can be converted to KEX. Alice performs key generation and sends the public key to Bob. Bob uses it to encapsulate a symmetric session key and sends it back to Alice. Alice decapsulates the ciphertext received from Bob and gets the symmetric key. This is actually what we do in our experiment to make integration with the TLS protocol less complicated.</p>
    <div>
      <h3>NTRU Lattice-based Encryption  </h3>
      <a href="#ntru-lattice-based-encryption">
        
      </a>
    </div>
    <p>We will enable the CECPQ2 implemented by Adam Langley from Google on our servers. He described this implementation in detail <a href="https://www.imperialviolet.org/2018/12/12/cecpq2.html">here</a>. This key exchange uses the HRSS algorithm, which is based on the NTRU (<b>N</b>-Th Degree <b>TRU</b>ncated Polynomial Ring) algorithm. Foregoing too much detail, I am going to explain how NTRU works and give simplified examples, and finally, compare it to HRSS.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3mw4chMg1bmziLfBeRywAo/f8353de8b49dee0704f5a813c4609230/polynomial-wheel_3x-1.png" />
            
            </figure><p>NTRU is a cryptosystem based on a polynomial ring. This means that we do not operate on numbers modulo a prime (like in RSA), but on polynomials of degree \( N \) , where the <i>degree</i> of a polynomial is the highest exponent of its variable. For example, $x^7 + 6x^3 + 11x^2$ has degree of 7.</p><p>One can add polynomials in the ring in the usual way, by simply adding theirs coefficients modulo some integer. In NTRU this integer is called \( q \). Polynomials can also be multiplied, but remember, you are operating in the ring, therefore the result of a multiplication is always a polynomial of degree less than \(N\). It basically means that exponents of the resulting polynomial are added to modulo \(N\).</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/4fjc31dekJkPOBmLSlnJPS/de486d978d6740055c65deadd39ed3b2/1feQoHE5ePfzDfdzw01q3eQDZz6gCs6znHlzj24ThULscNMsvS6kdmoN0diX9cGbcpcB6T7WbUk5v1vdfLB1vSWizK3LFpW3b_4lNY6i-BwIEAtVdp1wCz-D85gC.png" />
            
            </figure><p>In other words, polynomial ring arithmetic is very similar to modular arithmetic<a href="https://betterexplained.com/articles/fun-with-modular-arithmetic/">,</a> but instead of working with a set of numbers less than <i>N</i>, you are working with a set of polynomials with a degree less than <i>N</i>.</p><p>To instantiate the NTRU cryptosystem, three domain parameters must be chosen:</p><ul><li><p>\(N\) - degree of the polynomial ring, in NTRU the principal objects are polynomials of degree \(N-1\).</p></li><li><p>\(p\) - small modulus used during key generation and decryption for reducing message coefficients.</p></li><li><p>\(q\) - large modulus used during algorithm execution for reducing coefficients of the polynomials.</p></li></ul><p>First, we generate a pair of public and private keys. To do that, two polynomials \(f\) and \(g\) are chosen from the ring in a way that their randomly generated coefficients are much smaller than \(q\). Then key generation computes two inverses of the polynomial: $$ f_p= f^{-1} \bmod{p}   \\  f_q= f^{-1} \bmod{q} $$</p><p>The last step is to compute $$ pk = p\cdot f_q\cdot g \bmod q $$, which we will use as public key <i>pk</i>. The private key consists of \(f\) and \(f_p\). The \(f_q\) is not part of any key, however it must remain secret.</p><p>It might be the case that after choosing \(f\), the inverses modulo \(p\) and \( q \) do not exist. In this case, the algorithm has to start from the beginning and generate another \(f\). That’s unfortunate because calculating the inverse of a polynomial is a costly operation. HRSS brings an improvement to this issue since it ensures that those inverses always exist, making key generation faster than as proposed initially in NTRU.</p><p>The encryption of a message \(m\) proceeds as follows. First, the message \(m\) is converted to a ring element \(pt\) (there exists an algorithm for performing this conversion in both directions). During encryption, NTRU randomly chooses one polynomial \(b\) called <i>blinder.</i> The goal of the blinder is to generate different ciphertexts per encyption. Thus, the ciphetext \(ct\) is obtained as $$ ct = (b\cdot pk + pt ) \bmod q $$ Decryption looks a bit more complicated but it can also be easily understood. Decryption uses both the secret value \(f\) and to recover the plaintext as $$ v =  f \cdot ct \bmod q \\ pt = v \cdot f_p \bmod p $$</p><p>This diagram demonstrates why and how decryption works.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3m4bNrzq0NQFYpTObXuHYj/631873550a519f0bb4552f3343db00af/image-24.png" />
            
            </figure><p>Step-by-step correctness of decryption procedure.</p><p>After obtaining \(pt\), the message \(m\) is recovered by inverting the conversion function.</p><p>The underlying hard assumption is that given two polynomials: \(f\) and \(g\) whose coefficients are short compared to the modulus \(q\), it is difficult to distinguish \(pk = \frac{f}{g} \) from a random element in the ring. It means that it’s hard to find \(f\) and \(g\) given only public key <i>pk</i>.</p>
    <div>
      <h3>Lattices</h3>
      <a href="#lattices">
        
      </a>
    </div>
    <p>NTRU cryptosystem is a grandfather of lattice-based encryption schemes. The idea of using  difficult problems for cryptographic purposes was due to <a href="http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=144BBB9F0E87EF0D471151F0EACC7DB8?doi=10.1.1.40.2489&amp;rep=rep1&amp;type=pdf">Ajtai</a>. His work evolved into a whole area of research with the goal of creating more practical, lattice-based cryptosystems.</p>
    <div>
      <h3>What is a lattice and why it can be used for post-quantum crypto?</h3>
      <a href="#what-is-a-lattice-and-why-it-can-be-used-for-post-quantum-crypto">
        
      </a>
    </div>
    <p>The picture below visualizes lattice as points in a two-dimensional space. A lattice is defined by the origin \(O\) and base vectors \( \{ b_1 , b_2\} \). Every point on the lattice is represented as a linear combination of the base vectors, for example  \(V = -2b_1+b_2\).</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/40Fg69tL7QYjTIzHk5s0z2/d6807ffa9ba6a103c4d8d1ac845c2f14/pasted-image-0--1--3.png" />
            
            </figure><p>There are two classical NP-hard problems in lattice-based cryptography:</p><ol><li><p><b>Shortest Vector Problem</b> (SVP): Given a lattice, to find the shortest non-zero vector in the lattice. In the graph, the vector \(s\) is the shortest one. The SVP problem is NP-hard only under some assumptions.</p></li><li><p><b>Closest Vector Problem</b> (CVP). Given a lattice and a vector \(V\) (not necessarily in the lattice), to find the closest vector to \(V\)<i>.</i> For example, the closest vector to \(t\) is \(z\).</p></li></ol><p>In the graph above, it is easy for us to solve SVP and CVP by simple inspection. However, the lattices used in cryptography have higher dimensions, say above 1000, as well as highly non-orthogonal basis vectors. On these instances, the problems get extremely hard to solve. It’s even believed future quantum computers will have it tough.</p>
    <div>
      <h3>NTRU vs HRSS</h3>
      <a href="#ntru-vs-hrss">
        
      </a>
    </div>
    <p>HRSS, which we use in our experiment, is based on NTRU, but a slightly better instantiation. The main improvements are:</p><ul><li><p>Faster key generation algorithm.</p></li><li><p>NTRU encryption can produce ciphertexts that are impossible to decrypt (true for many lattice-based schemes). But HRSS fixes this problem.</p></li><li><p>HRSS is a key encapsulation mechanism.</p></li></ul>
    <div>
      <h3>CECPQ2b - Isogeny-based Post-Quantum TLS</h3>
      <a href="#cecpq2b-isogeny-based-post-quantum-tls">
        
      </a>
    </div>
    <p>Following CECPQ2, we have integrated into BoringSSL another hybrid key exchange mechanism relying on SIKE. It is called CECPQ2b and we will use it in our experimentation in TLS 1.3. <a href="https://sike.org">SIKE</a> is a key encapsulation method based on Supersingular Isogeny Diffie-Hellman (SIDH). Read more about <a href="/sidh-go/">SIDH</a> in our previous post. The math behind SIDH is related to elliptic curves. A comparison between SIDH and the classical Elliptic Curve Diffie-Hellman (ECDH) is given.</p><p>An elliptic curve is a set of points that satisfy a specific mathematical equation. The equation of an elliptic curve may have multiple forms, the standard form is called the <i>Weierstrass</i> equation $$ y^2 = x^3 +ax +b  $$ and its shape can look like the red curve.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/26PHEagKtiaocOpyT6e85j/4e0b5a3e2f40bdf6fa77b4a14b44b88d/pasted-image-0--2--3.png" />
            
            </figure><p>An interesting fact about elliptic curves is have a group structure. That is, the set of points on the curve have associated a binary operation called <i>point addition</i>. The set of points on the elliptic curve is closed under addition. Thus, adding two points results in another point that is also on the elliptic curve.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/65C2RgCyQ7TG84QUa4kYkd/14197ecc324cb64112614ec33fe06ba1/ecc.gif" />
            
            </figure><p>If we can add two different points on a curve, then we can also add one point to itself. And if we do it multiple times, then the resulting operations is known as a <i>scalar multiplication</i> and denoted as  <i>\(Q = k\cdot P = P+P+\dots+P\)</i> for an integer \(k\).</p><p>Multiplication of scalars is <i>commutative</i>. It means that two scalar multiplications can be evaluated in any order \( \color{darkred}{k_a}\cdot\color{darkgreen}{k_b} =   \color{darkgreen}{k_b}\cdot\color{darkred}{k_a} \); this an important property that makes ECDH possible.</p><p>It turns out that carefully if choosing an elliptic curve "correctly", scalar multiplication is easy to compute but extremely hard to reverse. Meaning, given two points \(Q\) and \(P\) such that \(Q=k\cdot P\), finding the integer k is a difficult task known as the Elliptic Curve Discrete Logarithm problem (ECDLP). This problem is suitable for cryptographic purposes.</p><p>Alice and Bob agree on a secret key as follows. Alice generates a private key \( k_a\). Then, she uses some publicly known point \(P\) and calculates her public key as \( Q_a = k_a\cdot P\). Bob proceeds in similar fashion and gets \(k_b\) and \(Q_b = k_b\cdot P\). To agree on a shared secret, each party multiplies their private key with the public key of the other party. The result of this is the shared secret. Key agreement as described above, works thanks to the fact that scalars can commute:$$  \color{darkgreen}{k_a} \cdot Q_b = \color{darkgreen}{k_a} \cdot  \color{darkred}{k_b} \cdot P \iff \color{darkred}{k_b} \cdot \color{darkgreen}{k_a} \cdot P = \color{darkred}{k_b} \cdot Q_a $$</p><p>There is a vast theory behind elliptic curves. An introduction to <a href="/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/">elliptic curve cryptography</a> was posted before and more details can be found in this <a href="https://doi.org/10.1007/b97644">book</a>. Now, lets describe SIDH and compare with ECDH.</p>
    <div>
      <h3>Isogenies on Elliptic Curves</h3>
      <a href="#isogenies-on-elliptic-curves">
        
      </a>
    </div>
    <p>Before explaining the details of SIDH key exchange, I’ll explain the 3 most important concepts, namely: <b><i>j-invariant, isogeny</i></b> and its <b><i>kernel.</i></b></p><p>Each curve has a number that can be associated to it. Let’s call this number a <b><i>j-invariant.</i></b> This number is not unique per curve, meaning many curves have the same value of <b><i>j-invariant</i></b>, but it can be viewed as a way to group multiple elliptic curves into disjoint sets. We say that two curves are <b><i>isomorphic</i></b> if they are in the same set, called the <i>isomorphism class</i>. The j-invariant is a simple criterion to determine whether two curves are isomorphic. The j-invariant of a curve \(E\) in Weierstrass form \( y^2 = x^3 + ax + b\) is given as $$ j(E) = 1728\frac{4a^3}{4a^3 +27b^2} $$</p><p>When it comes to <b><i>isogeny</i></b>, think about it as a map between two curves. Each point on some curve \( E \) is mapped by isogeny to the point on isogenous curve \( E' \). We denote mapping from curve \( E \) to \( E' \) by isogeny \( \phi \) as:</p><p>$$\phi: E \rightarrow E' $$</p><p>It depends on the map if those two curves are isomorphic or not. Isogeny can be visualised as:</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/4RSE4DdJxSwP5IspNUpc8D/689054d8939ceb6af436869a3dc352fb/pasted-image-0--3--2.png" />
            
            </figure><p>There may exist many of those mappings, each curve used in SIDH has small number of isogenies to other curves. Natural question is how do we compute such isogeny. Here is where the <b><i>kernel</i></b> of an isogeny comes. The <b><i>kernel</i></b> uniquely determines isogeny (up to <i>isomorphism class</i>). Formulas for calculating isogeny from its kernel were initially <a href="https://www.researchgate.net/publication/246557704_Isogenies_entre_courbes_elliptiques">given by J. Vélu</a> and the idea of calculating them efficiently was <a href="https://eprint.iacr.org/2017/504.pdf">extended</a>.</p><p>To finish, I will summarize what was said above with a picture.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/240s5FQy6PHpVMswhLAnAg/8af4f4386706c1abf312a3c58f429892/pasted-image-0--4--2.png" />
            
            </figure><p>There are two <b>isomorphism classes</b> on the picture above. Both curves \(E_1\) and \(E_2\) are <b>isomorphic</b> and have  j-invariant = 6. As curves \(E_3\) and \(E_4\) have j-invariant=13, they are in a different isomorphism class. There exists an <b>isogeny</b> \(\phi_2\) between curve \(E_3\) and \(E_2\), so they both are <b>isogeneous</b>. Curves \( \phi_1 \) and \( E_2 \) are isomorphic and there is isogeny \( \phi_1 \) between them. Curves \( E_1\) and \(E_4\) are not isomorphic.</p><p>For brevity I’m skipping many important details, like details of the <i>finite field,</i> the fact that isogenies must be <i>separable</i> and that the kernel is <i>finite.</i> But curious readers can find a number of academic research papers available on the Internet.</p>
    <div>
      <h3>Big picture: similarities with ECDH</h3>
      <a href="#big-picture-similarities-with-ecdh">
        
      </a>
    </div>
    <p>Let’s generalize the ECDH algorithm described above, so that we can swap some elements and try to use Supersingular Isogeny Diffie-Hellman.</p><p>Note that what actually happens during an ECDH key exchange is:</p><ul><li><p>We have a set of points on elliptic curve, set <i>S</i></p></li><li><p>We have another group of integers used for point multiplication, G</p></li><li><p>We use an element from <i>Z</i> to act on an element from <i>S</i> to get another element from <i>S</i>:</p></li></ul><p>$$ G \cdot S \rightarrow S $$</p><p>Now the question is: what is our <i>G</i> and <i>S</i> in an SIDH setting? For SIDH to work, we need a big set of elements and something secret that will act on the elements from that set. This “group action” must also be resistant to attacks performed by quantum computers.</p><p>In the SIDH setting, those two sets are defined as:</p><ul><li><p>Set <i>S</i> is a set (graph) of j-invariants, such that all the curves are supersingular: \( S = [j(E_1), j(E_2), j(E_3), .... , j(E_n)]\)</p></li><li><p>Set <i>G</i> is a set of isogenies acting on elliptic curves and transforming, for example, the elliptic curve \(E_1\) into \(E_n\):</p></li></ul>
    <div>
      <h3>Random walk on supersingular graph</h3>
      <a href="#random-walk-on-supersingular-graph">
        
      </a>
    </div>
    <p>When we talk about <i>Isogeny Based Cryptography</i>, as a topic distinct from <i>Elliptic Curve Cryptography</i>, we usually mean algorithms and protocols that rely fundamentally on the structure of isogeny graphs. An example of such a (small) graph is pictured below.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/3VatBy9An0gtSVOCUZBdjG/33747b7af909ae94861f7c30e981b875/isogeny-based-crypt0-1-.gif" />
            
            </figure><p>Animation based on Chloe Martindale <a href="https://2017.pqcrypto.org/school/slides/Isogeny_based_crypto.pdf">slide deck</a></p><p>Each vertex of the graph represents a different j-invariant of a set of supersingular curves. The edges between vertices represent isogenies converting one elliptic curve to another. As you can notice, the graph is strongly connected, meaning every vertex can be reached from every other vertex. In the context of isogeny-based crypto, we call such a graph a <a href="https://en.wikipedia.org/wiki/Supersingular_isogeny_graph"><i>supersingular isogeny graph</i></a>. I’ll skip some technical details about the construction of this graph (look for those <a href="https://eprint.iacr.org/2011/506.pdf">here</a> or <a href="http://iml.univ-mrs.fr/~kohel/pub/thesis.pdf">here</a>), but instead describe ideas about how it can be used.</p><p>As the graph is strongly connected, it is possible to <i>walk</i> a whole graph by starting from any vertex, randomly choosing an edge, following it to the next vertex and then start the process again on a new vertex. Such a way of visiting edges of this graph is called a <i>random walk.</i></p><p>The random walk is a key concept that makes isogeny based crypto feasible. When you look closely at the graph, you can notice that each vertex has a small number of edges incident to it, this is why we can compute the isogenies efficiently. But also for any vertex there is only a limited number of isogenies to choose from, which doesn’t look like good base for a cryptographic scheme. The key question is - where does the security of the scheme come from exactly? In order to get it, it is necessary to visit a couple hundred vertices. What it means in practice is that secret isogeny (of <i>large degree</i>) is constructed as a composition of multiple isogenies (of <i>small, prime degree</i>).  Which means, the secret isogeny is:</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/7pTiHpzM9xu84YbuXZozv8/40cb2052e3850cbc622f8569ac4d5ab2/CtdsWhxZs8vr7nj6LJCQhh4Mu3mP5VF5U2ayMvqZ_LVXIRBsVuduM2QwTsuy8V1izo53I5JcAFc0z6eA1LYP4FsviY4g_fqiDJc2-s8vZE_eHQGp6aQQrlhsdDDu.png" />
            
            </figure><p>This property and properties of the isogeny graph are <b>what makes</b> some of us believe that <b>scheme</b> has a good chance to be <b>secure</b><b><i>.</i></b> More specifically, there is no efficient way of finding a path that connects \( E_0 \) with \( E_n \), even with quantum computer at hand. The security level of a system depends on value <i>n</i> - the number of steps taken during the walk.</p><p>The random walk is a core process used when both generating public keys and computing shared secrets. It starts with party generating random value <i>m</i> (see more below), starting curve \(E_0\) and points P and Q on this curve. Those values are used to compute the kernel of an isogeny \( R_1 \) in the following way:</p><p>$$ R_1 = P + m \cdot Q $$</p><p>Thanks to formulas given by <a href="https://www.researchgate.net/publication/246557704_Isogenies_entre_courbes_elliptiques">Vélu</a> we can now use the point \( R_1 \) to compute the isogeny, the party will choose to move from a vertex to another one. After the isogeny \( \phi_{R_1} \) is calculated it is applied to \( E_0 \)  which results in a new curve \( E_1 \):</p><p>$$ \phi_{R_1}: E_0 \rightarrow E_1 $$</p><p>Isogeny is also applied to points P and Q. Once on \( E_1 \) the process is repeated. This process is applied <i>n</i> times, and at the end a party ends up on some curve \( E_n \) which defines isomorphism class, so also j-invariant.</p>
    <div>
      <h3>Supersingular Isogeny Diffie-Hellman</h3>
      <a href="#supersingular-isogeny-diffie-hellman">
        
      </a>
    </div>
    <p>The core idea in SIDH is to compose two random walks on an isogeny graph of elliptic curves in such a way that the end node of both ways of composing is the same.</p><p>In order to do it, scheme sets public parameters - starting curve \( E_0 \) and 2 pairs of base points on this curve <i>\( (PA,QA) \)</i> , <i>\( (PB,QB) \)</i>. Alice generates her random secret keys <i>m,</i> and calculates a secret isogeny \( \phi_q \) by performing a <i>random walk</i> as described above. The walk finishes with 3 values: elliptic curve \( E_a \) she has ended up with and pair of points \( \phi_a(PB) \) and \( \phi_a(QB) \) after pushing through Alice’s secret isogeny. Bob proceeds analogously which results in the triple \( {E_b, \phi_b(PA), \phi_b(QA)} \). The triple forms a public key which is exchanged between parties.</p><p>The picture below visualizes the operation. The black dots represent curves grouped in the same <i>isomorphism classes</i> represented by light blue circles. Alice takes the orange path ending up on a curve \( E_a \) in a separate isomorphism class than Bob after taking his dark blue path ending on \( E_b \). SIDH is parametrized in a way that Alice and Bob will always end up in different isomorphism classes.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/4coOPO3i8W2RxZpT8aS4Th/8a7f4006dec8c675ef7c81ffb2702143/pasted-image-0--5--2.png" />
            
            </figure><p>Upon receipt of triple \( { E_a, \phi_a(PB), \phi_a(QB) } \)  from Alice, Bob will use his secret value <i>m</i> to calculate a new kernel - but instead of using point \(PA\) and \(QA\) to calculate an isogeny kernel, he will now use images \( \phi_a(PB) \) and \( \phi_a(QB) \) received from Alice:</p><p>$$ R’_1 = \phi_a(PB) + m \cdot \phi_a(QB) $$</p><p>Afterwards, he uses \( R’_1 \) to start the walk again resulting in the isogeny \( \phi’_b: E_a \rightarrow E_{ab} \). Allice proceeds analogously resulting in the isogeny \(\phi’_a: E_b \rightarrow E_{ba} \). With isogenies calculated this way, both Alice and Bob will converge in the same isomorphism class. The math math may seem complicated, hopefully the picture below makes it easier to understand.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/2o7VmACLF5SYhrydaRyBRo/49b090ed60c4abdccbd6df456f833147/pasted-image-0--6--2.png" />
            
            </figure><p>Bob computes a new isogeny and starts his random walk from \( E_a \) received from Alice. He ends up on some curve \(E_{ba}\). Similarly, Alice calculates a new isogeny, applies it on \( E_b \) received from Bob and her random walk ends on some curve \(E_{ab}\). Curves \(E_{ab}\) and \(E_{ba}\) are not likely to be the same, but construction guarantees that they are isomorphic_._ As mentioned earlier, isomorphic curves have the same value of j-invariant,  hence the shared secret is a value of j-invariant \(j(E_{ab})\).</p><p>Coming back to differences between SIDH and ECDH - we can split them into four categories: the elements of the group we are operating on, the cornerstone computation required to agree on a shared secret, the elements representing secret values, and the difficult problem on which the security relies.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/4JOy8niIRMJP7yIY0hAcoE/a842ac7d3b49ff90dea78b98940f3cde/pasted-image-0--7--2.png" />
            
            </figure><p>Comparison based on Craig Costello’ s <a href="http://www.craigcostello.com.au/wp-content/uploads/Craig-isogenies-tutorial.pdf">slide deck</a>.</p><p>In ECDH there is a secret key which is an integer scalar, in case of SIDH it is a secret isogeny, which also is generated from an integer scalar. In the case of ECDH one multiplies a point on a curve by a scalar, in the case of SIDH it is a random walk in an isogeny graph. In the case of ECDH, the public key is a point on a curve, in the case of SIDH, the public part is a curve itself and the image of some points after applying isogeny. The shared secret in the case of ECDH is a point on a curve, in the case of SIDH it is a j-invariant.</p>
    <div>
      <h3>SIKE: Supersingular Isogeny Key Encapsulation</h3>
      <a href="#sike-supersingular-isogeny-key-encapsulation">
        
      </a>
    </div>
    <p>SIDH could potentially be used as a drop-in replacement of the ECDH protocol. We have actually implemented a proof-of-concept and added it to our implementation of TLS 1.3 in the <a href="http://github.com/cloudflare/tls-tris">tls-tris</a> library and described (together with Mozilla) implementation details in this <a href="https://tools.ietf.org/html/draft-kiefer-tls-ecdhe-sidh-00">draft</a>. Nevertheless, there is a problem with SIDH - the keys can be used only once. In 2016, a few researchers came up with an active <a href="https://eprint.iacr.org/2016/859">attack</a> on SIDH which works only when public keys are reused. In the context of TLS, it is not a big problem, because for each session a fresh key pair is generated (ephemeral keys), but it may not be true for other applications.</p><p>SIKE is an isogeny key encapsulation which solves this problem. Bob can generate SIKE keys, upload the public part somewhere in the Internet and then anybody can use it whenever he wants to communicate with Bob securely. SIKE reuses SIDH - internally both sides of the connection always perform SIDH key generation, SIDH key agreement and apply some other cryptographic primitives in order to convert SIDH to KEM. SIKE is implemented in a few variants - each variant corresponds to the security levels using 128-, 192- and 256-bit secret keys. Higher security level means longer running time. More details about SIKE can be found <a href="https://sike.org/">here</a>.</p><p>SIKE is also one of the candidates in NIST post-quantum "<a href="https://csrc.nist.gov/Projects/Post-Quantum-Cryptography">competition</a>".</p><p>I’ve skipped many important details to give a brief description of how isogeny based crypto works. If you’re curious and hungry for details, look at either of these Cloudflare <a href="https://www.youtube.com/watch?v=ctP24WKusX0">meetups</a>, where Deirdre Connolly talked about isogeny-based cryptography or this <a href="https://videos.2017.pqcrypto.org/school/#martindale1">talk</a> by Chloe Martindale during PQ Crypto School 2017. And if you would like to know more about quantum attacks on this scheme, I highly recommend <a href="https://eprint.iacr.org/2019/103.pdf">this</a> work.</p>
    <div>
      <h2>Conclusion</h2>
      <a href="#conclusion">
        
      </a>
    </div>
    <p>Quantum computers that can break meaningful cryptographic parameter settings do not exist, yet. They won't be built for at least the next few years. Nevertheless, they have already changed the way we look at current cryptographic deployments. There are at least two reasons it’s worth investing in PQ cryptography:</p><ul><li><p>It takes a lot of time to build secure cryptography and we don’t actually know when today’s classical cryptography will be broken. There is a need for a good mathematical base: an initial idea of what may be secure against something that doesn't exist yet. If you have an idea, you also need good implementation, constant time, resistance to things like <a href="https://www.paulkocher.com/doc/TimingAttacks.pdf">time</a> and <a href="https://www.youtube.com/watch?v=fLEjSU1a748">cache</a> <a href="https://en.wikipedia.org/wiki/Side-channel_attack">side-channels</a>, <a href="https://link.springer.com/content/pdf/10.1007%2FBFb0052259.pdf">DFA</a>, <a href="https://link.springer.com/content/pdf/10.1007%2Fs13389-011-0006-y.pdf">DPA</a>, <a href="https://en.wikipedia.org/wiki/Electromagnetic_attack">EM</a>, and a bunch of other abbreviations indicating <a href="https://csrc.nist.gov/csrc/media/events/physical-security-testing-workshop/documents/papers/physecpaper19.pdf">side-channel</a> resistance. There is also deployment of, for example, algorithms based on elliptic curves were introduced in '85, but started to really be used in production only during the last decade, 20 or so years later. Obviously, the implementation must be blazingly fast! Last, but not least, integration: we need time to develop standards to allow integration of PQ cryptography with protocols like TLS.</p></li><li><p>Even though efficient quantum computers probably won't exist for another few years, the threat is real. Data encrypted with current cryptographic algorithms can be recorded now with hopes of being broken in the future.</p></li></ul><p>Cloudflare is motivated to help build the Internet of tomorrow with the tools at hand today. Our interest is in cryptographic techniques that can be integrated into existing protocols and widely deployed on the Internet as seamlessly as possible. PQ cryptography, like the rest of cryptography, includes many cryptosystems that can be used for communications in today’s Internet; Alice and Bob need to perform some computation, but they do not need to buy new hardware to do that.</p><p>Cloudflare sees great potential in those algorithms and believes that some of them can be used as a safe replacement for classical public-key cryptosystems. Time will tell if we’re justified in this belief!</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/6eUX7xZqv0SKXlOXdRzbVM/a72e8969c4e1f1e5c6e8a3fc665af342/crypto-week-2019-header-circle_2x-2.png" />
            
            </figure><p></p> ]]></content:encoded>
            <category><![CDATA[Crypto Week]]></category>
            <category><![CDATA[Cryptography]]></category>
            <category><![CDATA[Security]]></category>
            <category><![CDATA[Product News]]></category>
            <category><![CDATA[TLS]]></category>
            <category><![CDATA[Deep Dive]]></category>
            <guid isPermaLink="false">3mpA8KK37HTvhRuZrsBvUy</guid>
            <dc:creator>Kris Kwiatkowski</dc:creator>
        </item>
        <item>
            <title><![CDATA[Introducing CIRCL: An Advanced Cryptographic Library]]></title>
            <link>https://blog.cloudflare.com/introducing-circl/</link>
            <pubDate>Thu, 20 Jun 2019 13:00:00 GMT</pubDate>
            <description><![CDATA[ Today we are proud to release the source code of a cryptographic library we’ve been working on:  a collection of cryptographic primitives written in Go, called CIRCL.  ]]></description>
            <content:encoded><![CDATA[ 
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/6b0YmeXVekCfEaADp0Kcp3/b0cbfa18736d7ffce6e5e2b6d04126da/circl-header_2x-1.png" />
            
            </figure><p>As part of <a href="/welcome-to-crypto-week-2019/">Crypto Week 2019</a>, today we are proud to release the source code of a cryptographic library we’ve been working on: a collection of cryptographic primitives written in Go, called <a href="http://github.com/cloudflare/circl">CIRCL</a>. This library includes a set of packages that target cryptographic algorithms for post-quantum (PQ), elliptic curve cryptography, and hash functions for prime groups. Our hope is that it’s useful for a broad audience. Get ready to discover how we made CIRCL unique.</p>
    <div>
      <h3>Cryptography in Go</h3>
      <a href="#cryptography-in-go">
        
      </a>
    </div>
    <p>We use Go a lot at Cloudflare. It offers a good balance between ease of use and performance; the learning curve is very light, and after a short time, any programmer can get good at writing fast, lightweight backend services. And thanks to the possibility of implementing performance critical parts in <a href="https://golang.org/doc/asm">Go assembly</a>, we can try to ‘squeeze the machine’ and get every bit of performance.</p><p>Cloudflare’s cryptography team designs and maintains security-critical projects. It's not a secret that security is hard. That's why, we are introducing the Cloudflare Interoperable Reusable Cryptographic Library - CIRCL. There are multiple goals behind CIRCL. First, we want to concentrate our efforts to implement cryptographic primitives in a single place. This makes it easier to ensure that proper engineering processes are followed. Second, Cloudflare is an active member of the Internet community - we are trying to improve and propose standards to help make the Internet a better place.</p><p>Cloudflare's mission is to help build a better Internet. For this reason, we want CIRCL helps the cryptographic community to create proof of concepts, like the <a href="/towards-post-quantum-cryptography-in-TLS">post-quantum TLS experiments</a> we are doing. Over the years, lots of ideas have been put on the table by cryptographers (for example, homomorphic encryption, multi-party computation, and privacy preserving constructions). Recently, we’ve seen those concepts picked up and exercised in a variety of contexts. CIRCL’s implementations of cryptographic primitives creates a powerful toolbox for developers wishing to use them.</p><p>The Go language provides native packages for several well-known cryptographic algorithms, such as key agreement algorithms, hash functions, and digital signatures. There are also packages maintained by the community under <a href="http://golang.org/x/crypto"><i>golang.org/x/crypto</i></a> that provide a diverse set of algorithms for supporting <a href="https://en.wikipedia.org/wiki/Authenticated_encryption">authenticated encryption</a>, <a href="https://en.wikipedia.org/wiki/Stream_cipher">stream ciphers</a>, <a href="https://en.wikipedia.org/wiki/Key_derivation_function">key derivation functions</a>, and <a href="https://en.wikipedia.org/wiki/Pairing-based_cryptography">bilinear pairings</a>. CIRCL doesn’t try to compete with <a href="http://golang.org/x/crypto"><i>golang.org/x/crypto</i></a> in any sense. Our goal is to provide a complementary set of implementations that are more aggressively optimized, or may be less commonly used but have a good chance at being very useful in the future.</p>
    <div>
      <h3>Unboxing CIRCL</h3>
      <a href="#unboxing-circl">
        
      </a>
    </div>
    <p>Our cryptography team worked on a fresh proposal to augment the capabilities of Go users with a new set of packages.  You can get them by typing:</p><p><code>$ go get github.com/cloudflare/circl</code></p><p>The contents of CIRCL is split across different categories, summarized in this table:</p><table>
  <tr>
    <th>Category</th>
    <th>Algorithms</th> 
    <th>Description</th> 
    <th>Applications</th>
  </tr>
  <tr>
    <td>Post-Quantum Cryptography</td>
    <td>SIDH</td> 
    <td>Isogeny-based cryptography. </td>
    <td>SIDH provides key exchange mechanisms using ephemeral keys. </td>
  </tr>
  <tr>
    <td>SIKE</td> 
    <td>SIKE is a key encapsulation mechanism (KEM).</td> 
    <td>Key agreement protocols.</td>
  </tr>
  <tr>
    <td>Key Exchange</td>
    <td>X25519, X448</td> 
    <td><a href="https://tools.ietf.org/html/rfc7748">RFC-7748</a> provides new key exchange mechanisms based on Montgomery elliptic curves.</td> 
    <td><a href="http://staging.blog.mrk.cfdata.org/introducing-tls-1-3/">TLS 1.3.</a> Secure Shell.</td>
  </tr>
  <tr>
    <td>FourQ</td> 
    <td>One of the fastest elliptic curves at 128-bit security level.</td> 
    <td>Experimental for <a href="https://tools.ietf.org/id/draft-ladd-cfrg-4q-01.html">key agreement</a> and <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2016/07/SchnorrQ.pdf"> digital signatures</a>.</td>
  </tr>
  <tr>
    <td>Digital Signatures</td>
    <td>Ed25519</td> 
    <td><a href="https://tools.ietf.org/html/rfc8032">RFC-8032</a> provides new digital signature algorithms based on twisted Edwards curves.</td> 
    <td><a href="https://tools.ietf.org/html/rfc8410">Digital certificates</a> and authentication methods.</td>
  </tr>
  <tr>
    <td>Hash to Elliptic Curve Groups</td>
    <td>Several algorithms: Elligator2, Ristretto, SWU, Icart.</td> 
    <td>Protocols based on elliptic curves require hash functions that map bit strings to points on an elliptic curve. </td> 
    <td>Useful in protocols such as <a href="http://staging.blog.mrk.cfdata.org/privacy-pass-the-math/">Privacy Pass.</a> <a href="https://eprint.iacr.org/2018/163">OPAQUE.</a>
PAKE.
<a href="https://datatracker.ietf.org/doc/draft-irtf-cfrg-vrf/">Verifiable random functions.</a></td>
  </tr>
  <tr>
    <td>Optimization</td>
    <td>Curve P-384</td> 
    <td>Our optimizations reduce the burden when moving from P-256 to P-384.</td> 
    <td>ECDSA and ECDH using Suite B at top secret level.</td>
  </tr>
</table>
    <div>
      <h3>SIKE, a Post-Quantum Key Encapsulation Mechanism</h3>
      <a href="#sike-a-post-quantum-key-encapsulation-mechanism">
        
      </a>
    </div>
    <p>To better understand the post-quantum world, we started experimenting with post-quantum key exchange schemes and using them for key agreement in TLS 1.3. CIRCL contains the sidh <a href="https://github.com/cloudflare/circl/tree/master/dh/sidh">package</a>, an implementation of Supersingular Isogeny-based Diffie-Hellman (SIDH), as well as <a href="https://en.wikipedia.org/wiki/Ciphertext_indistinguishability">CCA2-secure</a> Supersingular Isogeny-based Key Encapsulation (SIKE), which is based on SIDH.</p><p>CIRCL makes playing with PQ key agreement very easy. Below is an example of the SIKE interface that can be used to establish a shared secret between two parties for use in symmetric encryption. The example uses a key encapsulation mechanism (KEM). For our example in this scheme, Alice generates a random secret key, and then uses Bob’s pre-generated public key to encrypt (encapsulate) it. The resulting ciphertext is sent to Bob. Then, Bob uses his private key to decrypt (decapsulate) the ciphertext and retrieve the secret key. See more details about SIKE in this Cloudflare <a href="/towards-post-quantum-cryptography-in-TLS">blog</a>.</p><p>Let's see how to do this with CIRCL:</p>
            <pre><code>// Bob's key pair
prvB := NewPrivateKey(Fp503, KeyVariantSike)
pubB := NewPublicKey(Fp503, KeyVariantSike)

// Generate private key
prvB.Generate(rand.Reader)
// Generate public key
prvB.GeneratePublicKey(pubB)

var publicKeyBytes = make([]array, pubB.Size())
var privateKeyBytes = make([]array, prvB.Size())

pubB.Export(publicKeyBytes)
prvB.Export(privateKeyBytes)

// Encode public key to JSON
// Save privateKeyBytes on disk</code></pre>
            <p>Bob uploads the public key to a location accessible by anybody. When Alice wants to establish a shared secret with Bob, she performs encapsulation that results in two parts: a shared secret and the result of the encapsulation, the ciphertext.</p>
            <pre><code>// Read JSON to bytes

// Alice's key pair
pubB := NewPublicKey(Fp503, KeyVariantSike)
pubB.Import(publicKeyBytes)

var kem := sike.NewSike503(rand.Reader)
kem.Encapsulate(ciphertext, sharedSecret, pubB)

// send ciphertext to Bob</code></pre>
            <p>Bob now receives ciphertext from Alice and decapsulates the shared secret:</p>
            <pre><code>var kem := sike.NewSike503(rand.Reader)
kem.Decapsulate(sharedSecret, prvB, pubA, ciphertext)  </code></pre>
            <p>At this point, both Alice and Bob can derive a symmetric encryption key from the secret generated.</p><p>SIKE implementation contains:</p><ul><li><p>Two different field sizes: Fp503 and Fp751. The choice of the field is a trade-off between performance and security.</p></li><li><p>Code optimized for AMD64 and ARM64 architectures, as well as generic Go code. For AMD64, we detect the micro-architecture and if it’s recent enough (e.g., it supports ADOX/ADCX and BMI2 instruction sets), we use different multiplication techniques to make an execution even faster.</p></li><li><p>Code implemented in constant time, that is, the execution time doesn’t depend on secret values.</p></li></ul><p>We also took care of low heap-memory footprint, so that the implementation uses a minimal amount of dynamically allocated memory. In the future, we plan to provide multiple implementations of post-quantum schemes. Currently, our focus is on algorithms useful for <a href="/towards-post-quantum-cryptography-in-TLS">key exchange in TLS</a>.</p><p>SIDH/SIKE are interesting because the key sizes produced by those algorithms are relatively small (comparing with other PQ schemes). Nevertheless, performance is not all that great yet, so we’ll continue looking. We plan to add lattice-based algorithms, such as <a href="https://ntru-hrss.org/">NTRU-HRSS</a> and <a href="https://pq-crystals.org/kyber/">Kyber</a>, to CIRCL. We will also add another more experimental algorithm called cSIDH, which we would like to try in other applications. CIRCL doesn’t currently contain any post-quantum signature algorithms, which is also on our to-do list. After our experiment with TLS key exchange completes, we’re going to look at post-quantum PKI. But that’s a topic for a future blog post, so stay tuned.</p><p>Last, we must admit that our code is largely based on the implementation from the <a href="https://csrc.nist.gov/CSRC/media/Projects/Post-Quantum-Cryptography/documents/round-1/submissions/SIKE.zip">NIST submission</a> along with the work of former intern <a href="/sidh-go/">Henry De Valence</a>, and we would like to thank both Henry and the SIKE team for their great work.</p>
    <div>
      <h3>Elliptic Curve Cryptography</h3>
      <a href="#elliptic-curve-cryptography">
        
      </a>
    </div>
    <p>Elliptic curve cryptography brings short keys sizes and faster evaluation of operations when compared to algorithms based on RSA. <a href="/a-relatively-easy-to-understand-primer-on-elliptic-curve-cryptography/">Elliptic curves</a> were standardized during the early 2000s, and have recently gained popularity as they are a more efficient way for securing communications.</p><p>Elliptic curves are used in almost every project at Cloudflare, not only for establishing TLS connections, but also for certificate validation, certificate revocation (OCSP), <a href="/privacy-pass-the-math/">Privacy Pass</a>, <a href="/introducing-certificate-transparency-and-nimbus/">certificate transparency</a>, and <a href="/real-urls-for-amp-cached-content-using-cloudflare-workers/">AMP Real URL</a>.</p><p>The Go language provides native support for NIST-standardized curves, the most popular of which is <a href="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf">P-256</a>. In a previous post, <a href="/go-crypto-bridging-the-performance-gap/">Vlad Krasnov</a> described the relevance of optimizing several cryptographic algorithms, including P-256 curve. When working at Cloudflare scale, little issues around performance are significantly magnified. This is one reason why Cloudflare pushes the boundaries of efficiency.</p><p>A similar thing happened on the chained <a href="/universal-ssl-encryption-all-the-way-to-the-origin-for-free/">validation</a> of certificates. For some certificates, we observed performance issues when validating a chain of certificates. Our team successfully diagnosed this issue: certificates which had signatures from the <a href="https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf">P-384</a> curve, which is the curve that corresponds to the 192-bit security level, were taking up 99% of CPU time! It is common for certificates closer to the root of the chain of trust to rely on stronger security assumptions, for example, using larger elliptic curves. Our first-aid reaction comes in the form of an optimized implementation written by <a href="https://github.com/bren2010/p384">Brendan McMillion</a> that reduced the time of performing elliptic curve operations by a factor of 10. The code for P-384 is also available in CIRCL.</p><p>The latest developments in elliptic curve cryptography have caused a shift to use elliptic curve models with faster arithmetic operations. The best example is undoubtedly <a href="https://cr.yp.to/ecdh.html">Curve25519</a>; other examples are the Goldilocks and FourQ curves. CIRCL supports all of these curves, allowing instantiation of Diffie-Hellman exchanges and Edwards digital signatures. Although it slightly overlaps the Go native libraries, CIRCL has architecture-dependent optimizations.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/01zfosDYyaqzR6Lqu0Tshi/f5d0b4947d44ac2457a45fb5002e2268/imageLikeEmbed--3-.png" />
            
            </figure>
    <div>
      <h3>Hashing to Groups</h3>
      <a href="#hashing-to-groups">
        
      </a>
    </div>
    <p>Many cryptographic protocols rely on the hardness of solving the Discrete Logarithm Problem (DLP) in special groups, one of which is the integers reduced modulo a large integer. To guarantee that the DLP is hard to solve, the modulus must be a large prime number. Increasing its size boosts on security, but also makes operations more expensive. A better approach is using elliptic curve groups since they provide faster operations.</p><p>In some cryptographic protocols, it is common to use a function with the <a href="https://en.wikipedia.org/wiki/Cryptographic_hash_function">properties</a> of a cryptographic hash function that maps bit strings into elements of the group. This is easy to accomplish when, for example, the group is the set of integers modulo a large prime. However, it is not so clear how to perform this function using elliptic curves. In cryptographic literature, several methods have been proposed using the terms <i>hashing to curves</i> or <i>hashing to point</i> indistinctly.</p><p>The main issue is that there is no general method for deterministically finding points on any elliptic curve, the closest available are methods that target special curves and parameters. This is a problem for implementers of cryptographic algorithms, who have a hard time figuring out on a suitable method for hashing to points of an elliptic curve. Compounding that, chances of doing this wrong are high. There are many different methods, elliptic curves, and security considerations to analyze. For example, a <a href="https://wpa3.mathyvanhoef.com/">vulnerability</a> on WPA3 handshake protocol exploited a non-constant time hashing method resulting in a recovery of keys. Currently, an <a href="https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/">IETF draft</a> is tracking work in-progress that provides hashing methods unifying requirements with curves and their parameters.</p><p>Corresponding to this problem, CIRCL will include implementations of hashing methods for elliptic curves. Our development is accompanying the evolution of the IEFT draft. Therefore, users of CIRCL will have this added value as the methods implement a ready-to-go functionality, covering the needs of some cryptographic protocols.</p>
    <div>
      <h3>Update on Bilinear Pairings</h3>
      <a href="#update-on-bilinear-pairings">
        
      </a>
    </div>
    <p>Bilinear pairings are sometimes regarded as a tool for cryptanalysis, however pairings can also be used in a constructive way by allowing instantiation of advanced public-key algorithms, for example, identity-based encryption, attribute-based encryption, blind digital signatures, three-party key agreement, among others.</p><p>An efficient way to instantiate a bilinear pairing is to use elliptic curves. Note that only a special class of curves can be used, thus so-called <i>pairing-friendly</i> curves have specific properties that enable the efficient evaluation of a pairing.</p><p>Some families of pairing-friendly curves were introduced by Barreto-Naehrig (<a href="https://doi.org/10.1007/11693383_22">BN</a>), Kachisa-Schaefer-Scott (<a href="https://doi.org/10.1007/978-3-540-85538-5_9">KSS</a>), and Barreto-Lynn-Scott (<a href="https://doi.org/10.1007/3-540-36413-7_19">BLS</a>). BN256 is a BN curve using a 256-bit prime and is one of the fastest options for implementing a bilinear pairing. The Go native library supports this curve in the package <a href="https://godoc.org/golang.org/x/crypto/bn256">golang.org/x/crypto/bn256</a>. In fact, the BN256 curve is used by Cloudflare’s <a href="/geo-key-manager-how-it-works/">Geo Key Manager</a>, which allows distributing encrypted keys around the world. At Cloudflare, high-performance is a must and with this motivation, in 2017, we released an optimized implementation of the BN256 package that is <a href="https://github.com/cloudflare/bn256">8x faster</a> than the Go’s native package. The success of these optimizations reached several other projects such as the <a href="https://github.com/ethereum/go-ethereum/blob/master/core/vm/contracts.go">Ethereum protocol</a> and the <a href="/league-of-entropy/">Randomness</a> <a href="/inside-the-entropy/">Beacon</a> project.</p><p>Recent <a href="https://eprint.iacr.org/2015/1027">improvements</a> in solving the DLP over extension fields, GF(pᵐ) for p prime and m&gt;1, impacted the security of pairings, causing recalculation of the parameters used for pairing-friendly curves.</p><p>Before these discoveries, the BN256 curve provided a 128-bit security level, but now larger primes are needed to target the same security level. That does not mean that the BN256 curve has been broken, since BN256 gives a security of <a href="https://eprint.iacr.org/2017/334">100 bits</a>, that is, approximately 2¹⁰⁰ operations are required to cause a real danger, which is still unfeasible with current computing power.</p><p>With our CIRCL announcement, we want to announce our plans for research and development to obtain efficient curve(s) to become a stronger successor of BN256. According to the estimation by <a href="http://doi.org/10.1007/s00145-018-9280-5">Barbulescu-Duquesne</a>, a BN curve must use primes of at least 456 bits to match a 128-bit security level. However, the impact on the recalculation of parameters brings back to the main scene BLS and KSS curves as efficient alternatives. To this end a <a href="https://datatracker.ietf.org/doc/draft-yonezawa-pairing-friendly-curves/">standardization effort</a> at IEFT is in progress with the aim of defining parameters and pairing-friendly curves that match different security levels.</p><p>Note that regardless of the curve(s) chosen, there is an unavoidable performance downgrade when moving from BN256 to a stronger curve. Actual timings were presented by <a href="https://ecc2017.cs.ru.nl/slides/ecc2017-aranha.pdf">Aranha</a>, who described the evolution of the race for high-performance pairing implementations. The purpose of our continuous development of CIRCL is to minimize this impact through fast implementations.</p>
    <div>
      <h3>Optimizations</h3>
      <a href="#optimizations">
        
      </a>
    </div>
    <p>Go itself is a very easy to learn and use for system programming and yet makes it possible to use assembly so that you can stay close “to the metal”. We have blogged about improving performance in Go few times in the past (see these posts about <a href="/how-expensive-is-crypto-anyway/">encryption</a>, <a href="/go-crypto-bridging-the-performance-gap/">ciphersuites</a>, and <a href="/neon-is-the-new-black/">image encoding</a>).</p><p>When developing CIRCL, we crafted the code to get the best possible performance from the machine. We leverage the capabilities provided by the architecture and the architecture-specific instructions. This means that in some cases we need to get our hands dirty and rewrite parts of the software in Go assembly, which is not easy, but definitely worth the effort when it comes to performance. We focused on x86-64, as this is our main target, but we also think that it’s <a href="/arm-takes-wing/">worth looking at ARM architecture</a>, and in some cases (like SIDH or P-384), CIRCL has optimized code for this platform.</p><p>We also try to ensure that code uses memory efficiently - crafting it in a way that fast allocations on the stack are preferred over expensive heap allocations. In cases where heap allocation is needed, we tried to design the APIs in a way that, they allow pre-allocating memory ahead of time and reuse it for multiple operations.</p>
    <div>
      <h3>Security</h3>
      <a href="#security">
        
      </a>
    </div>
    <p>The CIRCL library is offered as-is, and without a guarantee. Therefore, it is expected that changes in the code, repository, and API occur in the future. We recommend to take caution before using this library in a production application since part of its content is experimental.</p><p>As new attacks and vulnerabilities arise over the time, security of software should be treated as a continuous process. In particular, the assessment of cryptographic software is critical, it requires the expertise of several fields, not only computer science. Cryptography engineers must be aware of the latest vulnerabilities and methods of attack in order to defend against them.</p><p>The development of CIRCL follows best practices on the secure development. For example, if time execution of the code depends on secret data, the attacker could leverage those irregularities and recover secret keys. In our code, we take care of writing constant-time code and hence prevent timing based attacks.</p><p>Developers of cryptographic software must also be aware of optimizations performed by the compiler and/or the <a href="https://meltdownattack.com/">processor</a> since these optimizations can lead to insecure binary codes in some cases. All of these issues could be exploited in real attacks aimed at compromising systems and keys. Therefore, software changes must be tracked down through thorough code reviews. Also static analyzers and automated testing tools play an important role on the security of the software.</p>
    <div>
      <h3>Summary</h3>
      <a href="#summary">
        
      </a>
    </div>
    <p>CIRCL is envisioned as an effective tool for experimenting with modern cryptographic algorithms yet providing high-performance implementations. Today is marked as the starting point of a continuous machinery of innovation and retribution to the community in the form of a cryptographic library. There are still several other applications such as homomorphic encryption, multi-party computation, and privacy-preserving protocols that we would like to explore.</p><p>We are team of cryptography, security, and software engineers working to improve and augment Cloudflare products. Our team keeps the communication channels open for receiving comments, including improvements, and merging contributions. We welcome opinions and contributions! If you would like to get in contact, you should check out our github repository for CIRCL <a href="https://github.com/cloudflare/circl">github.com/cloudflare/circl</a>. We want to share our work and hope it makes someone else’s job easier as well.</p><p>Finally, special thanks to all the contributors who has either directly or indirectly helped to implement the library - Ko Stoffelen, Brendan McMillion, Henry de Valence, Michael McLoughlin and all the people who invested their time in reviewing our code.</p>
            <figure>
            
            <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/58PegOxcmXcRhZLgq36KqR/14e8ebfa42a7b425cb055afd9a0ca8f0/crypto-week-2019-header-circle_2x-1.png" />
            
            </figure> ]]></content:encoded>
            <category><![CDATA[Crypto Week]]></category>
            <category><![CDATA[Cryptography]]></category>
            <category><![CDATA[Product News]]></category>
            <category><![CDATA[Security]]></category>
            <category><![CDATA[Elliptic Curves]]></category>
            <category><![CDATA[TLS]]></category>
            <category><![CDATA[Research]]></category>
            <guid isPermaLink="false">3JsbElNXCgx49YgvgUTvsL</guid>
            <dc:creator>Kris Kwiatkowski</dc:creator>
            <dc:creator>Armando Faz-Hernández</dc:creator>
        </item>
    </channel>
</rss>