Lecture Notes 7b Blockchain and Its Application in Finance
Lecture Notes 7b Blockchain and Its Application in Finance
1
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
Goods Trading
While money is something that we use almost every day,
the exact meaning of money can be quite abstract.
2
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
3
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
4
instance, it is much easier to bring currency around as
compared to bringing bags of cocoa beans each time you
need to buy something. Furthermore, coins and papers last
longer than most commodities used for trading. For
example, if a farmer relies on direct trade using corn, he
will only have a few weeks to trade before his corn become
rotten. Currency, on the other hand, can be accumulated
and stored.
4
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
Minted Currency
Now, you probably understand why minted currency was
such an important innovation. As far back as 2500 B.C.,
Egyptians created metal rings to use as money. Then,
actual coins made from precious metals such as gold,
silver, or copper appeared around 700 B.C.
5
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
6
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
7
Cheque
Person 1 Person 2
Cheque
Cheques became a very popular non-cash method for making
payments in the 20th century. A cheque is a document that orders
a bank to pay a specific amount of money from a person's account
to the person in whose name the cheque has been issued.
Let’s use Alex and Ben as an example. For Alex to issue a cheque
to Ben, Alex must have a transaction banking account where the
money is held. When Ben receives the cheque and drops it at the
bank’s deposit box, his bank will send the relevant information to
Alex's bank. After Alex's bank has checked and confirmed that the
cheque is valid and that there is sufficient money in his account,
Alex's bank will transfer the money to Ben's bank account.
8
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
9
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
Bitcoin
As we have learnt earlier, Bitcoin is the most popular
cryptocurrency and can be accepted as payments by some
shops. But how exactly do we get bitcoins? One way to do
so is through mining.
10
Bitcoin mining
Bitcoin Mining 1
Imagine that you have been tasked to search for a long-
lost treasure. Reputed to be the largest diamond in history,
its whereabouts has been unknown for centuries… until
now. It seems that a certain someone has hidden it and
locked it away in a highly secure safe. After hunting around
the world for it, you have finally found it. Alas, just when
you thought your mission’s accomplished, you realise that
you would also need a fingerprint to open the safe. What
would you do next?
11
attempts. But if you are unlucky, the right fingerprint might
be the last one. Assuming you check one person per
minute and the Earth’s population is about 7.125 billion
people, this means that you would be on this search for the
next 13,555 years!
11
Bitcoin Hash Puzzle
Keep trying
924,591,752
Bitcoin Mining 2
This process is similar to the bitcoin mining process.
Miners will need to solve an extremely complicated
computational hash puzzle through trial and error and only
the first miner to solve the hash puzzle will be rewarded
with newly minted bitcoins. If we think of the hash puzzle
as the safe, we will know that certain inputs, such as the
fingerprint, need to be present to open the safe or solve
the puzzle. What inputs are required for the hash puzzle
then? And what exactly are we looking for by solving the
puzzle?
12
Blockchain: Digital Ledger
Block 10 Block 11 Block 12
Prev_Hash Timestamp Prev_Hash Timestamp Prev_Hash Timestamp
Hash01 Hash23
13
consists of these new transactions is added to the chain
after authentication.
13
Hash Function
• The mathematical algorithm that transforms any kind of
message into a bit array of a fixed size (the "hash value"),
regardless of the size of the input message. It is a one-way
function and infeasible to invert.
• Example:
⁃ SHA256(Blockchain) =
625da44e4eaf58d61cf048d168aa6f5e492dea166d8bb54
ec06c30de07db57e1
⁃ SHA256(blockchain) =
ef7797e13d3a75526946a3bcf00daec9fc9c9c4d51ddc7cc
5df888f74dd434d1
Hash Puzzle
This brings us back to the mining process where miners
solve the hash puzzle. You see, each block in the
blockchain contains a bunch of transactions and header
components. The records on the common ledger are
usually listed one by one. However, the transaction records
are stored using a data structure, known as Merkle tree, in
each block.
14
There are different hash functions. Bitcoin uses hash
function SHA256 to convert the information into hash
values. It generates unique, fixed length of 64-digit
hexadecimal numbers. A tiny change of the input
information, say changing uppercase H to lowercase h in
the word “Hi”, leads to a completely different output from
this value, to this value.
14
Merkle Tree
Merkle Tree
After converting individual transaction messages into hash
values, a pair of hash values can be hashed again. We
keep doing so until we have one single hash value at the
top. By doing so, we bundle up transactions in a tree-like
manner, deriving a single hash value at the top, which is
called the Merkle tree root.
15
converted into a 64-digit hexadecimal number, Merkle root.
The beauty of this data structure of Merkle tree is that first
it takes up little disk space , and second it can efficiently
verify the data changes since the Merkle root changes even
with the slightest modification of the original transactions.
15
Block 277316
As we discuss the block hash , you may notice that this 64-
digit hexadecimal number starts with many zeros. It’s
actually related to the pre-defined condition for the hash
puzzle that miners need to solve. Particularly, to solve the
puzzle, miners will have to first identify all the fields in the
header components and use them as inputs of the hash
puzzle. Similar to the idea of using a fingerprint to unlock
the safe, the inputs of the header components solve the
hash puzzle.
16
time when the block is generated. Well, all except for one.
Nonce, an abbreviation for "number only used once”, is a
unique randomly generated number . And nonce is the
number that blockchain miners are solving for to use as
one of the inputs together with all other fields to do hash.
The resulting hash value needs to meet the pre-defined
condition, for example, the pre-defined condition for block
1001 is that the hash value must have 8 leading zeros.
16
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
17
the price of Bitcoin was about USD42,500 per bitcoin in
January 2022, which means the miner would have earned
USD265,625 (6.25 42,500) for completing a block.
17
© 2022 Nanyang Technological University, Singapore. All Rights Reserved.
Application of Bitcoin
So, what’s the big deal about Bitcoin? I don’t mean the
price. I mean how does that help society ? If you want to
trade bitcoins, the lowest unit you can trade is called
Satoshi, which is the name of its founder, Satoshi
Nakamoto. 1 unit of bitcoin is equivalent to 100 million
Satoshi. Assuming a bitcoin is worth $42,500 now, a unit of
Satoshi will be worth USD 0.000425. USD1 will give you
about 2353 units of Satoshi.
18
worry about carrying your wallet around. Imagine paying it
with 2353 units of Satoshi using a PayNow equivalent
system. As of the current moment, we don’t have such a
system. For the sake of convenience, let’s imagine a term
and call it SatoshiNow. So, you go and buy a cup of coffee
using SatoshiNow. You might think, erm, why do I bother
since I already have PayNow?
You are correct. You don’t have to bother. But if you are
travelling overseas for a holiday, for example, visiting Seoul
and checking out its iconic observation tower, or
Switzerland for its famous and beautiful Chapel Bridge, and
you wanted to buy a cup of coffee. What do you do? You’d
either have gone to a money changer to get the local
currency with the risk of under or overspending before the
trip; or you can solve that issue by paying with a credit card
which usually has highly unfavourable exchange rates as
compared to a traditional money changer. Either way puts
you at a losing end.
18
Decentralised commodity system
19
was valued because everyone knew how rare it was.
19
government to control the money system. The money is
minted through mining. In addition, the transactions ledger
is kept by miners rather than banks. There may come a day
when cryptocurrencies become a more widely accepted
means of payment such that the ordinary crypto investor
might even consider buying groceries with cryptocurrency.
Having said that, you should also remember that there is
long way for bitcoin or other cryptocurrency to become
wifely accepted. There are serious associated problems as
well, such as extremely high volatility, large consumption of
electricity to maintain proof of work. We will leave that
part of discussion for you to explore in advanced courses.
19