<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Bytes &amp; Musings - Medium]]></title>
        <description><![CDATA[Notes on web, code &amp; technology - Medium]]></description>
        <link>https://medium.com/bytes-musings?source=rss----478aac9c795---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Bytes &amp;amp; Musings - Medium</title>
            <link>https://medium.com/bytes-musings?source=rss----478aac9c795---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:48:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/bytes-musings" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sorcery behind the revolution: Merkle tree]]></title>
            <link>https://medium.com/bytes-musings/sorcery-behind-the-revolution-merkle-tree-part-1-92c4f1775c70?source=rss----478aac9c795---4</link>
            <guid isPermaLink="false">https://medium.com/p/92c4f1775c70</guid>
            <category><![CDATA[merkle-tree]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Tonino Jankov]]></dc:creator>
            <pubDate>Sat, 30 Sep 2017 03:32:22 GMT</pubDate>
            <atom:updated>2019-07-03T07:38:30.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*aw6-fI5FhYkVrys1Z476lg.gif" /><figcaption>WHAT IS THIS SORCERY?</figcaption></figure><p>There is an algorithm that underlies recent breakthroughs in blockchain applications, distributed computing (IPFS), version control systems like git, <br>P2P trustless applications like BitTorrent.</p><p>This algorithm is called <strong>Merkle tree</strong>. It was invented by <strong>Ralph Merkle</strong> and patented in 1979. (patent expired in 2002.). Without this algorithm, we wouldn’t have Bitcoin as we know it today.</p><p>This algorithm provides us with cheap way of verifying authenticity of large amounts of data, without having to process all the data ourself.</p><h4>Merkle tree is a hash tree</h4><p><strong>Cryptographic hashing</strong> — like commonly used SHA-2 — gives us <strong>cryptographic digest </strong>— which is like a <strong>unique</strong> signature produced for various data (text, files, etc) — with a consistent length:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*BcNkG9N2cYrNO8ayyQIM_Q.png" /></figure><p>Main points of these hashing functions is that</p><ul><li>they produce consistent-length digests (wether original data consists of single letter, or hundred megabytes of text),</li><li>they cant be reversed (one cannot produce/decypher original data from the given hash).</li><li>Same input (original data) <strong>always </strong>produces the same result (digest)</li><li>It is extremely difficult — or impossible — to find/reproduce input data that will result with given digest.</li></ul><p>So, given even huge amount of data, it is easy to verify its authenticity, or integrity — just by comparing its hash/digest with the expected one. We dont have to compare it byte-by-byte.</p><p><strong>Hash functions are used for checking of passwords </strong>of users in websites — this way websites dont need to keep passwords in plain text — and potential hackers — even if they manage to break in and steal hashes — wont have much use of it (see the last bullet point above). We only verify authenticity of users passwords to grant them access — by comparing hashes.</p><p><strong>Hash functions are also used to verify integrity of file downloads</strong> — original file provider provides digest/hash of data (file), so downloader, once he downloads the file, can compare its hash with hash given by file provider — and verify its integrity. This way end-user can be sure the file hasnt been tampered with.</p><p><strong>In blockchain-based cryptocurrencies, this hashing is used to</strong> keep record of transactions, and to be able to <strong>verify that transaction history hasn’t been tampered with.</strong></p><p>So, as we said — <strong>Merkle tree is a hash tree</strong>. Given initial data, it is a binary tree of hashes of concatenated hashes of initial <strong>leaves </strong>of data — until a root hash is reached.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oAZnN2zTKbq7PvJDMMhiQ.png" /></figure><p>Data nodes at the bottom are raw data — they can be couple of bytes, couple of megabytes or hundreds of megabytes. Each. Every time, cryptographic function represents them with a consistent-length string.</p><p>SHA-256 digest of text “Hi!” is “CA51CE1FB15ACC6D69B8A5700256172FCC507E02073E6F19592E341BD6508AB8”, while SHA-256 digest of the entire text of Ulysses by James Joyce (given here, on Project Gutenberg <a href="http://www.gutenberg.org/files/4300/4300-0.txt">http://www.gutenberg.org/files/4300/4300-0.txt</a> ), is “9806AFC09BFF3096037C27AF20B5E92FA74999CC135066D3E08D85C69632D942”.</p><p>If we change just the initial capital <strong>T </strong>from the given text into small <strong>t</strong> — we get this hash for the whole book: “D67BDFB14AA5BBD61F89925FC6D9007165C7B146FC532C3A15FBA6878FD1BC7C”.</p><p>So, we can verify data of any length with just <strong>32-bit </strong>long<strong> </strong>hash. This has enormous implications on our ability to verify integrity of huge amounts of data, without having to process all that data. For example, with cryptocurrencies, we dont need to download whole blockchains of past transactions (often measured in gigabytes, and tens/hundreds of gigabytes) to verify its integrity, or to verify integrity of transaction we are interested in.</p><p>With P2P file protocols, like BitTorrent or IPFS — we dont need to process / have available whole file to verify authenticity of one small bit of it. Having downloaded just one node of data from the bottom of our picture, like DATA1, we dont need to have all the remaining pieces to verify integrity / authenticity of this piece. We need root hash <strong>G</strong> , and hashes <strong>F</strong> and <strong>B.</strong></p><p>That is just 3 32-bit strings like those above, vs. having to have all the remaining DATA nodes (2, 3 and 4) available. Considering they can be of any length (and tree can be of any number of levels, like with Bitcoin blockchain for example), the efficiency and speed gains are enormous.</p><p>I hope I managed to shed light to an algorythm fundamental to Ethereum and BTC blockchains — algorithm that makes these crypto projects possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92c4f1775c70" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bytes-musings/sorcery-behind-the-revolution-merkle-tree-part-1-92c4f1775c70">Sorcery behind the revolution: Merkle tree</a> was originally published in <a href="https://medium.com/bytes-musings">Bytes &amp; Musings</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>