Blockchain Simulator - Hashing internal nodes of Merkle Tree - 13
The ExSan Abstract Data Structure can be used to implement a complex blockchain structure.
Each ExSan Node can be considered a block in the chain, pointing to a Merkle Binary Tree.
In fact, each ExSan Node can point to any user-defined abstract structure.
1 LEARNING BLOCKCHAIN
2
This a Computer Science topic quite interesting.
3
I have coded my first simulations using ExSan
4
It already has implemented binary tree in every block / node
Wikipedia Merkle Tree
5
This simulations tracks blockchains transactions without hashing.
6
Every row is a peer, when it reaches the end of the row it comes
7
back to the begining of the row and keeps on.
8
COURSERA Bitcoin and Cryptocurrency Technologies
9
ref:
My Profile #opentowork
10
Code and output of the simulation of simple transactions as depicted on the picture above
11
1 First try to implement this
2
3 In cryptography and computer science, a hash tree or Merkle tree is a tree
4 in which every "leaf" (node) is labelled with the cryptographic hash of a
5 data block, and every node that is not a leaf(called a branch, inner node,
6 or inode) is labelled with the cryptographic hash of the labels of its
7 child nodes. A hash tree allows efficientand secure verification of the
8 contents of a large data structure.A hash tree is a generalization of a
9 hash listand a hash chain.
10
11 | ExSan | C++ | ExSan | MSVSC2019_V16_11.23@01.11
12 Mon Feb 13 11:25 : 20 2023
13
14 exsan.plusplus@gmail.com https ://twitter.com/#!/ExSan_com
15 JOB: bch6_2520
16
17 Block Chain Simulator 6
18 key is a secuential number, if leaf sha(val in block)
19 if no leave, sha of previous child
20 Generate Exsan(2, 2)
21
22 LEDGER IN EVERY BLOCK - NODE
23
24 33 Insert randNumber : 11 in Block Row : 1 Col : 1
25 Val in Block
26 WORKSHEET 0 @[2, 2] FLOAT
27 A B
28 > ------------------<
29 1: 11 0
30 2: 0 0
31 < ------------------ >
32
33 Counter block Transactionsin
34 WORKSHEET 0 @[2, 2] PIX
35 A B
36 >------<
37 1: 1 0
38 2: 0 0
39 < ------ >
40
41 Merkle Tree In Order Traversal of hash val - track transaction
42 val-> 11 1
43 Merkle Tree In Order Traversal Hashing
44 key-> 0 it is a leaf SHA(11) 4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a
45
46 33 Insert randNumber : 10 in Block Row : 2 Col : 2
47 Val in Block
48 WORKSHEET 0 @[2, 2] FLOAT
49 A B
50 >------------------<
51 1: 11 0
52 2: 0 10
53 < ------------------ >
54
55 Counter block Transactionsin
56 WORKSHEET 0 @[2, 2] PIX
57 A B
58 >------<
59 1: 1 0
60 2 : 0 1
61 < ------ >
62
63 Merkle Tree In Order Traversal of hash val - track transaction
64 val-> 10 1
65 Merkle Tree In Order Traversal Hashing
66 key-> 1 it is a leaf SHA(10) 4a44dc15364204a80fe80e9039455cc1608281820fe2b24f1e5233ade6
67
68 33 Insert randNumber : 63 in Block Row : 2 Col : 1
69 Val in Block
70 WORKSHEET 0 @[2, 2] FLOAT
71 A B
72 >------------------<
73 1: 11 0
74 2: 63 10
75 < ------------------ >
76
77 Counter block Transactionsin
78 WORKSHEET 0 @[2, 2] PIX
79 A B
80 >------<
81 1: 1 0
82 2: 1 1
83 < ------ >
84
85 Merkle Tree In Order Traversal of hash val - track transaction
86 val-> 63 1
87 Merkle Tree In Order Traversal Hashing
88 key-> 2 it is a leaf SHA(63) da4ea2a5506f2693eae190d9360a1f31793c98a1adade51d93533a6f52
89
90
91 ....
92 more here
93 ....
94
95
96
97 33 Insert randNumber : 72 in Block Row : 1 Col : 2
98 Val in Block
99 WORKSHEET 0 @[2, 2] FLOAT
100 A B
101 > ------------------<
102 1: 93 72
103 2: 32 25
104 < ------------------ >
105
106 Counter block Transactionsin
107 WORKSHEET 0 @[2, 2] PIX
108 A B
109 >------ <
110 1: 8 10
111 2 : 8 6
112 < ------ >
113
114 Merkle Tree In Order Traversal of hash val - track transaction
115 val-> 57 1
116 val-> 78 2
117 val-> 80 3
118 val-> 9 4
119 val-> 18 5
120 val-> 43 6
121 val-> 50 7
122 val-> 69 8
123 val-> 45 9
124 val-> 72 10
125 Merkle Tree In Order Traversal Hashing
126 key-> 4 it is a leaf SHA(57) c837649cce43f2729138e72cc315207057ac82599a59be72765a477f22
127 key-> 8 Not a Leaf, current SHA(78) 349c41201b62db851192665c504b350ff98c6b45fb62a8a2161
128 previous, Merkle left child SHA(57) c837649cce43f2729138e72cc315207057ac82599a59be72765a4
129 key-> 10 it is a leaf SHA(80) 48449a14a4ff7d79bb7a1b6f3d488eba397c36ef25634c111b49baf362
130 key-> 11 Not a Leaf, current SHA(9) 19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03
131 previous, Merkle left child SHA(78) 349c41201b62db851192665c504b350ff98c6b45fb62a8a2161f7
132 key-> 13 it is a leaf SHA(18) 4ec9599fc203d176a301536c2e091a19bc852759b255bd6818810a42c5
133 key-> 15 Not a Leaf, current SHA(43) 44cb730c420480a0477b505ae68af508fb90f96cf0ec54c6ad1
134 previous, Merkle left child SHA(18) 4ec9599fc203d176a301536c2e091a19bc852759b255bd6818810
135 key-> 20 it is a leaf SHA(50) 1a6562590ef19d1045d06c4055742d38288e9e6dcd71ccde5cee80f1d5
136 key-> 23 Not a Leaf, current SHA(69) c75cb66ae28d8ebc6eded002c28a8ba0d06d3a78c6b5cbf9b2a
137 previous, Merkle left child SHA(50) 1a6562590ef19d1045d06c4055742d38288e9e6dcd71ccde5cee8
138 key-> 26 Not a Leaf, current SHA(45) 811786ad1ae74adfdd20dd0372abaaebc6246e343aebd01da0b
139 key-> 31 it is a leaf SHA(72) 8722616204217eddb39e7df969e0698aed8e599ba62ed2de1ce49b03ad
140
141 33 Insert randNumber : 62 in Block Row : 1 Col : 1
142 Val in Block
143 WORKSHEET 0 @[2, 2] FLOAT
144 A B
145 >------------------<
146 1: 62 72
147 2 : 32 25
148 <------------------ >
149
150 Counter block Transactionsin
151 WORKSHEET 0 @[2, 2] PIX
152 A B
153 >------ <
154 1: 9 10
155 2: 8 6
156 < ------ >
157
158 Merkle Tree In Order Traversal of hash val - track transaction
159 val-> 11 1
160 val-> 53 2
161 val-> 98 3
162 val-> 42 4
163 val-> 68 5
164 val-> 50 6
165 val-> 76 7
166 val-> 93 8
167 val-> 62 9
168 Merkle Tree In Order Traversal Hashing
169 key-> 0 it is a leaf SHA(11) 4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a
170 key-> 3 Not a Leaf, current SHA(53) 2858dcd1057d3eae7f7d5f782167e24b61153c01551450a628c
171 previous, Merkle left child SHA(11) 4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c0
172 key-> 5 it is a leaf SHA(98) 29db0c6782dbd5000559ef4d9e953e300e2b479eed26d887ef3f92b921
173 key-> 6 Not a Leaf, current SHA(42) 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b1
174 previous, Merkle left child SHA(53) 2858dcd1057d3eae7f7d5f782167e24b61153c01551450a628cee
175 key-> 14 it is a leaf SHA(68) a21855da08cb102d1d217c53dc5824a3a795c1c1a44e971bf01ab9da3a
176 key-> 21 Not a Leaf, current SHA(50) 1a6562590ef19d1045d06c4055742d38288e9e6dcd71ccde5ce
177 previous, Merkle left child SHA(68) a21855da08cb102d1d217c53dc5824a3a795c1c1a44e971bf01ab
178 key-> 22 it is a leaf SHA(76) f74efabef12ea619e30b79bddef89cffa9dda494761681ca862cff2871
179 key-> 24 Not a Leaf, current SHA(93) 6e4001871c0cf27c7634ef1dc478408f642410fd3a444e2a88e
180 previous, Merkle left child SHA(76) f74efabef12ea619e30b79bddef89cffa9dda494761681ca862cf
181 key-> 32 it is a leaf SHA(62) 81b8a03f97e8787c53fe1a86bda042b6f0de9b0ec9c09357e107c99ba4
182
183 33 Insert randNumber : 11 in Block Row : 2 Col : 1
184 Val in Block
185 WORKSHEET 0 @[2, 2] FLOAT
186 A B
187 > ------------------<
188 1: 62 72
189 2: 11 25
190 < ------------------ >
191
192 Counter block Transactionsin
193 WORKSHEET 0 @[2, 2] PIX
194 A B
195 >------ <
196 1: 9 10
197 2 : 9 6
198 < ------ >
199
200 Merkle Tree In Order Traversal of hash val - track transaction
201 val-> 63 1
202 val-> 30 2
203 val-> 75 3
204 val-> 49 4
205 val-> 39 5
206 val-> 87 6
207 val-> 57 7
208 val-> 32 8
209 val-> 11 9
210 Merkle Tree In Order Traversal Hashing
211 key-> 2 it is a leaf SHA(63) da4ea2a5506f2693eae190d9360a1f31793c98a1adade51d93533a6f52
212 key-> 7 Not a Leaf, current SHA(30) 624b60c58c9d8bfb6ff1886c2fd605d2adeb6ea4da576068201
213 previous, Merkle left child SHA(63) da4ea2a5506f2693eae190d9360a1f31793c98a1adade51d93533
214 key-> 12 it is a leaf SHA(75) f369cb89fc627e668987007d121ed1eacdc01db9e28f8bb26f358b7d8c
215 key-> 16 Not a Leaf, current SHA(49) 0e17daca5f3e175f448bacace3bc0da47d0655a74c8dd0dc497
216 previous, Merkle left child SHA(30) 624b60c58c9d8bfb6ff1886c2fd605d2adeb6ea4da576068201b6
217 key-> 25 it is a leaf SHA(39) 0b918943df0962bc7a1824c0555a389347b4febdc7cf9d1254406d80ce
218 key-> 27 Not a Leaf, current SHA(87) bdd2d3af3a5a1213497d4f1f7bfcda898274fe9cb5401bbc019
219 previous, Merkle left child SHA(39) 0b918943df0962bc7a1824c0555a389347b4febdc7cf9d1254406
220 key-> 28 it is a leaf SHA(57) c837649cce43f2729138e72cc315207057ac82599a59be72765a477f22
221 key-> 29 Not a Leaf, current SHA(32) e29c9c180c6279b0b02abd6a1801c7c04082cf486ec027aa135
222 previous, Merkle left child SHA(57) c837649cce43f2729138e72cc315207057ac82599a59be72765a4
223 key-> 33 it is a leaf SHA(11) 4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a
224
225 Val in Block pp 0
226 WORKSHEET 0 @[2, 2] FLOAT
227 A B
228 > ------------------<
229 1: 62 72
230 2: 11 25
231 < ------------------ >
232
233 Counter in Block pp 0
234 WORKSHEET 0 @[2, 2] PIX
235 A B
236 >------<
237 1: 9 10
238 2: 9 6
239 < ------ >
240
241 hash table 0
242 WORKSHEET 0 @[2, 2] STRING
243 A B
244 >------------------ <
245 1: 81b8... 6948a 8722...0fede
246 2: 4fc8...05eeb8 b7a5...e73569
247 <------------------>
248
249 Final Merkel Tree in each block
250
251 ENDS bch6_2520 Elapsed Time : 0.828 sec
252 Boost version : 1.80.0
253
254 EXIT FROM EXSAN
Polulating ExSan with Market Data Tick by Tick
Previous
Low Latency Systematic Trading Algorithm
Next
+
+
C
E
x
S
a
n
C
+
+
D
o
N
o
t
A
c
c
e
p
t
D
e
f
a
u
l
t
s
T
h
i
n
k
D
i
f
f
e
r
e
n
t
Comments
Post a Comment