0% found this document useful (0 votes)
6 views

FinTech Lecture 2

Uploaded by

Muhammad Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

FinTech Lecture 2

Uploaded by

Muhammad Ahmed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

FINTECH and BLOCKCHAIN

FIN17018

Lecture 2:
The Blockchain Innovation
In Preparation for this Lecture
• All students should watch:
– The the Bitcoin documentary on Netflix (“Banking on Bitcoin”) about
the background and events associated with Bitcoin. Very interesting!

– A short video about so called “Byzantine General Problem” (related to


Blockchain and establishing trust):
https://twitter.com/SJosephBurns/status/953252564887330816

– A longer video that describes in more detail the Byzantine General


Problem and how Blockchain solves it: “The Byzantine Generals
Problem and Blockchain Consensus Models | A Deep Dive”
https://www.youtube.com/watch?v=YJHcoHxfor4

– Watch the documentary named “The Blockchain and Us”. It can be


found through: https://blockchain-documentary.com/
CRYPTO
• Cryptology, the process of concealing messages, has been
used for the last 4,000 years.
• It started at least as long ago as the Egyptians, and continues
today and into the foreseeable future.
• The term cryptology is from the Greek krypt´os, meaning
secret or hidden, and log´os, meaning science.
• The term cryptology has come to encompass encryption
(cryptography, which conceals a message) and decryption
(revelation by cryptanalysis).
• If you want to understand what all this is coming from
(crypto, etc.) check out these websites:
• http://cseweb.ucsd.edu/~mihir/papers/gb.pdf
• http://www.crypto-textbook.com/
• https://www.youtube.com/watch?v=YEBfamv-_do
References from Nakamoto (2008) paper
• References
• [1] W. Dai, "b-money," http://www.weidai.com/bmoney.txt, 1998.
• [2] H. Massias, X.S. Avila, and J.-J. Quisquater, "Design of a secure
timestamping service with minimal trust requirements," In 20th Symposium
on Information Theory in the Benelux, May 1999.
• [3] S. Haber, W.S. Stornetta, "How to time-stamp a digital document," In
Journal of Cryptology, vol 3, no 2, pages 99-111, 1991.
• [4] D. Bayer, S. Haber, W.S. Stornetta, "Improving the efficiency and
reliability of digital time-stamping,“ In Sequences II: Methods in
Communication, Security and Computer Science, pages 329-334, 1993.
• [5] S. Haber, W.S. Stornetta, "Secure names for bit-strings," In Proceedings
of the 4th ACM Conference on Computer and Communications Security,
pages 28-35, April 1997.
• [6] A. Back, "Hashcash - a denial of service counter-measure,"
• http://www.hashcash.org/papers/hashcash.pdf, 2002.
• [7] R.C. Merkle, "Protocols for public key cryptosystems," In Proc. 1980
Symposium on Security and Privacy, IEEE Computer Society, pages 122-
133, April 1980.
• [8] W. Feller, "An introduction to probability theory and its applications,"
1957.
What is a Blockchain?
• Blockchain was invented to solve a particular problem that
Cypherpunks faced when inventing Bitcoin:
– how to store information in a reliable way and
– how to do it in a non-centralized fashion.
• Blockchain is fundamentally a new type of database technology
(accounting) that is optimized to tackle a unique set of
challenges.
– Historically, databases have been used as central data repositories by
organizations to support transaction processing and computation.
– However, databases are rarely shared be tween organizations due to a
variety of technology and security concerns.
• Blockchain is a shared, distributed database of transactions
among parties that is designed to increase transparency, security,
and efficiency.
• Blockchain: A database organized as a Merkle tree, updated via a
strategy-proof communal consensus protocol (a cryptographic
puzzle).
BLOCKCHAIN IS:
A database or a ledger (with copies of the database replicated
across multiple locations or nodes)
of transactions (between two or more parties)
split into blocks (with each block containing details of the
transaction such as the seller, the buyer, the price, the contract terms,
and other relevant details)
which are validated by the entire network via encryption by
combining the common transaction details with the unique
signatures of two or more parties.
– The transaction is valid if the result of the encoding is the same for all
nodes
and added to the chain of prior transactions (as long as the block
is validated).
– If the block is invalid, a “consensus” of nodes will correct the result in
the non-conforming node.

Source: Goldman Sachs Profiles in Innovation: Blockchain


What is Blockchain good for?
• “Blockchain is used for auditing, insurance, logistics, and other applications” – D.
Yermack
– PwC and Northern Trust (custody bank) just announced that they're launching an "instant audit" product via a private
blockchain to increase transparency and decrease audit times.
– March23, 2018: The governor of Tennessee just signed a law that will officially recognize smart contracts as legally
enforceable. This is important step in accelerating Blockchain adoption & making our world more efficient. More states
will follow soon.
– March23, 2018. Two condos in New York City were recently purchased with Bitcoin. This is believed to be the first real
estate purchase in NYC via Bitcoin.
• Blockchain is well suited to address a variety of problems:
– Facilitating secure, de-centralized transactions among many parties
• Because of the inherently decentralized nature of the ledger, Blockchain is particularly effective at handling
distributed transactions among a very large number of parties.
• In addition, Blockchain delivers a high level of security for each transaction because of the cryptographic
verification and validation among parties.
– Reducing fraud and increasing trust with increased security
• Corruption can lead to counterfeiting or alteration of official records.
– For example, bribery might drive a government insider to change a record describing the amount of a payment made,
or the owner of record of a particular asset.
• A malicious actor might attempt to selectively alter or destroy records (for example a cyber-hacker
changing payment records or trades between parties).
– Because each transaction is uniquely encoded via cryptography and this encoding is validated by other parties on the
Blockchain, any attempt to alter or remove transaction information would be detected by others and corrected by
other nodes.
– Increasing transparency and efficiency in multi-party transactions
• In any transaction involving two or more parties, the same transaction is typically entered separately by
each party into that organization’s own independent systems.
• By using a distributed ledger technology such as Blockchain, organizations can streamline the clearing and
settlement process, shorten settlement windows, and avoid substantial capital and operating expenses.
• Read the 7 case studies in Goldman Sachs’ Report: “Profile in Innovation: Blockchain”
Bitcoin & Blockchain Technology
• Bitcoin is a math-based digital currency;
• Bitcoin rules (software, procedures, etc.) are set originally in 2008 by
Satoshi Nakamoto, but are currently maintained by “the network”.
– If substantial majority of the nodes in the network disagree there could be a
mutually agreed “divorce” between the parts of the network . This creates so
called “Hard Fork.”
• As long as majority of “the network” agree on these rules they
continue to be implemented.
• Bitcoin rules are set such that:
– Every 10 minute one puzzle is solved (one block is mined)
– In the past, solving one puzzle was worth 25 bitcoins.
– After certain period (in 2016) the rewards was cut in half to 12.5 bitcoins
for solving each puzzle. In the 2020 halving, it will drop from 12.5 to 6.25.
• Satoshi Nakamoto, Bitcoin’s creator, set the block reward schedule when he created Bitcoin. It is one of Bitcoin’s
central rules and cannot be changed without agreement between the entire Bitcoin network.
• The block reward started at 50 BTC in block #1 and halves every 210,000 blocks. This means every block up until
block #210,000 rewards 50 BTC, while block 210,001 rewards 25. Since blocks are mined on average every 10
minutes, 144 blocks are mined per day on average. At 144 blocks per day, 210,000 blocks take on average four
years to mine.
• Check http://bitcoinclock.com/
• All 21 million bitcoins (BTC) will be mined by 2140. But more than 98% will be mined by 2030.

• (Continues on the next slide)


Bitcoin & Blockchain Technology (cont’d)
– So the amount of work you have to do per Bitcoin goes up.
– The halving is necessary. This is how Bitcoin controls its supply. This is
supposed to reduce inflation; But because coins get lost (evaporate), then
one can argue that Bitcoin system is actually deflationary.
– Once the block subsidy expires, transaction fees will pay miners for
securing the network. The block reward is the only way that new bitcoins
are created on the network.
– Satoshi explained this in an early email post in 2009: “Coins have to get
initially distributed somehow, and a constant rate seems like the best
formula.”
• The block reward creates an incentive for miners to add hash power
to the network. The block reward is what miners try to get using
their computing power, which make up the entirety of the Bitcoin
network hash rate.
• So, Bitcoin miners play central role in this Bitcoin system.
• Bitcoin users must pay a fee when sending a transaction on the
network. Right now, these fees are small since there aren’t many
Bitcoin users. Eventually, these transactions fees will become larger
and will help make up for the decreasing block reward.
Bitcoin Miners
– Bitcoin miners build and maintain a gigantic public ledger containing a
record of every bitcoin transaction in history.
– Every time somebody wants to send bitcoins to somebody else, the
transfer has to be validated by miners:
• They check the ledger to make sure the sender isn’t transferring money she
doesn’t have.
• If the transfer checks out, miners add it to the ledger.
• Finally, to protect that ledger from getting hacked, miners seal it behind layers
and layers of computational work—too much for a would-be fraudster to
possibly complete.
– And for these service, they are rewarded in Bitcoins.
– Miners are all competing with each other to be first to approve a new
batch of transactions and finish the computational work required to seal
those transactions in the ledger. With each fresh batch, a new block is
created and the winner takes all.
– It’s the computational work that really takes time, and that’s is designed
to work that way. Trying to solve a kind of cryptographic problem that
involves guessing and checking billions of times until it finds an answer.
– May seem annoying, but mining is an elaborate solution to a tough
problem that plagues every currency—double spending.
Double spending and a public ledger
• Double spending is when somebody spends same money more than once.
– It’s a risk with any currency.
– Traditional currencies avoid it through a combination of hard-to-mimic physical
cash and trusted third parties—banks, credit-card providers, and services like
PayPal—that process transactions and update account balances accordingly.
• Bitcoin is completely digital, and it has no third parties (no overseeing body).
– So if you tell me you have 7 bitcoins, how do I know you’re telling the truth?
– The solution is that public ledger with records of all transactions, known as the
Blockchain. Sometimes also called DLT.
– Basically, the idea is that if all of your Bitcoins can be quickly traced back to when
they were created, and each transaction when they exchanged hands, you can’t
get away with lying about how many you have.
– So every time somebody transfers Bitcoins to somebody else, miners consult the
ledger to make sure the sender isn’t double-spending. If she indeed has the right
to send that money, the transfer gets approved and entered into the ledger.
– Using a public ledger comes with some problems.
• Privacy - How can you make every Bitcoin exchange completely transparent while
keeping all Bitcoin users completely anonymous?
• Security - If the ledger is totally public, how do you prevent people from fudging it for
their own gain?
Maintaining Privacy in a Blockchain
• To solve the Privacy problem the Bitcoin’s ledger uses a
bit of accounting trickery.
– The ledger only keeps track of bitcoin transfers, not account
balances.
– There is no such a thing as a bitcoin account, which keeps
users anonymous.
– When Alice wants to transfer one bitcoin to Bob here is the
procedure they follow:
• First, Bob sets up a digital address (i.e., like an e-mail account) for
Alice to send the money to, along with a key (password to the e-
mail account) allowing him to access the money once it’s there.
• Bob sets up a new address and/or new key for every incoming
transaction (he doesn’t have to do this, but it’s highly recommended
to keep anonymity).
• When Alice clicks a button to send the money to Bob, the transfer is
encoded in a chunk of text that includes the amount and Bob’s
address.
Maintaining Privacy in a Blockchain (cont’d)
• Here’s what that transaction actually looks like:

Quoted in satoshi;
Equivalent to 50
bitcoins

• This transaction record is sent to every


Bitcoin miner
• i.e., every computer on the
internet that is running mining
software
• if it’s legit, it gets added to the ledger.
Maintaining Privacy in a Blockchain (cont’d)
• If the transaction is
accepted by the
miners network:

• Next, say in another transaction Bob wants to pay Carol one Bitcoin.
• Carol of course sets up an address and a key.
• And then Bob essentially takes the Bitcoin Alice gave him and uses his address and
key from that transfer to sign the bitcoin over to Carol:

• This transaction gets sent out to all of the miners, and they will check (using the reference
number from Alice’s transfer to Bob) to make sure that Bob hasn’t already transferred
that bitcoin to somebody else. No double spending.
• After validating the transfer, each miner will then send a message to all of the other
miners, giving his/her blessing.
Maintaining Privacy in a Blockchain (cont’d)

• If the Bob to Carol


transaction is also
accepted by the miners
network then it too gets
added to the ledger:

• That’s all transactions are—people signing Bitcoins (or fractions of


bitcoins) over to each other.
• The ledger tracks the coins, but it does not track people, at least not
explicitly.
• Assuming Bob creates a new address and key for each transaction,
the ledger won’t be able to reveal who he is, or which addresses are
his, or how many bitcoins he has in all.
• Ledger is just a record of money moving between anonymous hands.
Maintaining Security in a Blockchain
• The first thing that Bitcoin does to secure the ledger is decentralize it.
• There is no huge spreadsheet being stored on a server somewhere. There
is no master document at all.
• Instead, the ledger is broken up into blocks: discrete transaction logs that
contain 10 minutes worth of Bitcoin activity apiece.
• Every block includes a reference to the block that came before it, and you
can follow the links backward from the most recent block to the very first
block (The Genesis Block), when Bitcoin creator Satoshi Nakamoto created
the first Bitcoins into existence.
• This lineage of blocks is the Blockchain, and it constitutes Bitcoin’s public
ledger.
• Every 10 minutes miners add a new block, growing the chain.
• Generally speaking, every bitcoin miner has a copy of the entire block chain
on her computer.
– If she shuts her computer down and stops mining for a while, when she starts
it back up, her machine will send a message to other miners requesting the
blocks that were created in her absence.
– No one person or computer has responsibility for these block chain updates;
no miner has special status.
– Updates, like the authentication of new blocks, are provided by the network of
bitcoin miners at large. Community effort called Nakamoto consensus
A Block’s Lifecycle
The genesis block
- The very first block. It is assumed to be shared between the initial nodes.

Blocks lifecycle
Each node, periodically:
1 listens for transactions published by other nodes
2 validates, consistency-checks & executes them
3 compiles the new local candidate transactions to potentially form a new block
4 participates to the consensus algorithm
i.e. negotiates the next block to be appended to the blockchain
- this phase also includes a spreading of the block to peers
Proof of Work and Ledger Security
• The second thing that keeps the ledger security is by usage of
cryptographic puzzle (proof of work).
– So dividing the ledger up into distributed blocks isn’t enough on
its own to protect the ledger from fraud.
• To add a new block to the chain, a miner has to finish what’s
called a cryptographic proof-of-work problem.
• Such problems are impossible to solve without applying a ton
of brute computing force.
– If you have a solution in hand, it’s proof that you’ve done a
certain quantity of computational work.
– The computational problem is different (varying difficulty and
time consumed) for every block in the chain.
– It involves a particular kind of algorithm called a hash function.
– Like any function (e.g., log(x), etc.), a cryptographic hash function
takes an input—a string of numbers and letters—and produces an
output.
Properties of Cryptographic Hash Functions
• There are several things that set cryptographic hash functions apart:
1. The output is of predetermined length, regardless of the input.
– The hash function that Bitcoin relies on is called SHA-256 (developed by the US
National Security Agency) and it always produces a string that is 64 characters
long (=256 bits).
For exp: 7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069
– You could run your name through that hash function, or an entire book. In either
case, you’ll get 64 characters out the other end.
– And, for a given input, you’ll always get the same output.
• 2. It’s impossible to make a cryptographic hash function work in
reverse.
• If you have the output of a cryptographic hash function (called “a hash” for short),
there’s no way of knowing what the input was.
• It’s a one-way street. And that’s what makes it cryptographic—you can use a hash
function to scramble text in a way that’s impossible to unscramble (remember the
word “crypto”).
Properties of Hash Functions (cont’d)
3. Changing the input even a little bit changes the output dramatically
• With hash functions, a slight variation in the input results in a completely different
output:
• The proof-of-work problem that miners have to solve involves taking a hash of the
contents of the block that they are working on (all of the transactions, some meta-
data like a timestamp, and the reference to the previous block) plus a random
number called a nonce.
• Their goal is to find a hash output that has at least a certain number of leading
zeroes. Something like this:
– Example of a real solution: 0000000000000000011eae2aca0e002ed6d5fa1fb6a3755dbcaa8b0cab0ec3f6
• That constraint is what makes the problem more or less difficult.
• More leading zeroes means fewer possible solutions, and more time required to
solve the problem. Every 2,016 blocks (roughly two weeks), that difficulty is reset.
• If it took miners less than 10 minutes on average to solve those 2,016 blocks, then
the difficulty is automatically increased. If it took longer, then the difficulty is
decreased.
• Miners search for an acceptable hash by choosing a nonce, running the hash
function, and checking. If the hash doesn’t have the right number of leading
zeroes, they change the nonce, run the hash function, and check again.
Properties of Hash Functions (cont’d)
3. Changing the input even a little bit changes the output dramatically
• Because of the one-way nature of hash functions, you can’t work
your way backwards to find a nonce that fits.
• And because of a hash function’s unpredictability, applying
“strategies” or logic to different nonces never really gets you closer
to the right one. It’s all a process of elimination.
• When a miner is finally lucky enough to find a nonce that works, and
wins the block, that nonce gets appended to the end of the block,
along with the resulting hash output.
• The whole block then gets sent out to every other miner in the
network, each of whom can then run the hash function with the
winner’s nonce, and verify that it works.
• If the solution is accepted by a majority of miners, the winner gets
the reward, and a new block is started, using the previous block’s
hash output as a reference.
• Read also Narayana, et al. (2015) book. Chapter 1.
SHA-256 Hash Function
• The creator of the Bitcoin protocol, Satoshi Nakomoto, chose to use the
SHA-256 hash function as the basis for Bitcoin mining.
• This is a specific cryptographic hash function developed by NSA that has
been mathematically proven to hold the properties we mentioned.
• It always outputs a 256 bit number, which is usually represented in the
hexadecimal number system with 64 characters for human-readability.
• The output of the SHA-256 function is usually referred to as the hash of
its input.
• Try creating hash output yourselves through this website:
• https://www.xorbin.com/tools/sha256-hash-calculator
• Try any word and play with it. Then, also try this: Hello, world!4250
Cracking SHA-256 Hash Function: How tough?

• SHA‐256 maximum input size is 264‐1 bits: How large number is this number? 18.45
quintillion
• Suppose you put one penny on the first square of a chess board, two pennies on next, etc.
• How much is on the last square?
• Answer: $9,223,372,036,854,780.00 ($9.2 quintillion)
• US GDP is ~$20,000,000,000.00 ($20 trillion)

• Since 264‐1 = 18.45 quintillion, so maximum input size is 18.45 quintillion bits of
input

• Thus, to back-engineer (i.e., “to break”) a hash output of the SHA‐256, you need to
evaluate 2256 possible inputs.
Composition of a Block
• Composition of a Block (80 bytes):
• 4 bytes: version number (same for all miners)
• 32 bytes: the hash output of the previous block (same for all miners)
• 32 bytes: hash output of the transactions in the candidate block
• 4 bytes: time stamp
• 4 bytes: difficulty of task (same for all miners)
• 4 bytes: nonce
• Miner will search for a nonce:
• A good machine can try all possible 32‐bit nonce combinations in about 1
second (about 4 billion calculations); 55

• Miner will also vary the order to which transactions are grouped (in a Merkle
tree);
• Time stamp can also be varied;

You might also like