Skip to content

Commit e044346

Browse files
added smt blog post
1 parent b1564f4 commit e044346

File tree

30 files changed

+603
-76
lines changed

30 files changed

+603
-76
lines changed

content/posts/Hypersyn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
author: Lum Ramabaja
33
title: "Hypersyn: A Peer-to-Peer System for Mutual Credit"
4-
date: 2022-05-31
4+
date: 2022-08-15
55
draft: false
66
description: "Hypersyn: A Peer-to-Peer System for Mutual Credit"
77
tags: [
@@ -21,6 +21,6 @@ The Hypersyn protocol is a new type of permissionless and peer-to-peer payment n
2121

2222
## [Money & Mutual Credit](https://chainlesscoder.com/posts/money-mutual-credit/)
2323

24-
## [Demystifying Sparse Merkle Trees]()
24+
## [Demystifying Sparse Merkle Trees](https://chainlesscoder.com/posts/demystifying-sparse-merkle-trees)
2525

26-
## [Hypersyn - Mechanism Overview]()
26+
## [Hypersyn - Mechanism Overview](https://chainlesscoder.com/posts/hypersyn-mechanism-overview)

content/posts/Money_and_mutual_credit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
author: Lum Ramabaja
33
title: "Money & Mutual Credit 💰"
4-
date: 2022-05-31
4+
date: 2022-08-16
55
draft: false
66
description: "Hypersyn: A Peer-to-Peer System for Mutual Credit"
77
tags: [
@@ -12,7 +12,7 @@ tags: [
1212
series: ["Hypersyn"]
1313
---
1414

15-
This is part 1 of the Hypersyn blog series. Visit the [part 0](https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/) to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit [arxiv](https://arxiv.org/pdf/2206.04049.pdf).
15+
This is part 1 of the Hypersyn blog series. Visit [part 0](https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/) to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit [arxiv](https://arxiv.org/pdf/2206.04049.pdf).
1616

1717
---
1818
<!--more-->
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
author: Lum Ramabaja
3+
title: "Demystifying Sparse Merkle Trees 🌲"
4+
date: 2022-08-18
5+
draft: false
6+
description: "Hypersyn: A Peer-to-Peer System for Mutual Credit"
7+
tags: [
8+
data structures
9+
]
10+
series: ["Hypersyn"]
11+
---
12+
13+
This is part 2 of the Hypersyn blog series. Visit [part 0](https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/) to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit [arxiv](https://arxiv.org/pdf/2206.04049.pdf).
14+
15+
---
16+
<!--more-->
17+
18+
A Merkle tree is a binary tree data structure used to securely verify the presence of values in a list, without having to provide every value of the list to another party. To construct a Merkle tree, every value is hashed via a cryptographic hash function, the transformed values are also known as *leaf nodes*. The leaf nodes are then hashed together to form parent nodes, also known as *non-leaf nodes*. This step is repeated until the root of the constructed binary tree is reached (see Figure 1.).
19+
20+
<p align="center">
21+
<img width="70%" height="70%" src="/images/2022/merkle_tree.png">
22+
<em><br/>Figure 1. A depiction of a Merkle Tree. Leaf nodes are represented in yellow. Non-leaf nodes are represented in blue.</em>
23+
</p>
24+
25+
To verify that a value is present in the Merkle tree, a series of hashes (also known as the *Merkle proof*) is provided. By sequentially hashing the leaf node hash with the provided Merkle proof, the Merkle root of the original Merkle tree can be recreated (see Figure 2.). Note that recipients of a Merkle proof must already have a local copy of the Merkle root for a proof to take place. A node that receives a Merkle proof therefore, is able to verify if a value was part of the list of values that generated the Merkle root, by comparing their locally stored Merkle root, with the final hash generated by the provided Merkle proof. If the two hashes are equivalent, then the recipient of the Merkle proof knows that the provided value was indeed one of the leaf nodes in the original Merkle tree. This is also known as a *presence proof*. Instead of having to provide the whole list of $M$ values to another party to verify the presence of one specific value, Merkle trees allow to prove the presence of a value by providing only *log(M)* hashes.
26+
27+
<p align="center">
28+
<img width="70%" height="70%" src="/images/2022/merkle_proof.png">
29+
<em><br/>Figure 2. A depiction of a Merkle proof. To prove that <b>H<sub>3</sub></b> was present in the initial value list, one has to hash it with <b>H<sub>4</sub></b>, then with <b>H<sub>1,2</sub></b>, and finally with <b>H<sub>5,6,7,8</sub></b> (shown in green) to recreate the hash of the Merkle root.</em>
30+
</p>
31+
32+
While Merkle trees can provide presence proofs and perform value insertions with *log(M)* steps, they do not allow for efficient *absence proofs*, value updates, and value deletions. An absence proof is when a Merkle proof can show the absence of a value in a tree. In regular Merkle trees, absence proofs require leaf node sorting, while value updates and deletions require the re-computation of the whole tree, all of which are computationally expensive. The sparse Merkle tree (SMT) solves these issues by slightly redefining how a tree is constructed. In the SMT, one can both provide presence and absence proofs in *log(M)* steps on average, as well as perform insertions, deletions, and updates in *log(M)* steps on average.
33+
34+
Instead of constructing a Merkle tree bottom-up from a fixed set of values, SMTs start with an empty tree and sequentially add values to it. This is done by introducing the concept of *empty nodes* (a constant node with a fixed hash value), as well as by following a simple heuristic:
35+
36+
37+
* To add a new value to the tree, begin from the tree root. If there is no value yet in the tree, let the tree root be the empty node.
38+
* Let the path from a parent node to the left child node represent a zero, and the path to the right child node represent a one (see Figure 3.). Every value has a bit sequence (their cryptographic hash) that can be mapped onto the tree by sequentially choosing either the left side, or right side of a parent node, depending on the bits of the value's hash. Go down the value's path in the tree until a leaf node, or an empty node is reached.
39+
* If an empty node is reached, substitute it with the new value. Taking Figure 3. as an example, inserting the orange value with ID **100** (at time step **t<sub>2</sub>**) will result in the substitution of an empty node with the actual value.
40+
* If a leaf node is reached, create two child nodes and remap the values (by looking at the hashes of the values). If the values get mapped to the same child node, repeat the process and insert an empty node at the opposite child node. Taking Figure 3. as an example, inserting the yellow value with ID **011** (at time step **t<sub>3</sub>**) will result in the repositioning of the value with ID **010**, as well as result in the creation of an empty node on the left side of the none-leaf node that was previously (in time step **t<sub>2</sub>**) the **010** leaf node.
41+
42+
<p align="center">
43+
<img width="80%" height="80%" src="/images/2022/smt_insertion.png">
44+
<em><br/>Figure 3. A depiction of a sparse Merkle tree. At every time step <b>t</b> a value is being inserted. Blue nodes represent non-leaf nodes. White nodes with full lines represent empty nodes. White nodes with dashed lines are not part of the SMT and serve to depict where value nodes in the tree would get mapped. The green (<b>010</b>), orange (<b>100</b>), and yellow (<b>010</b>) nodes represent the values, i.e. leaf nodes of the SMT.</em>
45+
</p>
46+
47+
Value deletions in SMTs work the exact same way as insertions, but in reverse. When removing a leaf node we move any sibling node up, until a parent node with another leaf node, or empty node is reached. Proving the presence of a value in SMTs is done the same way as in regular Merkle trees (see Figure 2. as reference), but surprisingly enough, so are absence proofs. To prove that a value was not part of a sparse Merkle tree, all one has to do is provide a regular Merkle proof, where the original leaf value of the proof represents the empty node value (a constant hash value). Taking Figure 4. as an example, to prove that the value with ID **001** (depicted with a yellow dashed line) is not part of the SMT, one simply has to provide the empty node, as well as the green leaf node and the orange leaf node to a recipient. By hashing the empty node value with the green node value and the orange node value, one recreates the original Merkle root and can therefore prove that any value that starts with **01** cannot have been part of the tree.
48+
49+
<p align="center">
50+
<img width="80%" height="80%" src="/images/2022/smt_absence_proof.png">
51+
<em><br/>Figure 4. A depiction of a sparse Merkle tree. the value with ID <b>011</b> was never inserted into the SMT. One can show this by generating an absence proof.</em>
52+
</p>
53+
54+
In agent-centric protocol designs, nodes usually sign their Merkle roots with their private keys before sending it to peers. This is done to prevent malicious peers from forging another node's Merkle roots. When the volume of requests on a node-basis is high however, that is, when a node has to update, insert, and/or delete many of its SMT values in a small amount of time, signing the Merkle root after every state change becomes costly. To overcome this scalability issue, nodes in Hypersyn can batch-sign a number of transactions (i.e. SMT state changes) by signing a single Merkle root and a counter, as long as the state changes have a partial order with each other (see [part 3](https://chainlesscoder.com/posts/hypersyn-mechanism-overview)).

docs/404.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ <h2 class="read-more">Read more</h2>
8080

8181
<section class="item">
8282
<div>
83-
<h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/'>Hypersyn: A Peer-to-Peer System for Mutual Credit</a></h1>
84-
<div class="date">May 31, 2022</div>
83+
<h1 class="title"><a href='/posts/demystifying-sparse-merkle-trees/'>Demystifying Sparse Merkle Trees 🌲</a></h1>
84+
<div class="date">Aug 18, 2022</div>
8585
</div>
8686
</section>
8787

@@ -90,7 +90,16 @@ <h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-cred
9090
<section class="item">
9191
<div>
9292
<h1 class="title"><a href='/posts/money-mutual-credit/'>Money &amp; Mutual Credit 💰</a></h1>
93-
<div class="date">May 31, 2022</div>
93+
<div class="date">Aug 16, 2022</div>
94+
</div>
95+
</section>
96+
97+
98+
99+
<section class="item">
100+
<div>
101+
<h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/'>Hypersyn: A Peer-to-Peer System for Mutual Credit</a></h1>
102+
<div class="date">Aug 15, 2022</div>
94103
</div>
95104
</section>
96105

docs/images/2022/merkle_proof.png

51.4 KB
Loading

docs/images/2022/merkle_tree.png

47.1 KB
Loading
57.6 KB
Loading

docs/images/2022/smt_insertion.png

172 KB
Loading

docs/index.html

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ <h2>Lum Ramabaja</h2>
8080

8181
<section class="item">
8282
<div>
83-
<h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/'>Hypersyn: A Peer-to-Peer System for Mutual Credit</a></h1>
83+
<h1 class="title"><a href='/posts/demystifying-sparse-merkle-trees/'>Demystifying Sparse Merkle Trees 🌲</a></h1>
8484
<div class ="date">
85-
<time datetime="2022-05-31 00:00:00 &#43;0000 UTC">May 31, 2022</time>
85+
<time datetime="2022-08-18 00:00:00 &#43;0000 UTC">Aug 18, 2022</time>
8686
</div>
8787
</div>
8888

8989

90-
<div class="summary">This is the landing page for the Hypersyn blog series. To read the whole Hypersyn blog series in PDF form with included references, visit arxiv.
90+
<div class="summary">This is part 2 of the Hypersyn blog series. Visit part 0 to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit arxiv.
9191
</div>
9292

9393

@@ -99,12 +99,29 @@ <h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-cred
9999
<div>
100100
<h1 class="title"><a href='/posts/money-mutual-credit/'>Money &amp; Mutual Credit 💰</a></h1>
101101
<div class ="date">
102-
<time datetime="2022-05-31 00:00:00 &#43;0000 UTC">May 31, 2022</time>
102+
<time datetime="2022-08-16 00:00:00 &#43;0000 UTC">Aug 16, 2022</time>
103+
</div>
104+
</div>
105+
106+
107+
<div class="summary">This is part 1 of the Hypersyn blog series. Visit part 0 to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit arxiv.
108+
</div>
109+
110+
111+
</section>
112+
113+
114+
115+
<section class="item">
116+
<div>
117+
<h1 class="title"><a href='/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/'>Hypersyn: A Peer-to-Peer System for Mutual Credit</a></h1>
118+
<div class ="date">
119+
<time datetime="2022-08-15 00:00:00 &#43;0000 UTC">Aug 15, 2022</time>
103120
</div>
104121
</div>
105122

106123

107-
<div class="summary">This is part 1 of the Hypersyn blog series. Visit the part 0 to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit arxiv.
124+
<div class="summary">This is the landing page for the Hypersyn blog series. To read the whole Hypersyn blog series in PDF form with included references, visit arxiv.
108125
</div>
109126

110127

docs/index.xml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@
66
<description>Recent content on @ChainlessCoder</description>
77
<generator>Hugo -- gohugo.io</generator>
88
<language>en-us</language>
9-
<lastBuildDate>Tue, 31 May 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://chainlesscoder.com/index.xml" rel="self" type="application/rss+xml" />
9+
<lastBuildDate>Thu, 18 Aug 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://chainlesscoder.com/index.xml" rel="self" type="application/rss+xml" />
1010
<item>
11-
<title>Hypersyn: A Peer-to-Peer System for Mutual Credit</title>
12-
<link>https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/</link>
13-
<pubDate>Tue, 31 May 2022 00:00:00 +0000</pubDate>
11+
<title>Demystifying Sparse Merkle Trees 🌲</title>
12+
<link>https://chainlesscoder.com/posts/demystifying-sparse-merkle-trees/</link>
13+
<pubDate>Thu, 18 Aug 2022 00:00:00 +0000</pubDate>
1414

15-
<guid>https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/</guid>
16-
<description>&lt;p&gt;This is the landing page for the Hypersyn blog series. To read the whole Hypersyn blog series in PDF form with included references, visit &lt;a href=&#34;https://arxiv.org/pdf/2206.04049.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;arxiv&lt;/a&gt;.&lt;/p&gt;
15+
<guid>https://chainlesscoder.com/posts/demystifying-sparse-merkle-trees/</guid>
16+
<description>&lt;p&gt;This is part 2 of the Hypersyn blog series. Visit &lt;a href=&#34;https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;part 0&lt;/a&gt; to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit &lt;a href=&#34;https://arxiv.org/pdf/2206.04049.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;arxiv&lt;/a&gt;.&lt;/p&gt;
1717
&lt;hr&gt;</description>
1818
</item>
1919

2020
<item>
2121
<title>Money &amp; Mutual Credit 💰</title>
2222
<link>https://chainlesscoder.com/posts/money-mutual-credit/</link>
23-
<pubDate>Tue, 31 May 2022 00:00:00 +0000</pubDate>
23+
<pubDate>Tue, 16 Aug 2022 00:00:00 +0000</pubDate>
2424

2525
<guid>https://chainlesscoder.com/posts/money-mutual-credit/</guid>
26-
<description>&lt;p&gt;This is part 1 of the Hypersyn blog series. Visit the &lt;a href=&#34;https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;part 0&lt;/a&gt; to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit &lt;a href=&#34;https://arxiv.org/pdf/2206.04049.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;arxiv&lt;/a&gt;.&lt;/p&gt;
26+
<description>&lt;p&gt;This is part 1 of the Hypersyn blog series. Visit &lt;a href=&#34;https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;part 0&lt;/a&gt; to explore the other parts of the blog series. To read the whole Hypersyn blog series in PDF form with included references, visit &lt;a href=&#34;https://arxiv.org/pdf/2206.04049.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;arxiv&lt;/a&gt;.&lt;/p&gt;
27+
&lt;hr&gt;</description>
28+
</item>
29+
30+
<item>
31+
<title>Hypersyn: A Peer-to-Peer System for Mutual Credit</title>
32+
<link>https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/</link>
33+
<pubDate>Mon, 15 Aug 2022 00:00:00 +0000</pubDate>
34+
35+
<guid>https://chainlesscoder.com/posts/hypersyn-a-peer-to-peer-system-for-mutual-credit/</guid>
36+
<description>&lt;p&gt;This is the landing page for the Hypersyn blog series. To read the whole Hypersyn blog series in PDF form with included references, visit &lt;a href=&#34;https://arxiv.org/pdf/2206.04049.pdf&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;arxiv&lt;/a&gt;.&lt;/p&gt;
2737
&lt;hr&gt;</description>
2838
</item>
2939

0 commit comments

Comments
 (0)