<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>rosenblog</title>
      <link>https://mrosenberg.pub</link>
      <description></description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://mrosenberg.pub/feed.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Wed, 23 Sep 2020 01:17:00 +0000</lastBuildDate>
      <item>
          <title>A Bookmarklet to Download Zoom Recordings</title>
          <pubDate>Tue, 15 Sep 2020 15:41:00 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/zoom/</link>
          <guid>https://mrosenberg.pub/blog/zoom/</guid>
          <description>&lt;p&gt;&lt;strong&gt;Update (Sep. 23, 2020):&lt;&#x2F;strong&gt; Zoom disabled right-click on their video sites. I&#x27;ve updated the script to re-enable right-click :)&lt;&#x2F;p&gt;
&lt;h1 id=&quot;overview&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#overview&quot; aria-label=&quot;Anchor link for: overview&quot;&gt;§&lt;&#x2F;a&gt;
Overview&lt;&#x2F;h1&gt;
&lt;p&gt;This is a &lt;em&gt;bookmarklet&lt;&#x2F;em&gt; (that is, a bookmark with script inside) that lets you download recorded Zoom calls from the Zoom cloud, regardless of whether the owner has downloads enabled. If it&#x27;s visible to you, you can download it.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;why&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#why&quot; aria-label=&quot;Anchor link for: why&quot;&gt;§&lt;&#x2F;a&gt;
Why&lt;&#x2F;h1&gt;
&lt;p&gt;I like to watch lectures in the park, where there is no WiFi. So now I download the lectures in advance and take them wherever I go.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;installation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#installation&quot; aria-label=&quot;Anchor link for: installation&quot;&gt;§&lt;&#x2F;a&gt;
Installation&lt;&#x2F;h1&gt;
&lt;p&gt;Right click the link below and select &amp;quot;Bookmark This Link&amp;quot;. Put the bookmark wherever you want.&lt;br &#x2F;&gt;&lt;br &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&#x27;
javascript:(function(){
const download_link_id = &quot;__zoomdl_link&quot;;
if (!window.location.hostname.endsWith(&quot;zoom.us&quot;)
    || document.getElementById(download_link_id)) {
    return;
}
const video_url = document.getElementById(&quot;vjs_video_3_html5_api&quot;).src;
var download_link = document.createElement(&quot;a&quot;);
download_link.id = download_link_id;
download_link.href = video_url;
download_link.innerHTML = &quot;Download Video (right click → Save Link As)&quot;;
download_link.style = &quot;font-weight: bold&quot;;
download_link.onclick = function() { return false; };
var container = document.getElementsByClassName(&quot;main&quot;)[0];
container.prepend(download_link);
function enableContextMenu(aggressive = false) {
    void(document.ondragstart = null);
    void(document.onselectstart = null);
    void(document.onclick = null);
    void(document.onmousedown = null);
    void(document.onmouseup = null);
    void(document.body.oncontextmenu = null);
    enableRightClickLight(document);
    if (aggressive) {
        enableRightClick(document);
        removeContextMenuOnAll(&quot;body&quot;);
        removeContextMenuOnAll(&quot;img&quot;);
        removeContextMenuOnAll(&quot;td&quot;);
    }
}
function removeContextMenuOnAll(tagName) {
    var elements = document.getElementsByTagName(tagName);
    for (var i = 0; i &lt; elements.length; i++) {
        enableRightClick(elements[i]);
    }
}
function enableRightClickLight(el) {
    el || (el = document);
    el.addEventListener(&quot;contextmenu&quot;, bringBackDefault, true);
}
function enableRightClick(el) {
    el || (el = document);
    el.addEventListener(&quot;contextmenu&quot;, bringBackDefault, true);
    el.addEventListener(&quot;dragstart&quot;, bringBackDefault, true);
    el.addEventListener(&quot;selectstart&quot;, bringBackDefault, true);
    el.addEventListener(&quot;click&quot;, bringBackDefault, true);
    el.addEventListener(&quot;mousedown&quot;, bringBackDefault, true);
    el.addEventListener(&quot;mouseup&quot;, bringBackDefault, true);
}
function restoreRightClick(el) {
    el || (el = document);
    el.removeEventListener(&quot;contextmenu&quot;, bringBackDefault, true);
    el.removeEventListener(&quot;dragstart&quot;, bringBackDefault, true);
    el.removeEventListener(&quot;selectstart&quot;, bringBackDefault, true);
    el.removeEventListener(&quot;click&quot;, bringBackDefault, true);
    el.removeEventListener(&quot;mousedown&quot;, bringBackDefault, true);
    el.removeEventListener(&quot;mouseup&quot;, bringBackDefault, true);
}
function bringBackDefault(event) {
    event.returnValue = true;
    (typeof event.stopPropagation === &quot;function&quot;) &amp;&amp; event.stopPropagation();
    (typeof event.cancelBubble === &quot;function&quot;) &amp;&amp; event.cancelBubble();
}
enableContextMenu();
})();
&#x27;&gt;
Zoom Rec. ⬇️
&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;how-to-use&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-to-use&quot; aria-label=&quot;Anchor link for: how-to-use&quot;&gt;§&lt;&#x2F;a&gt;
How to Use&lt;&#x2F;h1&gt;
&lt;ol&gt;
&lt;li&gt;When you&#x27;re on the Zoom website, watching a recorded Zoom call, click the Zoom Rec. ⬇️ bookmarklet&lt;&#x2F;li&gt;
&lt;li&gt;A link will appear at the top of the page telling you to right click it&lt;&#x2F;li&gt;
&lt;li&gt;Right click the link, select &amp;quot;Save Link As&amp;quot;, and save the video file onto your computer&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h1 id=&quot;source-code-and-license&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#source-code-and-license&quot; aria-label=&quot;Anchor link for: source-code-and-license&quot;&gt;§&lt;&#x2F;a&gt;
Source Code and License&lt;&#x2F;h1&gt;
&lt;p&gt;Source code and license are available on the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rozbb&#x2F;zoomdl-bookmarklet&quot;&gt;Github page&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Hash Functions are not (Quantum) Random Oracles, but only Technically</title>
          <pubDate>Sun, 01 Mar 2020 00:00:00 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/qrom/</link>
          <guid>https://mrosenberg.pub/blog/qrom/</guid>
          <description>&lt;p&gt;&lt;em&gt;This post is part of a &lt;a href=&quot;&#x2F;assets&#x2F;pdfs&#x2F;qrom_survey.pdf&quot;&gt;survey&lt;&#x2F;a&gt; I co-wrote with &lt;a href=&quot;https:&#x2F;&#x2F;www.cs.umd.edu&#x2F;~erblum&#x2F;&quot;&gt;Erica Blum&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;llamakana.github.io&#x2F;&quot;&gt;Makana Castillo-Martin&lt;&#x2F;a&gt; for a quantum computation class at the University of Maryland in Fall 2019.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;In this post, we define the Random Oracle Model (ROM) and the Quantum ROM (QROM), and give some examples of their uses and their flaws. We show that the QROM is unsound in the same way that the ROM is, and we conclude that that&#x27;s OK.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;definitions-and-notation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#definitions-and-notation&quot; aria-label=&quot;Anchor link for: definitions-and-notation&quot;&gt;§&lt;&#x2F;a&gt;
Definitions and Notation&lt;&#x2F;h1&gt;
&lt;p&gt;I really don&#x27;t know what background to assume, but to balance comprehensibility and length of post, I&#x27;ve just chosen the things that I had to remind myself about when writing this.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;turing-machines&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#turing-machines&quot; aria-label=&quot;Anchor link for: turing-machines&quot;&gt;§&lt;&#x2F;a&gt;
Turing Machines&lt;&#x2F;h2&gt;
&lt;p&gt;You can imagine Turing Machines as abstract machines that run programs specified by some programming language. Like your computer!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;random-oracles&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#random-oracles&quot; aria-label=&quot;Anchor link for: random-oracles&quot;&gt;§&lt;&#x2F;a&gt;
Random Oracles&lt;&#x2F;h2&gt;
&lt;p&gt;An &lt;strong&gt;oracle&lt;&#x2F;strong&gt; is an abstraction—a black box—which Turing Machines can query and get a response from. I say &amp;quot;black box&amp;quot; and not &amp;quot;Turing Machine program,&amp;quot; for example, because an oracle is not necessarily a program that can be written down. Rather, it is an abstraction whose inner workings we have no information about. So when we talk about an oracle behaving a certain way, we are describing what kinds of outputs it gives in response to certain inputs, not how the oracle functions internally. When we want to express that a Turing Machine $\mathcal{A}$ has access to an oracle $\mathcal{O}$, we write $\mathcal{A}^\mathcal{O}$. This means that $\mathcal{A}$ can call $\mathcal{O}(x)$ on any input $x$ it pleases.&lt;&#x2F;p&gt;
&lt;div class=&quot;math-def&quot;&gt;
&lt;p&gt;&lt;strong&gt;Definition (informal):&lt;&#x2F;strong&gt; A &lt;strong&gt;random oracle&lt;&#x2F;strong&gt; in a cryptosystem is a publicly accessible oracle (i.e., all parties can query it) which produces random and consistent responses. &amp;quot;Random&amp;quot; means that, until the oracle is queried for the first time on a given input, every possible response is equally likely. &amp;quot;Consistent&amp;quot; means that $\mathcal{O}$ always returns the same value on a given input.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;Notice that implementing a random oracle is hard. You would have to construct a table that contains the output for every possible input. This table would be massive, so when we have to simulate a random oracle in practice, we normally do all this on the fly. That is, for each new input, we generate a new random value and save it in a table along with the input. This way, the oracle can respond consistently to previously seen queries.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;turing-reductions&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#turing-reductions&quot; aria-label=&quot;Anchor link for: turing-reductions&quot;&gt;§&lt;&#x2F;a&gt;
Turing Reductions&lt;&#x2F;h2&gt;
&lt;p&gt;It&#x27;s worth it to go over the definition of Turing reduction here, because the purpose of the random oracle model is to permit reductions that were not previously possible (as far as we&#x27;re aware).&lt;&#x2F;p&gt;
&lt;div class=&quot;math-def&quot;&gt;
&lt;p&gt;&lt;strong&gt;Definition:&lt;&#x2F;strong&gt; A &lt;strong&gt;Turing Reduction&lt;&#x2F;strong&gt; from problem $X$ to problem $Y$ is a Turing Machine $\mathcal{A}$ such that, if $\mathcal{A}$ is given access to a Turing Machine $\mathcal{Y}$ which solves $Y$, then $\mathcal{A}^\mathcal{Y}$ can efficiently&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#efficient&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; solve $X$. We say &amp;quot;$X$ &lt;strong&gt;reduces to&lt;&#x2F;strong&gt; $Y$&amp;quot;, or &amp;quot;$X \leq Y$&amp;quot; if and only if such a machine $\mathcal{A}$ exists.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;In this definition, we take &amp;quot;problem&amp;quot; to mean a question of the form &amp;quot;does this thing satisfy relation $R$&amp;quot; or &amp;quot;what is a thing that makes this satisfy relation $R$&amp;quot;. Examples are&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Given an integer $N$, what is a prime number that divides $N$? The relation here is
$$
R = {(N, p) : p \textrm{ prime} \wedge p \mid N }
$$&lt;&#x2F;li&gt;
&lt;li&gt;Given a polynomial $P$ and a value $x$, is $x$ a root of $P$? The relation here is
$$
R = {(P, x) : P(x) = 0}
$$&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;the-random-oracle-model&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-random-oracle-model&quot; aria-label=&quot;Anchor link for: the-random-oracle-model&quot;&gt;§&lt;&#x2F;a&gt;
The Random Oracle Model&lt;&#x2F;h1&gt;
&lt;p&gt;The Random Oracle Model (introduced in 1993 by &lt;a href=&quot;https:&#x2F;&#x2F;cseweb.ucsd.edu&#x2F;~mihir&#x2F;papers&#x2F;ro.pdf&quot;&gt;Bellare and Rogaway&lt;&#x2F;a&gt;) was invented as a response to a schism in the cryptographic community in the 1990s: practitioners were implementing all kinds of cryptographic protocols which used hash functions, while theoreticians had no way of proving that these schemes were secure. The aim of the ROM was to bridge this gap by formalizing a small assumption that many were making anyway: hash functions appear to behave randomly. Actually describing what &amp;quot;appear to behave randomly&amp;quot; means is more of an exercise in philosophy than math, so we&#x27;ll leave that out.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#randomly&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; But the gist of the formalization is captured in the following definition:&lt;&#x2F;p&gt;
&lt;div class=&quot;math-thm&quot;&gt;
&lt;p&gt;&lt;strong&gt;Definition (informal):&lt;&#x2F;strong&gt; We say that &lt;strong&gt;$X$ reduces to $Y$ in the ROM&lt;&#x2F;strong&gt; if and only if there is a reduction from $X$ to $Y&#x27;$, where $Y&#x27;$ is the same problem as $Y$ but with every hash function replaced with a random oracle.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;Take note of what is not being said: &lt;strong&gt;no claim is ever made that a reduction which holds in the ROM necessarily holds when hash functions are used instead of random oracles&lt;&#x2F;strong&gt;. Accordingly, and appropriately, &lt;strong&gt;the ROM is considered a heuristic&lt;&#x2F;strong&gt; for cryptosystems which use hash functions; it does not necessarily prove anything about the scheme with hashes. Rogaway and Bellare go out of their way to state precisely this in their introduction of the ROM:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;In order to bring to practice some of the benefits of provable security, it makes sense to incorporate into our models objects which capture the properties that practical primitives really seem to possess, and view these objects as basic even if the assumptions about them are, from a theoretical point of view, very strong...We stress that the proof is in the random oracle model and the last step is heuristic in nature. It is a thesis of this paper that significant assurance benefits nonetheless remain.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Innumerably many cryptosystems have been proven secure in the ROM (where &amp;quot;proven secure&amp;quot; means &amp;quot;reduced from a problem believed to be hard&amp;quot;). The &lt;a href=&quot;https:&#x2F;&#x2F;bristolcrypto.blogspot.com&#x2F;2015&#x2F;08&#x2F;52-things-number-47-what-is-fiat-shamir.html&quot;&gt;Fiat-Shamir Transform&lt;&#x2F;a&gt; (which is most often used in the ROM) has, alone, probably been used to construct hundreds of cryptosystems. The argument for the ROM goes deeper, though. &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2015&#x2F;140&quot;&gt;Koblitz and Menezes&lt;&#x2F;a&gt; make a strong argument that, not only does the ROM allow us to prove schemes secure that are otherwise unprovably secure (e.g., the Full-Domain Hash signature scheme), but it also gives us constructions that are less brittle to misuse (avoiding things like the duplicate signature key selection attack in the GHR signature scheme).&lt;&#x2F;p&gt;
&lt;p&gt;All this is to say that, while the ROM is just a heuristic, it&#x27;s a really really useful one.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;hash-functions-are-not-random-oracles&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#hash-functions-are-not-random-oracles&quot; aria-label=&quot;Anchor link for: hash-functions-are-not-random-oracles&quot;&gt;§&lt;&#x2F;a&gt;
Hash Functions are not Random Oracles&lt;&#x2F;h2&gt;
&lt;p&gt;Earlier I said that no claim is made that hash functions can be modeled as random oracles. And that&#x27;s good, because it turns out that it&#x27;s false. A neat way of proving this is to construct a digital signature algorithm which is secure in the ROM, but insecure under any choice of hash function. I&#x27;ll repeat that because this is really surprising: &lt;strong&gt;there is a signature scheme which is secure in the ROM, but completely insecure under ANY choice of hash function&lt;&#x2F;strong&gt;. As far as I can tell, the first example of such a scheme was given&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#revisitedsig&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; in 1998 by CGH, but I&#x27;d like to use a different example&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#maurer&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; by HMR, which I think is a lot cleaner and which I&#x27;ll paraphrase and prove in this section.&lt;&#x2F;p&gt;
&lt;p&gt;Suppose there&#x27;s a secure signature scheme&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#euf&quot;&gt;5&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; $\mathcal{S}$ with signature algorithm $\mathsf{Sign}_k(m)$ where $k$ is the signing key. We define a new signature scheme $\mathcal{Evil}$ with signing algorithm $\mathsf{EvilSign}^\mathsf{H}_k(m)$ which has access access to some oracle $\mathsf{H}$ (we&#x27;ll compare the case where $\mathsf{H}$ is an oracle $\mathcal{O}$ versus when it&#x27;s a hash function $f$). Denote the security parameter by $\lambda$. On input $m$, $\mathsf{EvilSign}^\mathsf{H}_k$ will calculate $b := \mathsf{D^H}(m)$, where $\mathsf{D}$ is an algorithm we&#x27;ll define in a second. If $b = 0$, then the algorithm returns $\mathsf{Sign}_k(m)$, otherwise, it does the completely insecure thing and returns $k$.&lt;&#x2F;p&gt;
&lt;p&gt;$\mathsf{D^H}(m)$ is the algorithm that we use to distinguish between random oracles and hash functions. It exploits the idea that a hash function has a representation as a program, whereas a random oracle needs a massive truth table in order to describe its behavior. $\mathsf{D^\mathsf{H}}$ will interpret its input $m$ as the description of a (Universal Turing Machine) program $\pi$. It then checks whether $\pi(i) = \mathsf{H}(i)$ for all $0 \leq i &amp;lt; 2|\pi|+\lambda$. If this equality fails for any $i$, then $\mathsf{D}$ outputs 0. Otherwise, it outputs 1. We claim two things:&lt;&#x2F;p&gt;
&lt;div class=&quot;math-thm&quot;&gt;
&lt;p&gt;&lt;strong&gt;Claims:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;If $\mathsf{H}$ is a hash function $f$, there exists an adversary that can always make $\mathsf{D}$ output 1.&lt;&#x2F;li&gt;
&lt;li&gt;If $\mathsf{H}$ is a random oracle $\mathcal{O}$, $\mathsf{D}$ outputs 0 with high probability (where the probability is taken over random choice of $\mathcal{O}$).&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Proof of (1):&lt;&#x2F;strong&gt; This one&#x27;s easy: the adversary simply sends the encoding of $f$ itself. Then $\pi(i) = \mathsf{H}(i) = f(i)$ for all $i$.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Proof of (2):&lt;&#x2F;strong&gt; This can be proven by bounding the likelihood that there exists a program that can represent the truth table of $\mathcal{O}$. For a moment, let&#x27;s consider just programs of length at most $\ell$. Let $q_\ell = 2\ell+\lambda$.&lt;&#x2F;p&gt;
&lt;p&gt;The set of all outputs up to $q_\ell$ of all random oracles, pessimistically assuming that the oracles are binary-valued, is $\{(\mathcal{O}(1), \mathcal{O}(2), \ldots, \mathcal{O}(q_\ell)) : \mathcal{O} : \mathbb{N} \to \{0,1\}\}$. This set has size $2^{q_\ell}$. In comparison, consider the set of program outputs of programs of length at most $\ell$. Again, assume pessimistically that all programs of length at most $\ell$ halt and return binary values. Then the size of the set, $\{(\pi(1), \pi(2), \ldots, \pi(q_\ell)) : |\pi| \leq \ell\}$, is at most $2^{\ell+1}$. This is a much smaller set than that of the oracle outputs. So if $\mathcal{O}$ is chosen randomly, the likelihood that there exists a $\pi$ of length at most $\ell$ that describes $\mathcal{O}$ out to $q_\ell$ many places is&lt;&#x2F;p&gt;
&lt;p&gt;$$
p_\ell
= \Pr_{\mathcal{O}}\left[
\exists \pi :
|\pi| \leq \ell
\wedge \mathcal{O}(1) = \pi(1)
\wedge \cdots \wedge \mathcal{O}(q_\ell) = \pi(q_\ell)
\right]
= {\sum_{|\pi| \leq \ell} \Pr_\mathcal{O}\left[
\mathcal{O}(1) = \pi(1)
\wedge \cdots \wedge \mathcal{O}(q_\ell) = \pi(q_\ell)
\right]}
\leq \frac{2^{\ell+1}}{2^{q_\ell}}
= 2^{-\ell-\lambda+1}
$$&lt;&#x2F;p&gt;
&lt;p&gt;Then by the union bound, the probability $p$ that a random oracle has any program $\pi$ that agrees with it at the first $2|\pi| + \lambda$ values is&lt;&#x2F;p&gt;
&lt;p&gt;$$
p \leq \sum_{\ell = 0}^\infty p_\ell \leq \sum_{\ell = 0}^\infty 2^{-\ell-\lambda+1} = 2^{-\lambda+2}
$$&lt;&#x2F;p&gt;
&lt;p&gt;which is inverse-exponential in the security parameter.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;If we are in the ROM, then it follows from claim (II) that the only way to construct a forgery in scheme $\mathcal{Evil}$ is to construct a forgery in $\mathcal{S}$. Since $\mathcal{S}$ is assumed to be secure against forgery, this is not possible. Thus, this scheme is secure in the ROM.&lt;&#x2F;p&gt;
&lt;p&gt;Further, it follows from claim (I) that for any choice of hash function $f$, $\mathsf{EvilSign}$ can be completely broken by an efficient adversary. Thus, we have constructed a scheme that is secure in the ROM and insecure under &lt;em&gt;any&lt;&#x2F;em&gt; choice of hash function!&lt;&#x2F;p&gt;
&lt;h2 id=&quot;is-the-rom-broken&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#is-the-rom-broken&quot; aria-label=&quot;Anchor link for: is-the-rom-broken&quot;&gt;§&lt;&#x2F;a&gt;
Is the ROM Broken?&lt;&#x2F;h2&gt;
&lt;p&gt;Given this ridiculous mismatch of security expectations, one may ask: is the ROM a reasonable heuristic to use if it so clearly fails to reflect reality in at least one cryptosystem? This is a matter of opinion.&lt;&#x2F;p&gt;
&lt;p&gt;The $\mathcal{Evil}$ cryptosystem above is a pathological example by any standard. The signature function is literally programmed to reveal the secret key some of the time. It turns out that weird examples like these are actually the only examples we have of the ROM failing to hold up in the real world. Further, there are a handful of examples where avoiding the ROM has actually introduced exploitable vulnerabilities into a cryptosystem&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#standardvulns&quot;&gt;6&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;. These vulnerabilities normally arise from, in a broad sense, things having too much algebraic structure.&lt;&#x2F;p&gt;
&lt;p&gt;On the other hand, an unrealistic model is an unrealistic model. If there is a cryptosystem, albeit a contrived one, which serves as a counterexample to the claim that hash functions are interchangeable with random oracles, then why should we believe that there are some cryptosystems in which this claim is true?&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#revisited&quot;&gt;7&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; We don&#x27;t have any proofs so far of being able to model a hash function with a random oracle in a certain cryptosystem, only counterexamples.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll hold off weighing in until the conclusion, but I think this is a reasonable question to ask, and not one that science or math can really answer. This is one of those cases where philosophy intersects cryptography in a way that can affect what people choose to research and how they construct their solutions.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;the-quantum-random-oracle-model&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#the-quantum-random-oracle-model&quot; aria-label=&quot;Anchor link for: the-quantum-random-oracle-model&quot;&gt;§&lt;&#x2F;a&gt;
The Quantum Random Oracle Model&lt;&#x2F;h1&gt;
&lt;p&gt;It turns out that we have to go through this same moral conundrum when we talk about the QROM, because $\mathcal{Evil}$ is secure in the QROM too! Again, to be concrete, &lt;strong&gt;there is a signature scheme that is secure against quantum-capable adversaries in the QROM, but completely insecure for ANY choice of hash function&lt;&#x2F;strong&gt;. To get to this claim, we&#x27;ll need some of the basics of quantum computation theory.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;a-quick-rundown-of-quantum-computation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-quick-rundown-of-quantum-computation&quot; aria-label=&quot;Anchor link for: a-quick-rundown-of-quantum-computation&quot;&gt;§&lt;&#x2F;a&gt;
A Quick Rundown of Quantum Computation&lt;&#x2F;h2&gt;
&lt;p&gt;&amp;quot;Qubit&amp;quot; is a fancy term you might have heard before. A qubit is the most basic unit of data in Quantum Land, so it&#x27;ll be worth it to give a rigorous definition. First, we often fix the number of qubits in a system by fixing the dimension of the system. In particular, we say that a &lt;strong&gt;$b$-qubit system&lt;&#x2F;strong&gt; is a subset of $\mathbb{C}^{2^b} \cong \mathbb{C}^2 \otimes \cdots \otimes \mathbb{C}^2$ (tensored $b$ many times). A &lt;strong&gt;qubit&lt;&#x2F;strong&gt; is an element of the unit sphere $B = \{\|z\| = 1 : z \in \mathbb{C}^{2^b}\}$ (where the norm is the $L_2$ norm). The operations on qubits we care about are &lt;strong&gt;unitary operators&lt;&#x2F;strong&gt;, i.e., linear functions that preserve length, i.e., linear functions from $\mathbb{C}^{2^b}$ to $\mathbb{C}^{2^b}$ which map $B$ to $B$. We represent the $i$-th basis vector (0-indexed) of $\mathbb{C}^{2^b}$ by writing $\langle \mathsf{bin}(i)\rangle$, where $\mathsf{bin}(i)$ denotes the binary expansion of $i$.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#braket&quot;&gt;8&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; So for example, $\langle 000 \rangle$ denotes the 0-th basis vector of $\mathbb{C}^8$ (&lt;em&gt;not&lt;&#x2F;em&gt; the zero vector!), and $\langle 011 \rangle$ denotes the 3rd basis vector. Sometimes we will want to split up the basis vector label into two parts. To denote this, we say $\langle x,y \rangle = \langle x \| y\rangle $, i.e., the concatenation of the binary strings $x$ and $y$. For example, $\langle 001, 011 \rangle = \langle 001011 \rangle$.&lt;&#x2F;p&gt;
&lt;p&gt;Notice that the set of bitstrings of length $b$ is in bijection with the basis vectors of $\mathbb{C}^{2^b}$, so we can talk about &amp;quot;linear combinations of bitstrings&amp;quot; in a way that makes sense. For example, $v = (1&#x2F;\sqrt{2})\cdot \langle 110 \rangle - (i&#x2F;\sqrt{2})\cdot \langle 010\rangle$ is a vector in $B$. We say that this qubit $v$ represents a &lt;strong&gt;superposition&lt;&#x2F;strong&gt; of the bitstrings $\langle 110\rangle$ and $\langle 010\rangle$. This representation as the linear combination of bitstrings is unique for the same reason that the representation of a vector in terms of the standard basis is unique.&lt;&#x2F;p&gt;
&lt;p&gt;We can define linear operators that act on these bitstrings by defining mappings from basis elements to basis elements. For example, if $f$ is a function from $\{0,1\}^3$ to $\{0,1\}^3$ (i.e., bitstrings of length 3 to bitstrings of length 3), and $f(010) = 111$, then we can define a linear operator $F$ that takes $\langle 010\rangle$ to $\langle 111\rangle$. This gives a unitary operator whenever $f$ is a bijection on the bitstrings. But what if $f$ isn&#x27;t a bijection? What if $f(001) = f(010) = 111$? Then you can use a neat trick: define $F$ such that it takes the basis vector $\langle x, y \rangle$ to $\langle x, y \oplus f(x)\rangle$. This trick works because the output &amp;quot;remembers&amp;quot; the input, so the function is always invertible. For example,&lt;&#x2F;p&gt;
&lt;p&gt;$$
F(\langle 010, 000 \rangle) = \langle 010, 111 \rangle
\quad\textrm{and}\quad
F(\langle 001, 000 \rangle) = \langle 001, 111 \rangle
$$&lt;&#x2F;p&gt;
&lt;p&gt;Operators that are defined like this are almost always given $y = 0$. Finally, notice that we had to make the dimension of the space larger, and thus increase the number of qubits in our system in order to accommodate more bits. Indeed, doubling the dimension to account for non-injectivity of bit-valued functions is common practice.&lt;&#x2F;p&gt;
&lt;p&gt;Alright, that&#x27;s about all the background necessary to present the QROM and the final result.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;quantum-random-oracles&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#quantum-random-oracles&quot; aria-label=&quot;Anchor link for: quantum-random-oracles&quot;&gt;§&lt;&#x2F;a&gt;
Quantum Random Oracles&lt;&#x2F;h2&gt;
&lt;p&gt;The QROM (introduced in 2010 by &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2010&#x2F;428.pdf&quot;&gt;Boneh et al.&lt;&#x2F;a&gt;) comes from a simple insight: if we believe that quantum computers could run hash function circuits in superposition (and we do), then why don&#x27;t we model hash functions as random oracles, but more quantum-y? This is, in essence, the same idea as the ROM, except the random oracles are allowed to be queried in quantum superposition. More specifically,&lt;&#x2F;p&gt;
&lt;div class=&quot;math-def&quot;&gt;
&lt;p&gt;&lt;strong&gt;Definition:&lt;&#x2F;strong&gt; Given a random oracle $\mathcal{O}$, the associated &lt;strong&gt;quantum random oracle&lt;&#x2F;strong&gt; $\mathcal{O}_\mathrm{quant}$ is the unitary operator that maps a superposition of bitstrings to the superposition of its values when evaluated with $\mathcal{O}$. Concretely, for every basis vector $\langle x, y \rangle$, define&lt;&#x2F;p&gt;
&lt;p&gt;$$
\mathcal{O}_\mathrm{quant}(\langle x, y \rangle) := \langle x, y \oplus \mathcal{O}(x)\rangle
$$&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;By this definition, $\mathcal{O}_\mathrm{quant}$ is a unitary operator, so it makes sense to say&lt;&#x2F;p&gt;
&lt;p&gt;$$
\mathcal{O}_\mathrm{quant}\left(
\frac{1}{\sqrt 3} \langle 010, 000 \rangle
+ \frac{i}{\sqrt 3} \langle 011, 000 \rangle
- \frac{i}{\sqrt 3} \langle 110, 000 \rangle
\right)
=
\frac{1}{\sqrt 3} \langle 010, \mathcal{O}(010) \rangle
+ \frac{i}{\sqrt 3} \langle 011, \mathcal{O}(011) \rangle
- \frac{i}{\sqrt 3} \langle 110, \mathcal{O}(110) \rangle
$$&lt;&#x2F;p&gt;
&lt;p&gt;Notice that a quantum random oracle is at least as powerful as a random oracle, since you can always query with the superposition of just a single value:&lt;&#x2F;p&gt;
&lt;p&gt;$$
\mathcal{O}_\mathrm{quant}(\langle x, 0 \rangle) = \langle x, \mathcal{O}(x)\rangle
$$&lt;&#x2F;p&gt;
&lt;p&gt;In fact, quantum random oracles are strictly more powerful than classical random oracles. Boneh et al. show a &lt;em&gt;separation result&lt;&#x2F;em&gt;. In particular, they present an identification scheme that is secure in the ROM, and insecure in the QROM.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#separation&quot;&gt;9&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;quantum-hash-functions-are-not-quantum-random-oracles&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#quantum-hash-functions-are-not-quantum-random-oracles&quot; aria-label=&quot;Anchor link for: quantum-hash-functions-are-not-quantum-random-oracles&quot;&gt;§&lt;&#x2F;a&gt;
Quantum Hash Functions are not Quantum Random Oracles&lt;&#x2F;h2&gt;
&lt;p&gt;Since the QROM is strictly more powerful than the ROM, it follows that QROM-security implies ROM-security. But we&#x27;d like to show that the ROM-secure $\mathcal{Evil}$ scheme above is also QROM-secure. Luckily, Boneh et al. also give us the conditions for when this converse statement is true.&lt;&#x2F;p&gt;
&lt;div class=&quot;math-thm&quot;&gt;
&lt;p&gt;&lt;strong&gt;Theorem:&lt;&#x2F;strong&gt; If a reduction to a problem $P$ holds in the ROM, and the reduction is history-free, then the reduction to problem $P$ holds in the QROM as well.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;A &lt;strong&gt;history-free&lt;&#x2F;strong&gt; reduction is defined formally in the paper, but it suffices to say that a history-free reduction is a reduction that does not rewind its solver $\mathcal{Y}$, does not record the oracle queries, and does not modify oracle behavior based on previous queries.&lt;&#x2F;p&gt;
&lt;p&gt;Recall that the above proof of security in the ROM was actually a reduction to the security of the underlying hypothetical signature scheme $\mathcal{S}$. To prove QROM-security, we need to tweak the assumption a bit: instead of assuming that $\mathcal{S}$ is secure against classical adversaries, we need to further assume it is secure against quantum-capable adversaries. Admitting this, the only thing that needs to be shown is that the proof of ROM-security of $\mathcal{Evil}$ is history-free. Indeed, the reduction never recorded queries, rewound the solver, or modified its own behavior, so it&#x27;s pretty clear that it&#x27;s history free.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#proof&quot;&gt;10&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;conclusions&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusions&quot; aria-label=&quot;Anchor link for: conclusions&quot;&gt;§&lt;&#x2F;a&gt;
Conclusions&lt;&#x2F;h1&gt;
&lt;p&gt;And that&#x27;s it! We&#x27;ve just constructed a signature scheme (assuming the existence of a quantum-secure&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#euf&quot;&gt;5&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; signature scheme) that is secure against quantum adversaries when modeling the hash functions as quantum-accessible random oracles, but is completely insecure under &lt;em&gt;any&lt;&#x2F;em&gt; choice of hash function!&lt;&#x2F;p&gt;
&lt;p&gt;I want to reiterate that the failure of the (Q)ROM to reflect real-world security should not necessarily be taken as a sign that we should stop using it, though some argue precisely that. My personal, highly unqualified opinion is that this construct has given us far more than it&#x27;s taken, and despite the fact that it sometimes fails to tell us something about our world, I am convinced, as Rogaway and Bellare are, that it captures &amp;quot;the properties that practical primitives really seem to possess.&amp;quot;&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;efficient&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;&amp;quot;Efficient&amp;quot; meaning polynomial-time in the size of its inputs. Also of course not every Turing reduction is polynomial time, but there&#x27;s only so much couching I can do before I lose everyone.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;randomly&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;This is hard because the obvious definition of random is &amp;quot;given a bunch of input-output pairs, you are unable to tell anything about the output on any input you haven&#x27;t already seen&amp;quot;. In the context of a random oracle, this makes sense, because an oracle would be chosen at random at the beginning of the experiment. But for a hash function, if the hash function is publicly known, then the adversary can just make the queries itself. If we instead sample from a family of hash functions, that would eliminate that problem, but the ROM-secure schemes we&#x27;re talking about aren&#x27;t ones which randomly sample from a hash function family in every instantiation.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;revisitedsig&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;3&lt;&#x2F;sup&gt;
&lt;p&gt;Section 4 in &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;1998&#x2F;011&quot;&gt;Canetti, Goldreich, Halevi&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;maurer&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;4&lt;&#x2F;sup&gt;
&lt;p&gt;Section 2 in &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2003&#x2F;161&quot;&gt;Holenstein, Maurer, Renner&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;euf&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;5&lt;&#x2F;sup&gt;
&lt;p&gt;As a reminder, a digital signature scheme consists of algorithms $\mathsf{KeyGen}$, $\mathsf{Sign}$, and $\mathsf{Ver}$. By &amp;quot;secure&amp;quot; I mean EUF-CMA-secure, meaning that an adversary can&#x27;t forge a valid signature for a message it&#x27;s never seen before. And by &amp;quot;quantum-secure&amp;quot; I mean the same thing but against a quantum-capable adversary.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;standardvulns&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;6&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2015&#x2F;140.pdf&quot;&gt;This paper&lt;&#x2F;a&gt; by Koblitz and Menezes presents good arguments for what the ROM has bought us and what avoiding the ROM has wreaked.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;revisited&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;7&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;1998&#x2F;011&quot;&gt;Canetti, Goldreich, Halevi&lt;&#x2F;a&gt; generally argue that the ROM should be avoided for this reason.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;braket&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;8&lt;&#x2F;sup&gt;
&lt;p&gt;I know that this notation is nonstandard, but I&#x27;m not using bra-ket notation because it&#x27;s not necessary for the rest of this piece.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;separation&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;9&lt;&#x2F;sup&gt;
&lt;p&gt;This is section 3 in &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2010&#x2F;428.pdf&quot;&gt;Boneh et al.&lt;&#x2F;a&gt; The gist is there is an identification scheme that will either do the correct thing, or do the insecure thing if the adversary is able to compute some number of hash collisions in $O(\sqrt[3]{N})$ time. Since the best you can do in the classical case is find a collision with probability 1&#x2F;2 in $O(\sqrt N)$ time, this is secure for all classical adversaries. But a quantum adversary running Grover&#x27;s algorithm can compute several collisions in $O(\sqrt[3]{N})$ time with high probability.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;proof&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;10&lt;&#x2F;sup&gt;
&lt;p&gt;I left out the details here only because it&#x27;s very boring and takes up a bunch of space. If you want read the full proof, see section 3.2 in the aforementioned &lt;a href=&quot;&#x2F;assets&#x2F;pdfs&#x2F;qrom_survey.pdf&quot;&gt;survey paper&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</description>
      </item>
      <item>
          <title>Supersingular Isogeny Key Exchange for Not-Quite Beginners</title>
          <pubDate>Wed, 08 Jan 2020 16:55:20 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/sidh/</link>
          <guid>https://mrosenberg.pub/blog/sidh/</guid>
          <description>&lt;p&gt;I recently read a &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2019&#x2F;1321&quot;&gt;great introductory paper&lt;&#x2F;a&gt; on Supersingular Isogeny Diffie-Hellman (SIDH) by Craig Costello and wanted to summarize just the math of it (with some simplifications) for myself. Hopefully this summary is clear enough to also be useful to people who aren&#x27;t myself.&lt;&#x2F;p&gt;
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;&lt;h1 id=&quot;background&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#background&quot; aria-label=&quot;Anchor link for: background&quot;&gt;§&lt;&#x2F;a&gt;
Background&lt;&#x2F;h1&gt;
&lt;p&gt;We deal with supersingular (we won&#x27;t define this word) elliptic curves defined over finite fields of the form $\mathbb{F}_{p^2}$.&lt;&#x2F;p&gt;
&lt;p&gt;For SIDH, we deal only with curves such that $E(\mathbb{F}_{p^2}) \cong \mathbb{Z}_{p+1} \times \mathbb{Z}_{p+1}$. The kernel of the left multiplication map $P \to [a]P$ is of the form $\mathbb{Z}_a \times \mathbb{Z}_a$. We say that a map $\phi: E \to E&#x27;$ is an $\ell$-isogeny iff $|\ker \phi| = \ell$. Notice that $\ell$-isogenies only exist for $\ell \mid p+1$. Every $\ell$-isogeny $\phi: E \to E&#x27;$ also has an associated $\ell$-isogeny, called the dual isogeny $\psi: E&#x27; \to E$, such that $\phi \circ \psi$ is the left-multiplication map $[\ell]$. Vélu&#x27;s formulas tell us that every subgroup $G \leq E$ corresponds to a unique isogeny out of $E$ (to some curve $E&#x27;$) with kernel G. They also tell us how to construct an isogeny given its desired kernel.&lt;&#x2F;p&gt;
&lt;div class=&quot;math-thm&quot;&gt;
&lt;p&gt;&lt;strong&gt;Claim:&lt;&#x2F;strong&gt; On a supersingular curve $E$ of the form above, for any prime $\ell \mid p+1$, there are exactly $\ell+1$ nontrivial $\ell$-isogenies out of $E$.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Proof:&lt;&#x2F;strong&gt; Using Vélu&#x27;s formulas, it suffices to show that E has exactly $\ell+1$ many subgroups of prime order $\ell$. Firstly, since these are of order $\ell$, they all must be subgroups of $E[\ell] \cong \mathbb{Z}_\ell \times \mathbb{Z}_\ell$. Let $P$ and $Q$ denote the free generators of $E[\ell]$.
Consider the family of cyclic subgroups generated by $P + [k]Q$ for $0 \leq k &amp;lt; \ell$. We claim that these are not only distinct, but disjoint. Suppose for distinct $k$, $k&#x27;$ that&lt;&#x2F;p&gt;
&lt;p&gt;$$
\alpha(P + [k]Q) = \beta(P + [k&#x27;]Q)
$$&lt;&#x2F;p&gt;
&lt;p&gt;for some integers $\alpha$, $\beta$. Rearranging,&lt;&#x2F;p&gt;
&lt;p&gt;$$
[\alpha]P - [\beta]P = [\beta k]Q - [\alpha k&#x27;]Q
$$&lt;&#x2F;p&gt;
&lt;p&gt;Since $P$ and $Q$ are linearly independent, both sides of this equation must be the identity. Therefore,&lt;&#x2F;p&gt;
&lt;p&gt;$$
\alpha \equiv \beta\ (\textrm{mod } \ell)
$$&lt;&#x2F;p&gt;
&lt;p&gt;Putting this together with the fact that the RHS is the identity,&lt;&#x2F;p&gt;
&lt;p&gt;$$
\beta k \equiv \alpha k&#x27; \equiv \beta k&#x27;\ (\textrm{mod } \ell),
$$&lt;&#x2F;p&gt;
&lt;p&gt;we conclude $k \equiv k&#x27;\ (\textrm{mod } \ell)$. This gives us a family of $\ell$ many disjoint subgroups. The final subgroup to include is the one generated by $Q$. It is clear that this is also disjoint from the previously mentioned subgroups. Finally, there cannot be any more order $\ell$ subgroups, since we have listed all the possible cyclic subgroups of $\mathbb{Z}_\ell \times \mathbb{Z}_\ell$, and all groups of prime order are cyclic.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;A &lt;strong&gt;supersingular $\ell$-isogeny graph&lt;&#x2F;strong&gt; is a graph whose nodes are $j$-invariants (i.e., elements of $\mathbb{F}_{p^2}$ which are in bijective correspondence with isomorphism classes of elliptic curves) and whose edges represent $\ell$-isogenies between them. Note this is an undirected graph because every $\ell$-isogeny has a dual $\ell$-isogeny going in the other direction. Also, by the above claim, every node has degree $\ell+1$. It turns out that this is an expander graph, which means random walks on it mix quickly. In other words, the diameter of an expander graph on $N$ elements is roughly $\log(N)$. SIDH exploits this property to make its security claims.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;sidh&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#sidh&quot; aria-label=&quot;Anchor link for: sidh&quot;&gt;§&lt;&#x2F;a&gt;
SIDH&lt;&#x2F;h1&gt;
&lt;p&gt;The purpose of SIDH is to compute a shared secret by exchanging public keys. Same idea as Diffie Hellman.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;public-parameters&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#public-parameters&quot; aria-label=&quot;Anchor link for: public-parameters&quot;&gt;§&lt;&#x2F;a&gt;
Public Parameters&lt;&#x2F;h2&gt;
&lt;ul&gt;
&lt;li&gt;A prime $p = 2^{e_A}3^{e_B} - 1$. This way, $p+1$ is divisible by powers of 2 and 3. $e_A$ and $e_B$ are chosen so that $2^{e_A} \approx 3^{e_B}$.&lt;&#x2F;li&gt;
&lt;li&gt;A starting curve $E$ defined over $\mathbb{F}_{p^2}$&lt;&#x2F;li&gt;
&lt;li&gt;Two points $P_A,Q_A \in E$ such that $\langle P_A, Q_A \rangle \cong \mathbb{Z}_{2^{e_A}} \times \mathbb{Z}_{2^{e_A}}$.&lt;&#x2F;li&gt;
&lt;li&gt;Two points $P_B,Q_B \in E$ such that $\langle P_B, Q_B \rangle \cong \mathbb{Z}_{3^{e_B}} \times \mathbb{Z}_{3^{e_B}}$.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;protocol&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#protocol&quot; aria-label=&quot;Anchor link for: protocol&quot;&gt;§&lt;&#x2F;a&gt;
Protocol&lt;&#x2F;h2&gt;
&lt;p&gt;Here&#x27;s the gist of the protocol: Alice takes a walk on a 2-isogeny graph and marks her stopping point. Bob takes a walk on a 3-isogeny graph and marks his stopping point. The constraint that $2^{e_A} \approx 3^{e_B}$ means that the number of possible stopping points that Alice can get to is roughly equal to the number of possible stopping points Bob can get to. They then share their stopping points with each other. Then both of them do the same walks as before, but starting at each other&#x27;s stopping point. The final endpoints of Alice&#x27;s and Bob&#x27;s walks are isomorphic (as elliptic curves, since points on the isogeny graph are curves), which means they have the same $j$-invariant.&lt;&#x2F;p&gt;
&lt;p&gt;Concretely, here&#x27;s the protocol sequence. Alice initiates:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Alice:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Picks a random secret scalar $0 \leq k_A &amp;lt; 2^{e_A}$ and defines a secret generator $S_A = P_A + [k_A]Q_A$. Note that $S_A$ has order $2^{e_A}$ because $P_A$ and $Q_A$ are linearly independent. By the proof above, all the possible subgroups $\langle S_A\rangle$ are disjoint.&lt;&#x2F;li&gt;
&lt;li&gt;Constructs a $2^{e_A}$-isogeny $\phi_A: E \to E&#x2F;\langle S_A\rangle$. This is done iteratively by repeatedly constructing 2-isogenies with elements of $\langle S_A\rangle$ in the kernel. The way you do this is by getting a point $R_A = [2^{e_A-1}]S_A$ of order 2. Using Vélu&#x27;s formulas, you can construct a $\phi_0: E \to E&#x2F;\langle R_A\rangle$. Now let $S&#x27;_A = \phi_0(S_A)$. Then $S&#x27;_A$ has order $2^{e_A-1}$. Let $R&#x27;_A = [2^{e_A-2}]S&#x27;_A$, ... Once you&#x27;ve constructed $\phi_0$, ..., $\phi_{e_A}$, let $\phi_A$ be the composition of all of these.&lt;&#x2F;li&gt;
&lt;li&gt;Sends Bob $(\phi_A(E), \phi_A(P_B), \phi_A(Q_B))$, where $\phi_A(E)$ is the description of the output curve. We call this tuple Alice&#x27;s &amp;quot;public key&amp;quot;.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Bob:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Picks a secret $0 &amp;lt; k_B ≤ 3^{e_B}$, lets $S_B = P_B + [k_B]Q_B$, and constructs a $3^{e_B}$-isogeny $\phi_B: E \to E&#x2F;\langle S_B\rangle$ in the same way as above.&lt;&#x2F;li&gt;
&lt;li&gt;Sends Alice $(\phi_B(E), \phi_B(P_A), \phi_B(Q_A))$. We call this tuple Bob&#x27;s &amp;quot;public key&amp;quot;.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Alice:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Uses the same method to construct $\psi_A: \phi_B(E) \to \phi_B(E)&#x2F;\langle T_A\rangle$ where
$$
T_A = \phi_B(S_A) = \phi_B(P_A) + [k_A]\phi_B(Q_A)
$$&lt;&#x2F;li&gt;
&lt;li&gt;Computes the $j$-invariant of $\psi_A(\phi_B(E))$&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Bob:&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Same idea as above: Construct $\psi_B: \phi_A(E) \to \phi_A(E)&#x2F;\langle T_B\rangle$ where
$$
T_B = \phi_A(S_B) = \phi_A(P_B) + [k_B]\phi_A(Q_B)
$$&lt;&#x2F;li&gt;
&lt;li&gt;Computes the $j$-invariant of $\psi_B(\phi_A(E))$&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;End of Protocol&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Note that, since $j$-variants of isomorphic curves are equal, and
$$
(E&#x2F;\langle S_A\rangle)&#x2F;\langle T_B\rangle \cong E&#x2F;\langle S_A, S_B\rangle \cong (E&#x2F;\langle S_B\rangle)&#x2F;\langle T_A\rangle,
$$&lt;&#x2F;p&gt;
&lt;p&gt;the computed $j$-invariants are the same. Thus, it makes sense to have the $j$-invariant be the shared secret.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;an-attack-on-static-public-keys&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#an-attack-on-static-public-keys&quot; aria-label=&quot;Anchor link for: an-attack-on-static-public-keys&quot;&gt;§&lt;&#x2F;a&gt;
An Attack on Static Public Keys&lt;&#x2F;h1&gt;
&lt;p&gt;This attack is due to &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2016&#x2F;859&quot;&gt;Galbraith, Petit, Shani, and Ti&lt;&#x2F;a&gt;. If Alice keeps reusing the same $k_A$, Bob can determine its value by by initiating $\lceil\log_2(k_A)\rceil$ many SIDH exchanges. Here&#x27;s the exploit:&lt;&#x2F;p&gt;
&lt;p&gt;Bob can figure out the bottom bit of $k_A$ by publishing $\phi_B(Q_A) + L_2$ instead of $\phi_B(Q_A)$, where $L_2$ is a point of order 2. If $k_A$ is odd, i.e., if $L_2$ is not killed by $k_A$, then the protocol does not produce agreement, because $T_A + L_2$ is not the image of $S_A$ in Bob&#x27;s curve $\phi_B(E)$. If $k_A$ is even, then $L_2$ is killed by $k_A$ and the protocol completes successfully. Thus, the bottom bit is leaked.&lt;&#x2F;p&gt;
&lt;p&gt;Say Bob finds it was even. Now Bob wants to know if $k_A \equiv 0\ (\textrm{mod } 4)$ or $2\ (\textrm{mod } 4)$. Then he sends $\phi_B(Q_A) + L_4$ where $L_4$ is a point of order 4, and uses the same logic. If Bob had found $k_A$ was odd, then he would send $\phi_B(P_A) - L_4$ instead of $\phi_B(P_A)$, and $\phi_B(Q_A) + L_4$ instead of $\phi_B(Q_A)$. So if $k_A$ is $1\ (\textrm{mod } 4)$, then&lt;&#x2F;p&gt;
&lt;p&gt;$$
\begin{align*}
&amp;amp;\phi_B(P_A) - L_4 + k_A(\phi_B(Q_A) + L_4)
\newline &amp;amp;= \phi_B(P_A) - L_4 + [k_A]\phi_B(Q_A) + L_4
\newline &amp;amp;= \phi_B(P_A) + [k_A]\phi_B(Q_A)
\end{align*}
$$&lt;&#x2F;p&gt;
&lt;p&gt;and the protocol succeeds. Otherwise,&lt;&#x2F;p&gt;
&lt;p&gt;$$
\begin{align*}
&amp;amp;\phi_B(P_A) - L_4 + k_A(\phi_B(Q_A) + L_4)
\newline &amp;amp;= \phi_B(P_A) - L_4 + [k_A]\phi_B(Q_A) + [3]L_4
\newline &amp;amp;= \phi_B(P_A) + [k_A]\phi_B(Q_A) + [2]L_4
\end{align*}
$$&lt;&#x2F;p&gt;
&lt;p&gt;and the protocol fails. Bob can continue like this to recover each successive bit of $k_A$.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;patching-it-up&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#patching-it-up&quot; aria-label=&quot;Anchor link for: patching-it-up&quot;&gt;§&lt;&#x2F;a&gt;
Patching it up&lt;&#x2F;h1&gt;
&lt;p&gt;How do you prevent the above attack from working? Ideally, Alice would like to be able to tell when she receives a malicious public key, i.e., one of the form $\phi_B(Q_A) + L$ for some low-order point $L$. If she could do this, then she would be able to terminate the protocol early and not reveal anything about the shared secret.&lt;&#x2F;p&gt;
&lt;p&gt;Unfortunately, given just a public key share, there&#x27;s no way to tell if a given it was modified in this way or not.&lt;&#x2F;p&gt;
&lt;p&gt;But what if Alice was given more than a public key share? What if Bob somehow gave Alice his &lt;em&gt;private&lt;&#x2F;em&gt; ephemeral key as well? Then Alice would be able to compute Bob&#x27;s public key share from his private key and check that it matches the one she received from Bob. If they match, then the public key was honest and the protocol completes successfully. If they don&#x27;t match, then Alice can conclude that Bob cheated and she can abort the protocol early. This is precisely what the &lt;a href=&quot;https:&#x2F;&#x2F;sike.org&#x2F;&quot;&gt;SIKE&lt;&#x2F;a&gt; key encapsulation mechanism  does. Here&#x27;s the new protocol (a little simplified):&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Alice&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Picks her secrets randomly, as before&lt;&#x2F;li&gt;
&lt;li&gt;Publishes her public key $pk_A$, computed as before (i.e., a description of a curve, and two points on that curve)&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Bob&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Picks a random bitstring $m$&lt;&#x2F;li&gt;
&lt;li&gt;Computes his secret scalar $k_B = G(m \| pk_A)$, where $G$ is a pseudorandom number generator. He also computes the corresponding public key $pk_B$.&lt;&#x2F;li&gt;
&lt;li&gt;Computes the $j$-invariant of the SIDH exchange (as described above) between $k_B$ and $pk_A$&lt;&#x2F;li&gt;
&lt;li&gt;Derives a symmetric key $\kappa = \textrm{KDF}(j)$, where $\textrm{KDF}$ is some key-derivation function.&lt;&#x2F;li&gt;
&lt;li&gt;Computes $c = \textrm{Enc}_\kappa(m)$, where $\textrm{Enc}$ is the encryption function for some symmetric encryption scheme.&lt;&#x2F;li&gt;
&lt;li&gt;Sends Alice the tuple $(pk_B, c)$&lt;&#x2F;li&gt;
&lt;li&gt;Computes the shared secret (to be used if the protocol complete successfully) $K = \textrm{KDF}(m \| k_B \| c)$.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;&lt;strong&gt;Alice&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Uses $pk_B$ and her secret $k_A$ to derive the $j$-invariant, denoted $j&#x27;$&lt;&#x2F;li&gt;
&lt;li&gt;Computes $\kappa&#x27; = \textrm{KDF}(j&#x27;)$&lt;&#x2F;li&gt;
&lt;li&gt;Decrypts $m&#x27; = \textrm{Dec}_{\kappa&#x27;}(c)$ (recall Alice received $c$ from Bob)&lt;&#x2F;li&gt;
&lt;li&gt;Computes the secret scalar $k_B&#x27; = G(m&#x27; \| pk_A)$ and its corresponding public key $pk_B&#x27;$&lt;&#x2F;li&gt;
&lt;li&gt;Checks that $pk_B&#x27; = pk_B$. If these are not equal, the protocol aborts.&lt;&#x2F;li&gt;
&lt;li&gt;Derives the shared secret $K = \textrm{KDF}(m&#x27; \| k_B&#x27; \| c)$&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;analysis&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#analysis&quot; aria-label=&quot;Anchor link for: analysis&quot;&gt;§&lt;&#x2F;a&gt;
Analysis&lt;&#x2F;h2&gt;
&lt;p&gt;Let&#x27;s give an informal sketch of how this prevents information leakage.&lt;&#x2F;p&gt;
&lt;p&gt;Say Bob wants Alice to leak the lowest bit of her secret scalar $k_A$. The only leakage mechanism he has access to is learning whether the protocol succeeded or failed (since this can be used to convey a bit of information). He needs the protocol to do one thing when $k_A$ is even, and the other thing if it&#x27;s odd.&lt;&#x2F;p&gt;
&lt;p&gt;If Bob computes and conveys everything honestly (i.e., as described in this new protocol), then it should be clear that the protocol succeeds with 100% probability. Thus, this leaks nothing. If Bob lies about $c$, then $m&#x27; = \textrm{Dec}_{\kappa&#x27;}(c)$ is certainly going to differ from $m$,&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#caveat&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; which results in a different $k&#x27;_B$ and thus a different $pk_B&#x27;$. So that strategy causes the protocol to always fail with overwhelming probability, and thus leak nothing.&lt;&#x2F;p&gt;
&lt;p&gt;So what if Bob lies about $pk_B$ and tries the &amp;quot;add a low-order point&amp;quot; trick from the previous section? As before, this gives Bob control over the value $j&#x27;$ that Alice derives. If $k_A$ is even, it will be the same as Bob&#x27;s $j$, and if it&#x27;s odd it will be different. So far so good. Continuing on the &amp;quot;good&amp;quot; branch, if $j&#x27; = j$, then Alice&#x27;s steps 2, 3, and 4 all continue to derive the same values as Bob&#x27;s. In step 5, Alice can see that the $pk_B$ she received doesn&#x27;t match the public key corresponding to $k_B&#x27;$, so Alice aborts. On the &amp;quot;bad&amp;quot; branch, if $j&#x27; \neq j$, then all the values derived in steps 2, 3, and 4 are wrong, and Alice is certain to abort. Thus, this strategy also causes the protocol to always fail with overwhelming probability, thus leaking nothing!&lt;&#x2F;p&gt;
&lt;p&gt;I hope that explanation was understandable. The way the authors of SIKE prove security is actually far more elegant than this: it turns out that the &amp;quot;patch&amp;quot; I described above is a result of a much more general theorem.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#fuji&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; Also, the patch I presented isn&#x27;t totally accurate, so if you want more detail I encourage you to check out the &lt;a href=&quot;https:&#x2F;&#x2F;sike.org&#x2F;files&#x2F;SIDH-spec.pdf&quot;&gt;spec&lt;&#x2F;a&gt; (algorithms 1 and 2, and the proofs of security in section 4.3).&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;caveat&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;This relies on some assumption about the symmetric key primitive and on $\textrm{KDF}$, so that even if you modified $j&#x27;$ as well, you couldn&#x27;t get $c$ to decrypt to a chosen plaintext&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;fuji&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;The FO transformation is precisely made to turn an IND-CPA PKE into an IND-CCA PKE with very little overhead. &lt;a href=&quot;https:&#x2F;&#x2F;cs.uni-paderborn.de&#x2F;fileadmin&#x2F;informatik&#x2F;fg&#x2F;cuk&#x2F;Lehre&#x2F;Abschlussarbeiten&#x2F;Bachelorarbeiten&#x2F;2014&#x2F;BA_Lippert_FOT_final.pdf&quot;&gt;Here&lt;&#x2F;a&gt;&#x27;s a paper describing what it is and how it works. &lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2017&#x2F;604&quot;&gt;Here&lt;&#x2F;a&gt; is the extremely influential paper that the authors of SIKE cite.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;sike&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;3&lt;&#x2F;sup&gt;
&lt;p&gt;SIKE is currently in &lt;a href=&quot;https:&#x2F;&#x2F;csrc.nist.gov&#x2F;Projects&#x2F;post-quantum-cryptography&#x2F;round-2-submissions&quot;&gt;round 2&lt;&#x2F;a&gt; of the NIST post-quantum cryptography competition&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</description>
      </item>
      <item>
          <title>Better Encrypted Group Chat</title>
          <pubDate>Wed, 10 Jul 2019 00:00:00 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/molasses/</link>
          <guid>https://mrosenberg.pub/blog/molasses/</guid>
          <description>&lt;h1 id=&quot;introducing-molasses&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#introducing-molasses&quot; aria-label=&quot;Anchor link for: introducing-molasses&quot;&gt;§&lt;&#x2F;a&gt;
Introducing molasses&lt;&#x2F;h1&gt;
&lt;p&gt;Broadly, an end-to-end encrypted messaging protocol is one that ensures that only the participants in a conversation, and no intermediate servers, routers, or relay systems, can read and write messages. An end-to-end encrypted &lt;em&gt;group&lt;&#x2F;em&gt; messaging protocol is one that ensures this for all participants in a conversation of three or more people.&lt;&#x2F;p&gt;
&lt;p&gt;End-to-end encrypted group messaging is a necessary problem to solve. Whether it be for limiting liability, providing verifiable client-side security, or removing a single point of failure, there &lt;a href=&quot;https:&#x2F;&#x2F;medium.com&#x2F;@RiotChat&#x2F;why-we-need-end-to-end-encryption-for-online-communications-e7448e0be2c3&quot;&gt;are&lt;&#x2F;a&gt; &lt;a href=&quot;https:&#x2F;&#x2F;www.schneier.com&#x2F;academic&#x2F;paperfiles&#x2F;paper-keys-under-doormats-CSAIL.pdf&quot;&gt;good&lt;&#x2F;a&gt; &lt;a href=&quot;https:&#x2F;&#x2F;www.nytimes.com&#x2F;2019&#x2F;07&#x2F;01&#x2F;opinion&#x2F;slack-chat-hackers-encryption.html&quot;&gt;reasons&lt;&#x2F;a&gt; for a group messaging host to use an end-to-end encrypted protocol.&lt;&#x2F;p&gt;
&lt;p&gt;Existing solutions such as Signal, WhatsApp, and iMessage have inherent problems with scaling, which I&#x27;ll discuss in detail, that make it infeasible to conduct group chats of more than a few hundred people. The &lt;a href=&quot;https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;draft-ietf-mls-protocol&#x2F;&quot;&gt;Message Layer Security (MLS)&lt;&#x2F;a&gt; protocol aims to make end-to-end group chat more efficient while still providing security guarantees like forward secrecy and post-compromise security.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#pcs&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;To these ends, I have been working on &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;trailofbits&#x2F;molasses&quot;&gt;&lt;code&gt;molasses&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, a Rust implementation of MLS, designed with safety, ease-of-use, and difficulty-of-misuse in mind.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;molasses-has-helped-refine-the-mls-spec&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#molasses-has-helped-refine-the-mls-spec&quot; aria-label=&quot;Anchor link for: molasses-has-helped-refine-the-mls-spec&quot;&gt;§&lt;&#x2F;a&gt;
Molasses has helped refine the MLS spec&lt;&#x2F;h2&gt;
&lt;p&gt;The primary contribution of &lt;code&gt;molasses&lt;&#x2F;code&gt; has been in detecting errors in the specification and other implementations through unit and interoperability testing. &lt;code&gt;molasses&lt;&#x2F;code&gt; implements most of MLS draft 6. Why not all of draft 6? There was an error in the spec that made it impossible for members to be added to any group. This broke all the unit tests that create non-trivial groups. Errors like this are hard to catch just by reading the spec; they require some amount of automated digging. Once they are found, the necessary revisions tend to be pretty obvious, and they are swiftly incorporated into the subsequent draft.&lt;&#x2F;p&gt;
&lt;p&gt;Iterating this discovery&#x2F;patching process using &lt;code&gt;molasses&lt;&#x2F;code&gt; has given me a chance to put the spec through its paces and help make things clearer. This winter internship (also called a &amp;quot;winternship&amp;quot; by nobody) project has been a great experience, especially as a first-time IETF contributor.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;how-to-build-encrypted-group-chat&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-to-build-encrypted-group-chat&quot; aria-label=&quot;Anchor link for: how-to-build-encrypted-group-chat&quot;&gt;§&lt;&#x2F;a&gt;
How to build encrypted group chat&lt;&#x2F;h1&gt;
&lt;p&gt;In this section we derive why MLS is constructed the way it is (hint: for efficiency reasons), and how it compares to other solutions (hint: it&#x27;s better).&lt;&#x2F;p&gt;
&lt;p&gt;First off, MLS works on a lower level than most chat applications. It is a protocol upon which applications can be built. For example, MLS does not govern group permissions such as who can add people to the chat (this can be done at the application level while using MLS under the hood). Thus, we can leave things like formal rule systems out of the conversation entirely when analyzing the protocol. Here, we&#x27;re only going to consider the sending of messages and the removal of members.&lt;&#x2F;p&gt;
&lt;p&gt;The constructions in this section make use of cryptographic primitives such as digital signatures, Diffie-Hellman key exchange, (a)symmetric encryption, and key-derivation functions. If the reader feels underprepared in any of these areas, a quick skim of the sections in &lt;a href=&quot;https:&#x2F;&#x2F;nostarch.com&#x2F;seriouscrypto&quot;&gt;&lt;em&gt;Serious Cryptography&lt;&#x2F;em&gt;&lt;&#x2F;a&gt; on ECIES and Authenticated Diffie-Hellman should be sufficient.&lt;&#x2F;p&gt;
&lt;p&gt;Without further ado,&lt;&#x2F;p&gt;
&lt;h2 id=&quot;a-motivating-problem&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-motivating-problem&quot; aria-label=&quot;Anchor link for: a-motivating-problem&quot;&gt;§&lt;&#x2F;a&gt;
A Motivating Problem&lt;&#x2F;h2&gt;
&lt;p&gt;Wilna is planning a retirement party for an acquaintance, Vince. The logistics are a nightmare, so she invites her friends Xavier, Yolanda, and Zayne to help her plan. They would like to make a group chat on Slack so they can all stay on the same page, but they remember that Vince is an infrastructure manager for Slack—he can see &lt;em&gt;all&lt;&#x2F;em&gt; the messages sent over any Slack server in the world. This is a problem, since they want to give Vince a nice long vacation upstate and they want it to be a surprise. Vince&#x27;s position poses even more problems: he happens to manage every single server in town. Even if Wilna purchases her own server to mediate the group chat, Vince will be tasked with managing it, meaning that he can read everything the server stores.&lt;&#x2F;p&gt;
&lt;p&gt;What Wilna needs is a &lt;strong&gt;centralized end-to-end encrypted group chat&lt;&#x2F;strong&gt;, i.e., a group chat where every member can broadcast messages and read all incoming messages, but the single server that mediates these messages cannot read anything. For clarity, we&#x27;ll distinguish between &lt;strong&gt;application messages&lt;&#x2F;strong&gt;, which carry the textual content of what a group member wants to say to everyone else in the group, and &lt;strong&gt;auxiliary messages&lt;&#x2F;strong&gt; (called &amp;quot;Handshake messages&amp;quot; in MLS), which members use to manage group membership and cryptographic secrets. Since this is all mediated through one server, the members can rely on the server to broadcast their messages to the rest of the group.&lt;&#x2F;p&gt;
&lt;p&gt;With the setup out of the way, what are the options?&lt;&#x2F;p&gt;
&lt;h2 id=&quot;solution-1-pairwise-channels&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#solution-1-pairwise-channels&quot; aria-label=&quot;Anchor link for: solution-1-pairwise-channels&quot;&gt;§&lt;&#x2F;a&gt;
Solution #1: Pairwise Channels&lt;&#x2F;h2&gt;
&lt;p&gt;Suppose Wilna, Xavier, Yolanda, and Zayne all know each other&#x27;s public keys for digital signatures. This means that each pair of people can do an authenticated Diffie-Hellman key exchange over some auxiliary messages and derive a shared symmetric key called the &lt;strong&gt;pair key&lt;&#x2F;strong&gt;. This process produces six separate &lt;strong&gt;pairwise channels&lt;&#x2F;strong&gt;, represented here:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;assets&#x2F;images&#x2F;post_molasses&#x2F;pairwise_channels.svg&quot; alt=&quot;pairwise channels between 4 members&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;If Wilna wants to send an application message &lt;em&gt;m&lt;&#x2F;em&gt; to the group, she has to encrypt it three separate times (once for each member of the group) and send all the ciphertexts:&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;pairwise_app_msg.svg&quot; alt=&quot;Pairwise encryption of application message&quot;&gt;
  
    &lt;figcaption&gt;
      The grey arrows represent application messages encrypted under a symmetric key.
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;Note that Wilna isn&#x27;t making use of the server&#x27;s ability to broadcast messages, since each member in the group can only decrypt messages encrypted under their own pair keys. Generalizing this, if there is a group of size &lt;em&gt;N&lt;&#x2F;em&gt;, sending an application message requires a member to encrypt and send &lt;em&gt;N-1&lt;&#x2F;em&gt; times. Roughly speaking, this is how iMessage does group chat.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#good_source&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Great, so that&#x27;s just three encryptions per person. This probably takes at most a few milliseconds on a phone. What&#x27;s the issue? The issue is what about the WhatsApp groups with &amp;gt;10,000 members where my aunts talk about who&#x27;s getting married next?? Do you want them to do 9,999 encryptions every time they send something? I do, but they probably don&#x27;t. To accomodate my aunts, we need to get cleverer.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;solution-2-sender-keys&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#solution-2-sender-keys&quot; aria-label=&quot;Anchor link for: solution-2-sender-keys&quot;&gt;§&lt;&#x2F;a&gt;
Solution #2: Sender Keys&lt;&#x2F;h2&gt;
&lt;p&gt;Instead of having a key between every user in the group, let&#x27;s give every user a &lt;strong&gt;sender key&lt;&#x2F;strong&gt; that they use to encrypt application messages. This is roughly what Signal,&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#good_source&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; WhatsApp,&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#good_source&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; and Keybase&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#keybase_source&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; do. If you&#x27;re a group member, you have to go through the following setup:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Randomly generate your sender key&lt;&#x2F;li&gt;
&lt;li&gt;For every user in the group, encrypt your sender key with your pair key that you share with that user&lt;&#x2F;li&gt;
&lt;li&gt;Send every user their encrypted copy of your sender key as an auxiliary message&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;After the setup, which requires &lt;em&gt;N-1&lt;&#x2F;em&gt; encryptions for each user in a group of size &lt;em&gt;N&lt;&#x2F;em&gt; (that&#x27;s Θ(&lt;em&gt;N&lt;&#x2F;em&gt;&lt;sup&gt;2&lt;&#x2F;sup&gt;) total auxiliary messages), we finally see some efficient behavior. To send an application message &lt;em&gt;m&lt;&#x2F;em&gt;, Wilna:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Encrypts &lt;em&gt;m&lt;&#x2F;em&gt; with her sender key &lt;em&gt;precisely once&lt;&#x2F;em&gt;&lt;&#x2F;li&gt;
&lt;li&gt;Broadcasts the ciphertext to the group&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;sender_key_app_msg.svg&quot; alt=&quot;Sender key encrypted message broadcast&quot;&gt;
  
    &lt;figcaption&gt;
      The grey arrows represent application messages encrypted under a symmetric key.
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;Although there are three arrows here, they are all the same ciphertext, so the application message only needs to be encrypted and broadcast &lt;em&gt;once&lt;&#x2F;em&gt;. Thus, after the setup phase, each outgoing application message only costs a single encryption. So we&#x27;re done, right? Wrong, of course wrong. Because&lt;&#x2F;p&gt;
&lt;h3 id=&quot;what-about-removal&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-about-removal&quot; aria-label=&quot;Anchor link for: what-about-removal&quot;&gt;§&lt;&#x2F;a&gt;
What about Removal?&lt;&#x2F;h3&gt;
&lt;p&gt;The fallacy here is that the setup phase runs once. It actually runs every time the group is modified. Suppose in the process of premeditating this &amp;quot;retirement party,&amp;quot; the group finds out that Zayne has been leaking details to Vince the whole time. Naturally, they kick Zayne out. Now Zayne still knows all the sender keys, so if he talks to Vince and gets an encrypted transcript of the group conversation that happened after his departure, he would still be able to decrypt it. This is a no-no, since Zayne has already defected. To prevent this from happening, each remaining user in the group has to create a new sender key and share it with everyone else through their pairwise channels. Again, this is Θ(&lt;em&gt;N&lt;&#x2F;em&gt;&lt;sup&gt;2&lt;&#x2F;sup&gt;) total auxiliary messages, which can be a &lt;em&gt;lot&lt;&#x2F;em&gt;. So if we want to tolerate tons of group modifications,&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#removal&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; we&#x27;re going to have to find a way to bring down the number of auxiliary messages sent during the setup phase, while still being able to keep using sender keys for application messages. A well-known secret in computer science is that when the naïve solutions of pairs and lists don&#x27;t work, there&#x27;s a next logical step:&lt;&#x2F;p&gt;
&lt;h2 id=&quot;solution-3-trees&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#solution-3-trees&quot; aria-label=&quot;Anchor link for: solution-3-trees&quot;&gt;§&lt;&#x2F;a&gt;
Solution #3: Trees&lt;&#x2F;h2&gt;
&lt;p&gt;We would like to have sender keys (since they make application messages efficient). We also want to be able to transmit new sender keys to subsets of the group without using too many auxiliary messages. The important insight here is that, when we remove a member, we shouldn&#x27;t need to &lt;em&gt;individually&lt;&#x2F;em&gt; send new keying information to every single remaining member like we had to in the previous solution. After all, we need to send this to the whole group minus just one person. So why not have public keys that cover large subsets of the group, and use those for sending auxiliary messages? This is exactly what the MLS ratchet tree (a.k.a. TreeKEM) affords us.&lt;&#x2F;p&gt;
&lt;p&gt;The MLS &lt;strong&gt;ratchet tree&lt;&#x2F;strong&gt; is a binary tree&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#tree&quot;&gt;5&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; whose leaves correspond to members of the group, and whose non-leaf nodes, called &lt;strong&gt;intermediate nodes&lt;&#x2F;strong&gt;, carry a Diffie-Hellman public key and private key. Intermediate nodes don&#x27;t represent people, computers, or locations on a network; they&#x27;re just pieces of data that facilitate auxiliary message sending. We also allow nodes to be &lt;strong&gt;blank&lt;&#x2F;strong&gt;, meaning that they do not have an associated keypair. A node that does have an associated keypair is said to be &lt;strong&gt;filled&lt;&#x2F;strong&gt;. Every member in the group retains a copy of the ratchet tree, minus the private keys. Knowledge of the private keys follows the ratchet tree property:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Ratchet Tree Property&lt;&#x2F;strong&gt; If a member &lt;em&gt;M&lt;&#x2F;em&gt; is a descendant of intermediate node &lt;em&gt;N&lt;&#x2F;em&gt;, then &lt;em&gt;M&lt;&#x2F;em&gt; knows the private key of &lt;em&gt;N&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;em&gt;*deep breath*&lt;&#x2F;em&gt; Sender keys are derived via key-derivation function (KDF) from the root node&#x27;s private key, and private keys are derived via KDF from its most-recently updated child&#x27;s private key.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#falsehoods&quot;&gt;6&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; Upon the removal of a user, new private keys are distributed to the &lt;strong&gt;resolutions of the copath nodes&lt;&#x2F;strong&gt;, i.e, the maximal non-blank nodes of the subtrees whose root is the sibling of an updated node.&lt;&#x2F;p&gt;
&lt;p&gt;That paragraph alone took about 10 minutes to write, so let&#x27;s just see&lt;&#x2F;p&gt;
&lt;h3 id=&quot;a-small-example&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-small-example&quot; aria-label=&quot;Anchor link for: a-small-example&quot;&gt;§&lt;&#x2F;a&gt;
A Small Example&lt;&#x2F;h3&gt;
&lt;p&gt;We start off with a group like so&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;assets&#x2F;images&#x2F;post_molasses&#x2F;initial_tree.svg&quot; alt=&quot;Initial tree&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Zayne wants out, so Yolanda removes him.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#self_removal&quot;&gt;7&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; To remove him, Yolanda will first blank out Zayne and all his ancestors:&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;blanked_tree.svg&quot; alt=&quot;Tree after blanking&quot;&gt;
  
    &lt;figcaption&gt;
      The boxes with red slashes through them represent blank nodes
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;Yolanda needs to contribute new keying information to the new group so that the new sender keys can be derived from the new root&#x27;s private key. To do this, she generates a new personal keypair pub&lt;sub&gt;&lt;em&gt;Y&#x27;&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt; and priv&lt;sub&gt;&lt;em&gt;Y&#x27;&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt; and derives all her ancestors&#x27; keypairs by iteratively applying a KDF to the private key and computing its corresponding public key (this is called &amp;quot;ratcheting,&amp;quot; whence &amp;quot;ratchet tree&amp;quot;).&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;updating_tree_1.svg&quot; alt=&quot;Tree with new secrets&quot;&gt;
  
    &lt;figcaption&gt;
      The green circles indicate recently updated nodes
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;But Yolanda isn&#x27;t done. Wilna and Xavier need to be told about these new keys somehow. It&#x27;s Yolanda&#x27;s job to share this info. In particular,&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Every member needs to get a copy of the public keys of all updated nodes (i.e., Yolanda&#x27;s own public key and all her ancestors&#x27;). This is important. The public keys are part of the shared group state, and shared group state is how a bunch of values in the MLS protocol are derived.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Every member needs to get a copy of the private keys of their nearest modified ancestor. This is in order to preserve the ratchet tree property.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Remember that the end goal is still to derive the sender keys, which means that Wilna and Xavier need to be told the value of the root private key, priv&lt;sub&gt;&lt;em&gt;Y&#x27;&#x27;&#x27;&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt;. This will be a consequence of item two above.&lt;&#x2F;p&gt;
&lt;p&gt;Since everyone needs public keys and public keys are not secret, Yolanda can just broadcast them as unencrypted auxiliary messages. But private keys are more sensitive. She needs to encrypt them for &lt;em&gt;just&lt;&#x2F;em&gt; the members who need them. This is where we use the ratchet tree property. If she wants Wilna and Xavier to be able to read an auxiliary message containing priv&lt;sub&gt;&lt;em&gt;Y&#x27;&#x27;&#x27;&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt;, she need only encrypt the message under pub&lt;sub&gt;&lt;em&gt;WX&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt;, since Wilna and Xavier are descendants of the &lt;em&gt;WX&lt;&#x2F;em&gt; intermediate node, and will therefore be able to decrypt anything encrypted under pub&lt;sub&gt;&lt;em&gt;WX&lt;&#x2F;em&gt;&lt;&#x2F;sub&gt;.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#hpke&quot;&gt;8&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; This describes how the auxiliary messages are sent to the rest of the group:&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;updating_tree_2.svg&quot; alt=&quot;Tree and auxiliary messages&quot;&gt;
  
    &lt;figcaption&gt;
      The solid black arrows above indicate public-key encrypted messages. The dashed arrows indicate plaintext messages. The arrows do not indicate who is doing the sending (since that&#x27;s all Yolanda). They&#x27;re just meant to illustrate where in the tree the values are coming from and whom they&#x27;re intended for.
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;Now Wilna and Xavier will update their view of the tree by saving the public keys and decrypting the root private key. Thus, everyone is on the same page and the ratchet tree property is preserved. Finally, everyone re-derives their sender keys, and the removal is complete.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;assets&#x2F;images&#x2F;post_molasses&#x2F;post_remove_tree.svg&quot; alt=&quot;Tree post-removal&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Note that Zayne&#x27;s position remains blank after the removal. This saves the members from the computational overhead of shuffling themselves around and recomputing their ancestors&#x27; keypairs. MLS defines two ways to prevent removed members from overcrowding the tree: it allows blank nodes to be removed from the right end of the tree after removals (not applicable in the example above), and it allows new members to be added in the position of previously removed members. So if the &amp;quot;party-planners&amp;quot; above wanted to replace Zayne, they could do so without making the tree bigger.&lt;&#x2F;p&gt;
&lt;p&gt;This example illustrates the smaller details in updating keys, but it doesn&#x27;t do a particularly good job at illustrating which node secrets are sent to which other nodes in the resolutions of the copath nodes. To give an idea, here&#x27;s&lt;&#x2F;p&gt;
&lt;h3 id=&quot;a-much-bigger-example&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#a-much-bigger-example&quot; aria-label=&quot;Anchor link for: a-much-bigger-example&quot;&gt;§&lt;&#x2F;a&gt;
A Much Bigger Example&lt;&#x2F;h3&gt;
&lt;p&gt;Suppose Zayne wants to break out and go solo, but still feels the desire to be in a boy band. After cloning himself 15 times, Zayne #1 notices that one of the clones, Zayne #11, keeps hinting at breaking off and doing a solo career of his own. Zayne #1 acquiesces and removes him from the group. He sees what he&#x27;s created. Zayne #1 looks up at the stars. War soon.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s see what auxiliary messages were sent when Zayne #11 was booted. In this removal process, Zayne #1 generates new secrets, ratchets them all the way up the tree, and shares them with the appropriate subtrees:&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;updating_clone_tree.svg&quot; alt=&quot;Updating tree of clones&quot;&gt;
  
    &lt;figcaption&gt;
      The green circles still represent the updated nodes. The solid arrows represent the private key of its tail being encrypted under the public key of its head.
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;Notice on the right hand side of the tree, since you can&#x27;t encrypt to a blank node, the root private key needs to be encrypted under three separate public keys. The dashed arrows were omitted for clarity, but it&#x27;s still true that the public keys of all the circled nodes are broadcasted in this step.&lt;&#x2F;p&gt;
&lt;p&gt;With this larger example, you might start to see some pattern in how many auxiliary messages are sent per tree update. Let&#x27;s play&lt;&#x2F;p&gt;
&lt;h3 id=&quot;can-you-eyeball-the-asymptotic-behavior&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#can-you-eyeball-the-asymptotic-behavior&quot; aria-label=&quot;Anchor link for: can-you-eyeball-the-asymptotic-behavior&quot;&gt;§&lt;&#x2F;a&gt;
Can You Eyeball the Asymptotic Behavior?&lt;&#x2F;h3&gt;
&lt;p&gt;We got efficient application messages with sender keys, and we&#x27;d like to say that we got efficient auxiliary messages with TreeKEM so we can call it a day. Is this true? Absolutely not, at least not entirely. Let&#x27;s first talk about the example above, where we start off with a tree whose nodes are all filled.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;removal-in-a-filled-tree&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#removal-in-a-filled-tree&quot; aria-label=&quot;Anchor link for: removal-in-a-filled-tree&quot;&gt;§&lt;&#x2F;a&gt;
Removal in a Filled Tree&lt;&#x2F;h4&gt;
&lt;p&gt;The Zayne example is actually worst-case removal behavior in a filled tree in terms of number of auxiliary messages (you should prove this to yourself: what would happen if Zayne #1 removed Zayne #6 instead?). If there are &lt;em&gt;N&lt;&#x2F;em&gt; many members in the group, there are at most log(&lt;em&gt;N&lt;&#x2F;em&gt;)-1 encrypted auxiliary messages that don&#x27;t have to deal with blank nodes, and another log(&lt;em&gt;N&lt;&#x2F;em&gt;)-1 that do. Plus, there are log(&lt;em&gt;N&lt;&#x2F;em&gt;) many public keys to share. So, to complete the sage wisdom from computer scientists of days past, if you use trees, you get &lt;em&gt;O&lt;&#x2F;em&gt;(log(&lt;em&gt;N&lt;&#x2F;em&gt;)) behavior. This is way better than the quadratic number of auxiliary messages we saw in solution #2. The same WhatsApp group of kibbitzing mumehs now only takes about 3log&lt;sub&gt;2&lt;&#x2F;sub&gt;(10,000) ≈ 40 total auxiliary messages to establish a new set of sender keys (assuming a filled tree) instead of the &lt;em&gt;N&lt;&#x2F;em&gt;(&lt;em&gt;N&lt;&#x2F;em&gt;-1) ≈ 99 million total auxiliary messages required previously.&lt;&#x2F;p&gt;
&lt;h4 id=&quot;removal-in-a-tree-with-blanks&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#removal-in-a-tree-with-blanks&quot; aria-label=&quot;Anchor link for: removal-in-a-tree-with-blanks&quot;&gt;§&lt;&#x2F;a&gt;
Removal in a Tree with Blanks&lt;&#x2F;h4&gt;
&lt;p&gt;This logarithmic behavior is fantastic, but we only checked for the very specific case where we start with a full group and then remove one person. How efficient is it when we remove a single person from a group that already has some blanks? The good news is that it&#x27;s still better than Θ(&lt;em&gt;N&lt;&#x2F;em&gt;&lt;sup&gt;2&lt;&#x2F;sup&gt;). The bad news is that the worst case is...well let me just show you.&lt;&#x2F;p&gt;
&lt;p&gt;Suppose every odd-numbered Zayne was removed from the group besides Zayne #1. Finally, Zayne #2 deals the finishing blow, removing Zayne #1 and restoring peace. This is what the update looks like:&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;post_molasses&amp;#x2F;linear_tree.svg&quot; alt=&quot;A tree with linear removal behavior&quot;&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;That&#x27;s &lt;em&gt;N&lt;&#x2F;em&gt;-1 messages to remove a single person! As mentioned before, this can be a prohibitively large number of auxiliary messages for large &lt;em&gt;N&lt;&#x2F;em&gt;. Even worse, it may be possible for malicious group members to strategically remove people until the tree reaches the worst-case state, thus slowing down group operations for everyone in the group.&lt;&#x2F;p&gt;
&lt;p&gt;Dealing with this situation is an open issue, and people are actively working on resolving or at least mitigating it. As of this writing, though, there are no proposed solutions that would materially improve the worst-case behavior.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;conclusion-and-more-info&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#conclusion-and-more-info&quot; aria-label=&quot;Anchor link for: conclusion-and-more-info&quot;&gt;§&lt;&#x2F;a&gt;
Conclusion and More Info&lt;&#x2F;h1&gt;
&lt;p&gt;It&#x27;s underwhelming to end at an open issue, but this is where the protocol stands today. Efficiently updating keys is at the crux of end-to-end group messaging. The TreeKEM method, edge cases and all, is one of the most important singular contributions that MLS makes. Given that there&#x27;s still at least one open issue in the spec, you may wonder&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-close-is-the-protocol-to-being-done&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-close-is-the-protocol-to-being-done&quot; aria-label=&quot;Anchor link for: how-close-is-the-protocol-to-being-done&quot;&gt;§&lt;&#x2F;a&gt;
How close is the protocol to being done?&lt;&#x2F;h2&gt;
&lt;p&gt;No clue. MLS has plenty of open issues (nine as of this writing) and is being tweaked constantly. Draft 7 landed just this month, and it completely overhauled the symmetric key schedule. Inefficiencies are being shaved down as issues around authenticity, confidentiality, deniability, etc. are being patched.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-are-the-other-implementations&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#what-are-the-other-implementations&quot; aria-label=&quot;Anchor link for: what-are-the-other-implementations&quot;&gt;§&lt;&#x2F;a&gt;
What are the other implementations?&lt;&#x2F;h2&gt;
&lt;p&gt;The unofficial reference implementation, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cisco&#x2F;mlspp&quot;&gt;&lt;code&gt;mlspp&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, is used to create test vectors that we implementers all test against. There&#x27;s also &lt;code&gt;MLS*&lt;&#x2F;code&gt;, a project at Inria to implement and formally model the protocol in &lt;a href=&quot;https:&#x2F;&#x2F;www.fstar-lang.org&#x2F;&quot;&gt;F*&lt;&#x2F;a&gt;. And there&#x27;s even another Rust implementation, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;wireapp&#x2F;melissa&#x2F;&quot;&gt;&lt;code&gt;melissa&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, being written at Wire.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;remind-me-why-you-re-writing-yet-another-rust-implementation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#remind-me-why-you-re-writing-yet-another-rust-implementation&quot; aria-label=&quot;Anchor link for: remind-me-why-you-re-writing-yet-another-rust-implementation&quot;&gt;§&lt;&#x2F;a&gt;
Remind me why you&#x27;re writing yet another Rust implementation?&lt;&#x2F;h2&gt;
&lt;p&gt;The more implementations the better. Writing this implementation has helped find errors in &lt;code&gt;mlspp&lt;&#x2F;code&gt; and the specification itself.&lt;&#x2F;p&gt;
&lt;p&gt;Errors found in &lt;code&gt;mlspp&lt;&#x2F;code&gt; include missing important fields (missing protocol version and missing hash of WelcomeInfo, which enforces sequencing), incorrect tree addressing (using leaf indices instead of node indices and vice-versa), and incorrectly generated test vectors. Errors in the specification that we found include ambiguities (how are removed nodes pruned from the ratchet tree?), logical impossibilities (how can you add a user to the group if your WelcomeInfo doesn&#x27;t include the current decryption keys?), and deontological omissions (SHOULD&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#should&quot;&gt;9&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; a user verify the broadcasted pubkeys against their derived pubkeys or not?).&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ok-great-but-why-rust&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#ok-great-but-why-rust&quot; aria-label=&quot;Anchor link for: ok-great-but-why-rust&quot;&gt;§&lt;&#x2F;a&gt;
Ok great, but why Rust?&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;*cracks knuckles*&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I thought it would be nice to have an MLS implementation that has a clear API (thanks to &lt;code&gt;molasses&lt;&#x2F;code&gt;&#x27; careful design and Rust&#x27;s strong typing), memory-safe semantics (thanks to the Rust borrow checker), thorough documentation (thanks to &lt;code&gt;cargo doc&lt;&#x2F;code&gt; and &lt;code&gt;molasses&lt;&#x2F;code&gt;&#x27; current 43% comment-code ratio), and good performance (thanks to &lt;a href=&quot;&#x2F;assets&#x2F;images&#x2F;resf_orig.jpg&quot;&gt;ZERO-COST-ABSTRACTIONS&lt;&#x2F;a&gt;. Of course, none of these features make up for the fact that &lt;code&gt;molasses&lt;&#x2F;code&gt; is not formally verified like &lt;code&gt;MLS*&lt;&#x2F;code&gt; and may never be, but hey, nobody ever complained that cotton isn&#x27;t as bulletproof as kevlar, cuz those are for different things.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-can-i-help&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-can-i-help&quot; aria-label=&quot;Anchor link for: how-can-i-help&quot;&gt;§&lt;&#x2F;a&gt;
How can I help?&lt;&#x2F;h2&gt;
&lt;p&gt;I don&#x27;t recommend filing issues with &lt;code&gt;molasses&lt;&#x2F;code&gt; quite yet. The spec is moving too quickly and the library has to be redesigned accordingly each time. If you would like to contribute, the &lt;a href=&quot;https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;wg&#x2F;mls&#x2F;about&#x2F;&quot;&gt;MLS IETF page&lt;&#x2F;a&gt; has a mailing list where you can read and participate in discussions. The organizers are helpful and patient, and I appreciate them immensely. If you want to write your own implementation, see the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mlswg&#x2F;mls-implementations&quot;&gt;implementers&#x27; Github repo&lt;&#x2F;a&gt; for organizing info and test vectors.&lt;&#x2F;p&gt;
&lt;p&gt;If you are interested in reading more about the protocol and seeing some of the other open issues, you should give &lt;a href=&quot;https:&#x2F;&#x2F;datatracker.ietf.org&#x2F;doc&#x2F;draft-ietf-mls-protocol&#x2F;&quot;&gt;the spec&lt;&#x2F;a&gt;&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#spec&quot;&gt;10&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; a read.&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;pcs&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;Full post-compromise security, i.e., the problem of non-deterministically deriving all new shared data so as to make the excluded parties unable to participate, is actually not easily achieved in this scheme. There is ongoing research in characterizing how post-compromise secure MLS is after a certain number of group updates.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;good_source&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;eprint.iacr.org&#x2F;2017&#x2F;666.pdf&quot;&gt;Source&lt;&#x2F;a&gt;. This is a fantastic paper which provides a lot of context for this article. Seriously, if you want to understand this topic better, you should read the MLS spec and this paper and compare the two, since they differ in pretty subtle but significant ways. E.g., the ART scheme used in the paper does not allow intermediate nodes to be blank, which affects confidentiality of messages sent to offline members.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;keybase_source&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;3&lt;&#x2F;sup&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;rwc.iacr.org&#x2F;2019&#x2F;slides&#x2F;keybase-rwc2019.pdf&quot;&gt;Source&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;removal&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;4&lt;&#x2F;sup&gt;
&lt;p&gt;The problem of Removal in this article is a placeholder for (a weaker form of) post-compromise security. Here, &amp;quot;group modifications&amp;quot; includes updating key material without changing group membership.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;self_removal&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;7&lt;&#x2F;sup&gt;
&lt;p&gt;MLS doesn&#x27;t allow users to remove themselves. This is a quirk of the protocol, but it doesn&#x27;t really affect anything.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;tree&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;5&lt;&#x2F;sup&gt;
&lt;p&gt;Specifically, it is a left-balanced binary tree. This is fancy computer talk for &amp;quot;every left subtree is full,&amp;quot; which itself is fancy computer talk for &amp;quot;it behaves good when stuffed into an array.&amp;quot;&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;falsehoods&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;6&lt;&#x2F;sup&gt;
&lt;p&gt;Both these statements are technically false, but it’s way easier to think of things this way, and it’s close enough to the truth imo. In reality, sender keys are derived from a long chain of secret values relating to group state and state transitions. Node private keys are simpler, but they are also derived from chains of other secrets called &amp;quot;node secrets&amp;quot; and &amp;quot;path secrets.&amp;quot; As always, see the spec for more details.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;hpke&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;8&lt;&#x2F;sup&gt;
&lt;p&gt;If you&#x27;re confused why I say all these keys are Diffie-Hellman keys and then use public-key encryption, it&#x27;s because the public-key encryption in MLS is done with &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Integrated_Encryption_Scheme&quot;&gt;ECIES&lt;&#x2F;a&gt;. More specifically, it&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;draft-barnes-cfrg-hpke-01&quot;&gt;HPKE&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;should&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;9&lt;&#x2F;sup&gt;
&lt;p&gt;The all-caps &amp;quot;SHOULD&amp;quot; means something specific in IETF RFCs. Its meaning is governed by not one but two RFCs, which are referred to as &lt;a href=&quot;https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;bcp14&quot;&gt;Best Current Practice 14&lt;&#x2F;a&gt;. The linguistic conventions of RFCs are super cool and alone make it worth skimming a few specs and paying attention to their &amp;quot;conventions and terminology&amp;quot; sections. &lt;a href=&quot;https:&#x2F;&#x2F;tools.ietf.org&#x2F;html&#x2F;rfc8446&quot;&gt;TLS&lt;&#x2F;a&gt; is as good a place to start as any.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;spec&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;10&lt;&#x2F;sup&gt;
&lt;p&gt;If you want a particularly nice reading experience, you should compile the spec yourself from &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;mlswg&#x2F;mls-protocol&quot;&gt;source&lt;&#x2F;a&gt;. It really is appreciably better.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</description>
      </item>
      <item>
          <title>Siderophile: Expose your Crate&#x27;s Unsafety</title>
          <pubDate>Mon, 01 Jul 2019 00:00:00 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/siderophile/</link>
          <guid>https://mrosenberg.pub/blog/siderophile/</guid>
          <description>&lt;p&gt;&lt;em&gt;This article was originally posted on Trail of Bits&#x27; &lt;a href=&quot;https:&#x2F;&#x2F;blog.trailofbits.com&#x2F;2019&#x2F;07&#x2F;01&#x2F;siderophile-expose-your-crates-unsafety&#x2F;&quot;&gt;blog&lt;&#x2F;a&gt; on July 1, 2019&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Siderophile ([ˈsidərəˌfīl]) — Having an affinity for metallic iron&lt;&#x2F;em&gt;&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Today we released a tool, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;trailofbits&#x2F;siderophile&quot;&gt;&lt;code&gt;siderophile&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, that helps Rust developers find fuzzing targets in their codebases.&lt;&#x2F;p&gt;
&lt;p&gt;Siderophile trawls your crate&#x27;s dependencies and attempts to finds every unsafe function, expression, trait method, etc. It then traces these up the callgraph until it finds the function in your crate that uses the unsafety. It ranks the functions it finds in your crate by badness—the more unsafety a function makes use of, the higher its badness rating.&lt;&#x2F;p&gt;
&lt;p&gt;We created Siderophile for an engagement where we were delivered a massive Rust codebase with a tight timeframe for review. We wanted to fuzz it but weren&#x27;t even sure where to start. So, we created a tool to determine which functions invoked the most unsafe behavior. We were able to speed up our bug discovery by automating the targeting process with siderophile. We&#x27;re now open-sourcing this tool so everyone can benefit from it!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;sample-output&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#sample-output&quot; aria-label=&quot;Anchor link for: sample-output&quot;&gt;§&lt;&#x2F;a&gt;
Sample Output&lt;&#x2F;h1&gt;
&lt;p&gt;Here is a sample of &lt;code&gt;siderophile&lt;&#x2F;code&gt; when run on &lt;code&gt;molasses&lt;&#x2F;code&gt;, a crate we&#x27;re building that implements the [MLS cryptographic protocol]({% link _posts&#x2F;2019-07-10-molasses.md %}):&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;Badness Function
    012 molasses::crypto::hash::HashFunction::hash_serializable
    005 molasses::crypto::hash::HashContext::feed_serializable
    003 molasses::utils::derive_node_values
    003 molasses::application::encrypt_application_message
    003 molasses::application::decrypt_application_message
    003 molasses::group_ctx::GroupContext::new_from_parts
    003 molasses::group_ctx::GroupContext::from_welcome
    003 molasses::group_ctx::GroupContext::update_transcript_hash
    003 molasses::group_ctx::GroupContext::update_tree_hash
    003 molasses::group_ctx::GroupContext::update_epoch_secrets
    003 molasses::group_ctx::GroupContext::apply_update
    ...
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, much of the unsafety comes from the serialization and crypto-heavy routines. We&#x27;ll be sure to fuzz this bad boy before it goes 1.0.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;limitations&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#limitations&quot; aria-label=&quot;Anchor link for: limitations&quot;&gt;§&lt;&#x2F;a&gt;
Limitations&lt;&#x2F;h1&gt;
&lt;p&gt;This is not guaranteed to catch all the unsafety in a crate&#x27;s deps. For instance, we don&#x27;t have the ability to inspect macros or resolve dynamically dispatched methods since unsafe tagging only occurs at a source-level. The ergonomics for the tool could be better, and we&#x27;ve already identified some incorrect behavior on certain crates. If you&#x27;re interested in helping out, please do! We are actively maintaining the project and have some issues written out.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;try-it-out&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#try-it-out&quot; aria-label=&quot;Anchor link for: try-it-out&quot;&gt;§&lt;&#x2F;a&gt;
Try it Out&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;code&gt;siderophile&lt;&#x2F;code&gt; is on Github along with a better explanation of how it works and how to run the tool. You should run it on your Rust crate and set up fuzzers for what it finds. &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;trailofbits&#x2F;siderophile&quot;&gt;Check it out&lt;&#x2F;a&gt;!&lt;&#x2F;p&gt;
&lt;p&gt;Finally, thanks to &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;anderejd&#x2F;cargo-geiger&quot;&gt;cargo-geiger&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;praezi&#x2F;rust&#x2F;&quot;&gt;rust-praezi&lt;&#x2F;a&gt; for current best practices. This project is mostly due to their work.&lt;&#x2F;p&gt;
</description>
      </item>
      <item>
          <title>Confidential Transactions from Cryptographic Primitives</title>
          <pubDate>Fri, 07 Jun 2019 02:53:07 +0000</pubDate>
          <author>Michael Rosenberg</author>
          <link>https://mrosenberg.pub/blog/confidential-transactions/</link>
          <guid>https://mrosenberg.pub/blog/confidential-transactions/</guid>
          <description>&lt;p&gt;&lt;em&gt;This article was originally posted on NCC Group&#x27;s crypto services &lt;a href=&quot;https:&#x2F;&#x2F;cryptoservices.github.io&#x2F;cryptography&#x2F;2017&#x2F;07&#x2F;21&#x2F;Sigs.html&quot;&gt;blog&lt;&#x2F;a&gt; on July 21, 2017&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;During my time at NCC Group this summer, I had the opportunity to dig into all sorts of cryptocurrency software to see how they work and what kind of math they rely on. One sought-after property that some cryptocurrencies (ZCash, Monero, all CryptoNote-based coins) support is &lt;a href=&quot;https:&#x2F;&#x2F;elementsproject.org&#x2F;elements&#x2F;confidential-transactions&#x2F;&quot;&gt;confidential transactions&lt;&#x2F;a&gt;. To explain what this means, we&#x27;ll first look at what Bitcoin transactions do.&lt;&#x2F;p&gt;
&lt;p&gt;At its core, a Bitcoin transaction is just a tuple $(\{a_i\}, \{b_i\}, \{v_i\})$ where $\{a_i\}$ are the input addresses, $\{b_i\}$ are the output addresses, and $\{v_i\}$ are the amounts that go to each output. We&#x27;ll ignore the proof-of-work aspect, since it isn&#x27;t quite relevant to where we&#x27;re going with this. Each transaction appears unencrypted for the whole world to see in the public ledger. This is all well and good, but it makes transactions &lt;a href=&quot;https:&#x2F;&#x2F;bitcoin.org&#x2F;en&#x2F;protect-your-privacy&quot;&gt;easy&lt;&#x2F;a&gt; to &lt;a href=&quot;https:&#x2F;&#x2F;www.sciencemag.org&#x2F;news&#x2F;2016&#x2F;03&#x2F;why-criminals-cant-hide-behind-bitcoin&quot;&gt;trace&lt;&#x2F;a&gt;, even when the coins go through multiple owners. One way to make this harder is to use a tumbler, which essentially takes in Bitcoin from many sources, mixes them around, and hands back some fresh uncorrelated coins (you might be familiar with this concept under the term &amp;quot;money laundering&amp;quot;).&lt;&#x2F;p&gt;
&lt;p&gt;The goal of confidential transactions is to let &lt;em&gt;just&lt;&#x2F;em&gt; the participants of a transactions see the $v_i$ values, and otherwise hide them from the rest of the world. But at the same time, we want non-participants to be able to tell when a transaction is bogus. In particular, we don&#x27;t want a user to be able to print money by spending more than they actually have. This property was easily achieved in the Bitcoin scheme, since the number of Bitcoin in each address $a_i$ is publicly known. So a verifier need only check that the sum of the outputs doesn&#x27;t exceed the sum of account contents of the input addresses. But how do we do this when the account contents and the output values are all secret? To show how, we&#x27;ll need a primer in some core cryptographic constructions. There is a lot of machinery necessary to make this work, so bear with me.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;schnorr-signatures&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#schnorr-signatures&quot; aria-label=&quot;Anchor link for: schnorr-signatures&quot;&gt;§&lt;&#x2F;a&gt;
Schnorr Signatures&lt;&#x2F;h1&gt;
&lt;p&gt;The purpose of a signature is to prove to someone who knows your public information that you have seen a particular value. In the case of Schnorr Signatures, I am working in an abelian group $\mathbb{G}$ of prime order $q$ with generator $G$ and I have a public key $P = xG$ where $x \in \mathbb{Z}_q$ is my secret key.&lt;&#x2F;p&gt;
&lt;p&gt;First, we&#x27;ll start off with Schnorr proof of knowledge. As a prover, I would like to prove to a verifier that I know the value of $x$ without actually revealing it. Here&#x27;s how I do it:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;First, I pick a random $\alpha \leftarrow \mathbb{Z}_q$ and send $Q = \alpha G$ to the verifier.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;The verifier picks $e \leftarrow \mathbb{Z}_q$ and sends it to me.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;I calculate $s = \alpha - ex$ and send $s$ to the verifier.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Lastly, the verifier checks that $sG + eP = Q$. Note that if all the other steps were
performed correctly, then indeed&lt;&#x2F;p&gt;
&lt;p&gt;$$
sG + eP
=(\alpha - ex)G + exG
=\alpha G - exG + exG
= \alpha G
= Q
$$&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;We can quickly prove that this scheme is &lt;em&gt;sound&lt;&#x2F;em&gt; in the sense that being able to consistently pass verification implies knowledge of the secret $x$. To prove this, it suffices to show that an adversary with access to a prover $\mathcal{P}$ and the ability to rewind $\mathcal{P}$ can derive $x$ efficiently. Suppose I have such a $\mathcal{P}$. Running it the first time, I give it any value $e \leftarrow \mathbb{Z}_q$. $\mathcal{P}$ will return its proof $s$. Now I rewind $\mathcal{P}$ to just before I sent $e$. I send a different value $e&#x27; \neq e$ and receive its proof $s&#x27;$. With these two values, I can easily compute&lt;&#x2F;p&gt;
&lt;p&gt;$$
\frac{s - s&#x27;}{e&#x27; - e} = \frac{\alpha - ex - \alpha + e&#x27;x}{e&#x27; - e} = \frac{x(e&#x27; - e)}{e&#x27; - e} = x
$$&lt;&#x2F;p&gt;
&lt;p&gt;and, voilà, the private key is exposed.&lt;&#x2F;p&gt;
&lt;p&gt;Ok that was pretty irrelevant for where I&#x27;m going, but I thought it was a nice quick proof. So how can we use proof of knowledge to construct a signature? Well we can tweak the above protocol in order to &amp;quot;bind&amp;quot; our proofs of knowledge to a particular message $M \in \{0,1\}^* $. The trick is to use $M$ in the computation of $e$. This also makes the interactivity of this protocol unnecessary. That is, since I am computing $e$ myself, I don&#x27;t need a challenger to give it to me. But be careful! If we are able to pick $e$ without any restrictions in our proof-of-knowledge algorithm, then we can &amp;quot;prove&amp;quot; we know the private key to any public key $P$ by first picking random $e$ and $s$ and then retroactively letting $Q = sG + eP$. So in order to prevent forgery, $e$ must be difficult to compute before $Q$ is determined, while also being linked somehow to $M$. For this, we make use of a hash function $H: \{0,1\}^* \to \mathbb{Z}_q$. Here&#x27;s how the algorithm to sign $M \in \{0,1\}^*$ goes. Note that because this no longer interactive, there is no verifier giving me a challenge:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;I pick a random $\alpha \leftarrow \mathbb{Z}_q$ and let $Q = \alpha G$.&lt;&#x2F;li&gt;
&lt;li&gt;I compute $e = H(Q \| M)$&lt;&#x2F;li&gt;
&lt;li&gt;I compute $s = \alpha - ex$&lt;&#x2F;li&gt;
&lt;li&gt;I return the signature, which is the tuple $\sigma = (s, e)$&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Observe that because hash functions are difficult to invert, this algorithm essentially guarantees that $e$ is determined after $Q$. To verify a signature $(s, e)$ of the message $m$, do the following:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Let $Q = sG + eP$&lt;&#x2F;li&gt;
&lt;li&gt;Check that $e = H(Q \| M)$&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Fantastic! We&#x27;re now a fraction of the way to confidential transactions! The next step is to extend this type of proof to a context with multiple public keys.&lt;&#x2F;p&gt;
&lt;p&gt;(Extra credit: prove that Schnorr is sound in the Random Oracle Model. That is, assume an adversary has the ability to run and rewind the prover $\mathcal{P}$ as before, but now also has to ability to intercept queries to $H$ and return its own responses, as long as those responses are &lt;em&gt;random&lt;&#x2F;em&gt; and &lt;em&gt;consisent&lt;&#x2F;em&gt; with responses on the same query input)&lt;&#x2F;p&gt;
&lt;h1 id=&quot;aos-ring-signatures&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#aos-ring-signatures&quot; aria-label=&quot;Anchor link for: aos-ring-signatures&quot;&gt;§&lt;&#x2F;a&gt;
AOS Ring Signatures&lt;&#x2F;h1&gt;
&lt;p&gt;The signatures that end up being used in confidential transactions are called ring signatures. It&#x27;s the same idea as a regular signature, except less specific: a ring signature of the message $m$ over the public keys ${P_1, P_2, \ldots, P_n}$ proves that someone with knowledge of &lt;em&gt;one of the private keys&lt;&#x2F;em&gt; ${x_1, x_2, \ldots, x_n}$ has seen the message $m$. So this is a strict generalization of the signatures above, since regular signatures are just ring signatures where $n=1$. Furthermore, it is generally desired that a ring signature not reveal which private key it was that performed the signature. This property is called &lt;em&gt;signer ambiguity&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;www.iacr.org&#x2F;cryptodb&#x2F;archive&#x2F;2002&#x2F;ASIACRYPT&#x2F;50&#x2F;50.pdf&quot;&gt;Abe, Okhubo, Suzuki&lt;&#x2F;a&gt; ring signature scheme is a generalization of Schnorr Signatures. The core idea of scheme is, for each public key, we compute an $e$ value that depends on the &lt;em&gt;previous&lt;&#x2F;em&gt; $Q$ value, and all the $s$ values are random except for the one that&#x27;s required to &amp;quot;close&amp;quot; the ring. That &amp;quot;closure&amp;quot; is performed on the $e$ value whose corresponding public key and private key belong to us.&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll outline the algorithm in general and then give a concrete example. Denote the public keys by $\{P_1, \ldots, P_n\}$ and let $x_j$ be the private key of public key $P_j$. An AOS signature of $M \in \{0,1\}^*$ is computed as follows:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Pick $\alpha \leftarrow \mathbb{Z}_q$. $Q = \alpha G$ and let $e_{j+1} = H(Q \| M)$.&lt;&#x2F;li&gt;
&lt;li&gt;Starting at $j+1$ and wrapping around the modulus $n$, for each pick $s_i \leftarrow \mathbb{Z}_q$ and let $e_{i+1} = H(s_i G + e_i P_i \| M)$&lt;&#x2F;li&gt;
&lt;li&gt;Let $s_j = \alpha - e_jx_j$&lt;&#x2F;li&gt;
&lt;li&gt;Output the signature $\sigma = (e_0, s_0, s_1, \ldots, s_n)$.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;That&#x27;s very opaque, so here&#x27;s an example where there are the public keys $\{P_0, P_1, P_2\}$ and I know the value of $x_1$ such that $P_1 = x_1G$:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;I start making the ring at index 2: $\alpha \leftarrow \mathbb{Z}_q $. $e_2 = H(\alpha G \| M)$.&lt;&#x2F;li&gt;
&lt;li&gt;I continue making the ring. $s_2 \leftarrow \mathbb{Z}_q $. $e_0 = H(s_2 G + e_2 P_2 \| M) $.&lt;&#x2F;li&gt;
&lt;li&gt;I continue making the ring. $s_0 \leftarrow \mathbb{Z}_q $. $e_1 = H(s_0 G + e_0 P_0 \| M) $.&lt;&#x2F;li&gt;
&lt;li&gt;Now notice that $e_2$ has been determined in two ways: from before, $e_2 = H(\alpha G \| M)$, and also from the property which must hold for every $e$ value: $e_2 = H(s_1 G + e_1 P_1 \| M)$. The only $s_1$ that satisfies these constraints is $s_1 = \alpha - e_1x_1$, which I can easily compute, since I know $x_1$. 5. Finally, my signature is $\sigma = (e_0, s_0, s_1, s_2)$.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The way to verify this signature is to just step all the way through the ring until we loop back around, and then check that the final $e$ value matches the initial one. Here are steps for the above example; the general process should be easy to see:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Let $e_1 = H(s_0 G + e_0 P_0 \| M)$.&lt;&#x2F;li&gt;
&lt;li&gt;Let $e_2 = H(s_1 G + e_1 P_1 \| M)$.&lt;&#x2F;li&gt;
&lt;li&gt;Let $e&#x27;_0 = H(s_2 G + e_2 P_2 \| M)$.&lt;&#x2F;li&gt;
&lt;li&gt;Check that $e_0 = e&#x27;_0$.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The verification process checks that &lt;em&gt;some&lt;&#x2F;em&gt; $s$ value was calculated &lt;em&gt;after&lt;&#x2F;em&gt; all the $e$ values were determined, which implies that some secret key is known. Which $s$ it is is well-hidden, though. Notice that all the $s$ values but the last one are random. And also notice that the final $s$ value has $\alpha$ as an offset. But that $\alpha$ was chosen randomly and was never revealed. So this final $s$ value is completely indistinguishable from randomness, and is thus indistinguishable from the truly random $s$ values. Pretty cool, huh?&lt;&#x2F;p&gt;
&lt;p&gt;There&#x27;s one tweak we can make to this that&#x27;ll slightly improve efficiency and make notation easier. Including $M$ at every step really isn&#x27;t necessary. It just has to get mixed in at &lt;em&gt;some&lt;&#x2F;em&gt; point in the process. A natural place to put it is in $e_0 = H(s_{n-1} G + e_{n-1} P_{n-1} \| M)$ and calculate the other $e$ values without the $m$, like $e_{i+1} = H(s_iG + e_iP_i)$.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;borromean-ring-signatures&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#borromean-ring-signatures&quot; aria-label=&quot;Anchor link for: borromean-ring-signatures&quot;&gt;§&lt;&#x2F;a&gt;
Borromean Ring Signatures&lt;&#x2F;h1&gt;
&lt;p&gt;If you thought we were done generalizing, you&#x27;re dead wrong. We&#x27;ve got one more step to go. Consider the following situation (and withhold your cries for practical application for just a wee bit longer): there are multiple sets of public keys $\mathcal{A}_1, \mathcal{A}_2, \mathcal{A}_3 $. I, having one private key in each $\mathcal{A}_i $, would like to sign a message $M$ in each of these rings. In doing so, I am proving &amp;quot;Some key in $\mathcal{A}_1$ signed $M$ AND some key in $\mathcal{A}_2$ signed $M$ AND some key in $\mathcal{A}_3$ signed $M$.&amp;quot; The naïve approach is to make a separate AOS signature for each set of public keys, giving us a final signature of $\sigma = (\sigma_1, \sigma_2, \sigma_3)$. But it turns out that there is an (admittedly small) optimization that can make the final signature smaller.&lt;&#x2F;p&gt;
&lt;p&gt;Gregory Maxwell&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ElementsProject&#x2F;borromean-signatures-writeup&quot;&gt;Borromean ring signature scheme&lt;&#x2F;a&gt;&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#1&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; makes the optimization of pinning $e_0$ as a shared $e$ value for all rings $\mathcal{A}_i$. More specifically, the paper defines&lt;&#x2F;p&gt;
&lt;p&gt;$$ e_0 = H(R_0 | R_1 | \ldots | R_{n-1} | M) $$&lt;&#x2F;p&gt;
&lt;p&gt;where each $R_i = s_{i, m_i-1} G + e_{i, m_i-1} P_{i, m_i-1}$ when $j_i \neq m_i-1$, and $R_i = \alpha_i G$ otherwise, and $m_i$ denotes the number of public keys in the $i^\textrm{th}$ ring, and $j_i$ denotes the index of the known private key in the $i^\textrm{th}$ ring. The whole $R$ thing is a technicality. The gist is that the last $e$ and $s$ values of every ring (whether it correspond to the known private key or not) are incorporated into $e_0$. Here&#x27;s a pretty picture from the Maxwell Paper to aide your geometric intuition (if one believes in such silly things)&lt;&#x2F;p&gt;
&lt;figure&gt;
  &lt;img src=&quot;&amp;#x2F;assets&amp;#x2F;images&amp;#x2F;borromean.png&quot; alt=&quot;A Borromean ring signature on two rings&quot;&gt;
  
    &lt;figcaption&gt;
      A Borromean ring signature for $(P_0 | P_1| P_2) \&amp; (P_0&#x27; | P_3 | P_4)$
    &lt;&#x2F;figcaption&gt;
  
&lt;&#x2F;figure&gt;
&lt;p&gt;The signature itself looks like&lt;&#x2F;p&gt;
&lt;p&gt;$$
\sigma =
\left(
e_0, (s_{0,0}, s_{0,1}, \ldots, s_{1,m_0-1})
, \ldots ,
(s_{n-1,0}, \ldots, s_{n-1,m_{(n-1)}-1})
\right)
$$&lt;&#x2F;p&gt;
&lt;p&gt;where $s_{i,j}$ is the $j^\textrm{th}$ $s$ value in the $i^\textrm{th}$ ring.&lt;&#x2F;p&gt;
&lt;p&gt;For clarity, I did slightly modify some details from this paper, but I don&#x27;t believe that the modifications impact the security of the construction whatsoever. There is also the important detail of mixing the ring number and position in the ring into at least one $e$ value per-ring so that rings cannot be moved around without breaking the signature. The mixing is done by simply hashing the values into some $e$.&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, the end result of this construction is a method of constructing $n$ separate ring signatures using $\sum m_i + 1$ values (the $s$ values plus the one $e_0$) instead of the naïve way, in which we would have to include $e_{0,0}, e_{1,0}, \ldots, e_{(n-1),0}$. This saves us $n-1$ integers in the signature.&lt;&#x2F;p&gt;
&lt;p&gt;You might be wondering how large $n$ is that such savings are worth a brand-new signature scheme. If you are wondering that, stop reading, because you won&#x27;t get an answer. Onwards towards more theory!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;pedersen-commitments&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#pedersen-commitments&quot; aria-label=&quot;Anchor link for: pedersen-commitments&quot;&gt;§&lt;&#x2F;a&gt;
Pedersen Commitments&lt;&#x2F;h1&gt;
&lt;p&gt;Alright, we have all the signature technology we need. Now let&#x27;s turn that fear of math into fear of commitment(s). A commitment is a value that is published prior to the revealing of some information. The commitment proves that you knew that information before it was revealed. Suppose I wanted to prove to someone that I know the winner of tomorrow&#x27;s horse race, but I don&#x27;t want to tell them because they might make a massive bet and raise suspicion. I could tweet out the SHA256 hash&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;1c5d6a56ec257e5fe6f733e7&lt;&#x2F;code&gt;​&lt;code&gt;e81f6f2571475d44c09fa&lt;&#x2F;code&gt;​&lt;code&gt;a9ecdaa2ff1c4a49ecd&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Once the race is over, I tweet again, revealing that the preimage of the hash was &amp;quot;Cloud Computing&amp;quot;. Since finding the preimage of a hash function is capital-D-Difficult, I have effectively proven that I knew ahead of time that Cloud Computing would win (note: the set of possible winners is so small that someone can easily just try all the names and see what matches. In this case, I would pick a random number and commit to &amp;quot;Cloud Computing.ba9fd6d66f9bd53d&amp;quot; and then reveal &lt;em&gt;that&lt;&#x2F;em&gt; later.)&lt;&#x2F;p&gt;
&lt;p&gt;Pedersen commitments are a type of commitment scheme with some nice properties that the hashing technique above doesn&#x27;t have. A Pedersen commitment in an abelian group $\mathbb{G}$ of prime order $q$ requires two public and unrelated generators, $G$ and $H$ (by unrelated, I mean there should be no obvious relation $aG = H$). If I want to commit to the value $v \in \mathbb{Z}_q$ I do as follows:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;Pick a random &amp;quot;blinding factor&amp;quot; $\alpha \leftarrow \mathbb{Z}_q $.&lt;&#x2F;li&gt;
&lt;li&gt;Return $Q = \alpha G + v H$ as my commitment.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;That&#x27;s it. The way I reveal my commitment is simply by revealing my initial values $(\alpha, v)$. It&#x27;s worth it to quickly check that the scheme is _binding_, that is, if I make a commitment to $(\alpha, v)$, it&#x27;s hard to come up with different values $(\alpha&#x27;, v&#x27;)$ that result in the same commitment. For suppose I were able to do such a thing, then&lt;&#x2F;p&gt;
&lt;p&gt;$$
\alpha G + v H = \alpha&#x27; G + v&#x27; H
\implies (\alpha - \alpha&#x27;)G = (v&#x27; - v)H
\implies G = \frac{v&#x27; - v}{\alpha - \alpha&#x27;}H
$$&lt;&#x2F;p&gt;
&lt;p&gt;and we&#x27;ve found the discrete logarithm of $H$ with respect to G, which we assumed earlier was hard. Another cool property (which is totally unrelated to anything) is &lt;em&gt;perfect hiding&lt;&#x2F;em&gt;. That is, for any commitment $Q$ and any value $v$, there is a blinding factor $\alpha$ such that $Q$ is a valid commitment to $(\alpha, v)$. This is just by virtue of the fact that, since $G$ is a generator, there must be an $\alpha$ such that $\alpha G = Q - vH$ (also since $H$ is also a generator, this also works if you fix $Q$ and $\alpha$ and derive $v$). Perfect hiding proves that, when $\alpha$ is truly random, you cannot learn anything about $v$, given just $Q$.&lt;&#x2F;p&gt;
&lt;p&gt;Lastly, and very importantly, Pedersen commitments are additively homomorphic. That means that if $Q$ commits to $(\alpha, v)$ and $Q&#x27;$ commits to $(\alpha&#x27;, v&#x27;)$, then&lt;&#x2F;p&gt;
&lt;p&gt;$$ Q + Q&#x27; = \alpha G + vH + \alpha&#x27; G + v&#x27;H = (\alpha + \alpha&#x27;)G + (v + v&#x27;)H $$&lt;&#x2F;p&gt;
&lt;p&gt;So the commitment $Q + Q&#x27;$ commits to $(\alpha + \alpha&#x27;, v + v&#x27;)$. We&#x27;ll use this property in just a second.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;hiding-transaction-amounts&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#hiding-transaction-amounts&quot; aria-label=&quot;Anchor link for: hiding-transaction-amounts&quot;&gt;§&lt;&#x2F;a&gt;
Hiding Transaction Amounts&lt;&#x2F;h1&gt;
&lt;p&gt;Ok so back to the problem statement. We&#x27;ll simplify it a little bit. A transaction has an input amount $a$, an output amount $b$, and a transaction fee $f$, all in $\mathbb{Z}_q$. To maintain consistency, every transaction should satisfy the property $a = b + f$, i.e., total input equals total output, so no money appears out of thin air and no money disappears into nothingness. We can actually already prove that this equation is satisfied without revealing any of the values by using Pedersen commitments. Pick random $\alpha_a \leftarrow \mathbb{Z}_q,, \alpha_b \leftarrow \mathbb{Z}_q$, and let $\alpha_f = \alpha_a - \alpha_b$. Now make the Pedersen commitments&lt;&#x2F;p&gt;
&lt;p&gt;$$ P = \alpha_a G + aH \quad Q = \alpha_b G + bH \quad R = \alpha_f G + fH $$&lt;&#x2F;p&gt;
&lt;p&gt;and publish $(P,Q,R)$ as your transaction. Then a verifier won&#x27;t be able to determine any of the values of $a$, $b$, or $f$, but will still be able to verify that&lt;&#x2F;p&gt;
&lt;p&gt;$$ P - Q - R = (\alpha_a - \alpha_b - \alpha_f) G + (a - b - f)H = 0G + 0H = \mathcal{O} $$&lt;&#x2F;p&gt;
&lt;p&gt;Remember, if someone tries to cheat and picks values so $a - b - f \neq 0$, then they&#x27;ll have to find an $\alpha$ such that $-\alpha G = (a - b - f) H$ which is Hard. So we&#x27;re done, right? Problem solved! Well not quite yet. What we actually have here is a proof that $a - b - f \equiv 0, (\textrm{mod } q)$. See the distinction? For example, let $q$ be a large prime, say, 13. I&#x27;ll have the input to my transaction be 1🔥TC (Litcoin; ICO is next week, check it out). I&#x27;d like to print some money, so I set my output to be 9🔥TC. I&#x27;ll be generous and give the miner 5🔥TC as my fee. Then anyone can check via the generated Pedersen commitments that&lt;&#x2F;p&gt;
&lt;p&gt;$$ a - b - f = 1 - 9 - 5 = -13 \equiv 0, (\textrm{mod } 13) $$&lt;&#x2F;p&gt;
&lt;p&gt;So this transaction passes the correctness test. What happened? I overflowed and ended up wrapping around the modulus. Since all our arithmetic is done modulo $q$, none of the above algorithms can tell the difference! So how can we prevent the above situation from happening? How do I prove that my inputs don&#x27;t wrap around the modulus and come back to zero? One word:&lt;&#x2F;p&gt;
&lt;h1 id=&quot;rangeproofs&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#rangeproofs&quot; aria-label=&quot;Anchor link for: rangeproofs&quot;&gt;§&lt;&#x2F;a&gt;
Rangeproofs&lt;&#x2F;h1&gt;
&lt;p&gt;To prove that our arithmetic doesn&#x27;t wrap around the modulus, it suffices to prove that the values $a,b,f$ are small enough such that their sum does not exceed $q$. To avoid thinking about negative numbers, we&#x27;ll check that $a = b + f$ instead of $a - b - f = 0$, which are identical equations, but the first one will be a bit easier to reason about. To show that $b + f &amp;lt; q$, we will actually show that $b$ and $f$ can be represented in binary with $k$ bits, where $2^{k+1} &amp;lt; q$ (this ensures that overflow can&#x27;t happen since $b,f &amp;lt; 2^k$ and $2^k + 2^k = 2^{k+1} &amp;lt; q$). In particular, for both $b$ and $f$, we will make $k$ Pedersen commitments, where each $v$ value is provably 0 or a power of two, and the sum of the commitments equals the commitment of $b$ or $f$, respectively. Let&#x27;s do it step by step.&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I start with a value $v$ that I want to prove is representable with $k$ bits. First, pick a random $\alpha \leftarrow \mathbb{Z}_q$ and make a Pedersen commitment $P = \alpha G + v H$&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;Break $v$ down into its binary representation: $v = b_0 + 2b_1 + \ldots + 2^{k-1}b_{k-1} $.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;For each summand, make a Pedersen commitment, making sure that the sum of the commitments is $P$. That is,&lt;&#x2F;p&gt;
&lt;p&gt;$$
\forall 0 \leq i &amp;lt; k-1 \quad \textrm{pick } \alpha_i \leftarrow \mathbb{Z}&lt;em&gt;q \
\textrm{and let } \alpha&lt;&#x2F;em&gt;{k-1} = \alpha - \sum_{i=0}^{k-2} \alpha_i
$$&lt;&#x2F;p&gt;
&lt;p&gt;Then for all $i$, commit&lt;&#x2F;p&gt;
&lt;p&gt;$$ P_i = \alpha_i G + 2^ib_i H $$&lt;&#x2F;p&gt;
&lt;p&gt;This ensures that $P = P_0 + P_1 + \ldots + P_{k-1}$. The verifier will be checking this property later.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;Great. So far we&#x27;ve provably broken down a single number into $k$ constituents, while hiding all
the bits. But how does a verifier know that all the $b$ values are bits? What&#x27;s preventing me
from picking $b_0 = 3^{200}$, for example? This is where we will use ring signatures! For each
commitment, we&#x27;ll make the set $\mathcal{A}_i = \{P_i, P_i - 2^iH\}$ and treat that as a set
of public keys for a ring signature. Note that, because we know the binary expansion of $v$, we
know the private key to exactly one of the public keys in $\mathcal{A}_i$. This is because&lt;&#x2F;p&gt;
&lt;p&gt;$$
\begin{aligned}
b_i = 0 &amp;amp;\implies P_i = \alpha_i G + 0H = \alpha_i G \newline
b_i = 1 &amp;amp;\implies P_i - 2^iH = \alpha_i G + 2^iH - 2^iH = \alpha_i G
\end{aligned}
$$&lt;&#x2F;p&gt;
&lt;p&gt;So to prove that $b_i = 0 \textrm{ or } 1$, we construct a ring signature over $\mathcal{A}_i$. Since the ring signature is signer-ambiguous, a verifier can&#x27;t determine which key did the signing. This means we get to hide all the bits, while simultaneously proving that they are indeed bits! We get some space savings by using Borromean signatures here, since we&#x27;ll have $k$ total signatures of size 2 each. The final rangeproof of the value $v$ is thus&lt;&#x2F;p&gt;
&lt;p&gt;$$
R_v = (P_0, \ldots, P_k, e_0, s_0, \overline{s_0}, s_1, \overline{s_1}, \ldots, s_k, \overline{s_k})
$$&lt;&#x2F;p&gt;
&lt;p&gt;where $s_i$ and $\overline{s_i}$ are the $s$ values of the $i^\textrm{th}$ ring signature. Obviously, the choice of binary representation as opposed to, say, base-16 representation is arbitrary, since you can make rings as big as you want, where each public key corresponds to a digit in that representation. But note that the space savings that Borromean ring signatures give us come from the number of rings, not their size. So it appears to be a good strategy to make the rings as small as possible and let the center $e_0$ value take the place of as many $e$ values as possible.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;putting-it-all-together&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#putting-it-all-together&quot; aria-label=&quot;Anchor link for: putting-it-all-together&quot;&gt;§&lt;&#x2F;a&gt;
Putting It All Together&lt;&#x2F;h1&gt;
&lt;p&gt;So to recap, we have picked transaction input $a$, output $b$, and fee $f$, and hidden them with Pedersen commitments $P_a$, $P_b$, and $P_f$. This gives verifiers the ability to check correctness of the transaction up to modulus-wrapping. Then we constructed the commitments&#x27; corresponding rangeproofs $R_a$, $R_b$, and $R_f$ so that a verifier gets the last piece of assurance that the transaction is correct &lt;em&gt;and&lt;&#x2F;em&gt; there is no overflow. So, in total, a confidential transaction is the tuple&lt;&#x2F;p&gt;
&lt;p&gt;$$ (P_a, P_b, P_f, R_a, R_b, R_f) $$&lt;&#x2F;p&gt;
&lt;p&gt;And that&#x27;s how confidential transactions work! If I want to send 🔥TC to someone, I can construct a confidential transaction that I make public, and then privately reveal the commitments for $P_a$, $P_b$ and $P_f$ so that they can be sure that I actually sent what I claim. Because the commitments are binding, they can be certain that I can&#x27;t claim to someone else that I sent different $a$, $b$ or $f$ values.&lt;&#x2F;p&gt;
&lt;p&gt;There&#x27;s plenty more detail in how transactions are constructed that I didn&#x27;t cover, but I hope I was able to explain the core of confidential transactions, and hopefully interest you in cryptography a little bit more. There&#x27;s a lot of cool stuff out there, and cryptocurrencies are a massive playing field for novel constructions.&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;1&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;Sorry, you&#x27;re gonna have to compile the $\LaTeX$ yourself. Every PDF on the internet is
either outdated or erroneous.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</description>
      </item>
    </channel>
</rss>
