0% found this document useful (0 votes)
34 views20 pages

Lesson 9 Finance and Blockchain Technologies

Blockchains use distributed databases, peer-to-peer transmission, transparency and pseudonymity, and irreversible recording of transactions. The key properties allow for applications like payment systems, smart contracts, land registry, and digital identity verification. Blockchain's main uses cases include international transactions, programmable money and finance through smart contracts, non-fungible tokens representing digital property, and crypto-assets. The first blockchain application was Bitcoin, introduced in 2008, which uses cryptography and digital signatures to securely record transactions on a distributed ledger without intermediaries.

Uploaded by

aa566
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)
34 views20 pages

Lesson 9 Finance and Blockchain Technologies

Blockchains use distributed databases, peer-to-peer transmission, transparency and pseudonymity, and irreversible recording of transactions. The key properties allow for applications like payment systems, smart contracts, land registry, and digital identity verification. Blockchain's main uses cases include international transactions, programmable money and finance through smart contracts, non-fungible tokens representing digital property, and crypto-assets. The first blockchain application was Bitcoin, introduced in 2008, which uses cryptography and digital signatures to securely record transactions on a distributed ledger without intermediaries.

Uploaded by

aa566
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/ 20

Lesson 9 Finance and blockchain technologies 

Introduction :

What are blockchains?


Four basic properties of the blockchain technology:

1) Distributed database

Each party on a blockchain has access to the whole database and its complete history. No single party
regulates the data.

2) Peer-to-peer transmission

Communication occurs between peers instead of through a central node. Each node stores and
forwards information to all other nodes

3) Transparency and pseudonymity

All transactions are visible to anyone with an access to the system. Users use pseudonyms
(generally a sequence of alphanumerics) to store coins and transact with each other’s (random
example in the Ethereum blockchain).

4) Irreversibility of records

Once a transaction is recorded in the database and the accounts are updated, the records cannot be
changed. Various computational algorithms and approaches are deployed to ensure that the
recording on the database is permanent.

The four points are essential for (e.g.):

• A blockchain-based payment system, like Bitcoin


• Enforceable scripts (smart contracts), on e.g. Ethereum
• Land registry
• Proofs of existence, electronic signatures and seals
• Proof of digital identity
• Proof of person / humanity

What are blockchain’s main use cases?

Cross-border (international) transactions: Traditional systems typically pass through multiple banks.
Blockchain can make the process faster and less expensive.
Progammable money: (multi-signatures, timelocks, ...), Censorship-resistance, privacy, ...
Progammable finance: smart contracts for lending, borrowing, investing, ...
Digital property (NFT, ...)
Crypto-asset, a new asset class?

An asset class is a grouping of investments that exhibit similar characteristics in terms of return and
risk factors, and are subject to the same laws and regulations. There is usually very little correlation
between different asset classes. Financial advisors focus on asset classes as a way to help investors
diversify their portfolio.
Genesis
The Blockchain technology was first succesfully used for payment systems by Satoshi Nakamato in
his/her/their 2009 paper:
Bitcoin: A Peer-to-Peer Electronic Cash System
Bitcoin is “an electronic payment system based on cryptographic proof instead of trust, allowing any
two willing parties to transact directly with each other without the need for a trusted third party.”
Since then, a rich ecosystem of cryptocurrencies has developed based on blockchain technology

The concept of blockchain as ’chain of blocks’ was invented by Haber and Stornetta in their 1991
research paper to certify when a document was created or last modified, which is crucial for
resolving issues like intellectual property rights.
They created their own timestamping service to put their scheme into action.
To apprehend the logic, we need first to understand the cryptographic mechanism of hashing

Cryptography
Encryption (le chiffrement) is the process of turning a readable human message into cyphertext, so
that if the encrypted message is intercepted, a snooper cannot understand it. (=message cache)

Decryption is the process of turning the cyphertext back into readable plaintext (texte écrit).

Breaking’ the cyphertext means working out how to decrypt cyphertext without being given the
’key’ (see below)

Let’s say Alice wants to send a message to Bob, so that only Bob can read it.
They agree to use ’+1’ as the ’key’, meaning that each letter is moved one place later in the alphabet.

 So A becomes B, B becomes C, C becomes D etc. This scheme is called the Caesar cipher.

Alice sends the cyphertext to Bob. Bob decrypts the cyphertext by shifting each letter back by one
position and gets back the plaintext.

Symmetric encryption

This type of encryption is part of a family called ’symmetric encryption’ because the same key (+1 in
this case) is used in both the encryption and decryption stages.
One of the biggest problems of symmetric cryptography is how to share the key.
Symmetric encryptions are not secure when communications can be tapped.
Then came asymmetric encryption (end of 70s)

Public Key Cryptography


The key used to decrypt a message is different (but mathematically linked) to the key used to encrypt
the message (asymmetric scheme). This makes it more secure.
If you want to receive encrypted messages you create two keys (two big numbers): a public key and a
private key.
You can share your public key with the world, and anyone can use it to encrypt messages for you!
You use your private key, known only to you, to decrypt those messages. Anyone who sends you
encrypted messages using your public key knows that only you can decrypt them.

Benefit: you broadcast your public key to everyone, not caring if eavesdroppers can see it or not.

If an eavesdropper gets the encrypted message, they can’t decrypt it because they don’t have your
private key.

Example of pubic key:


ECDSA (Elliptic Curve Digital Signature Algorithm) is an alternative to PGP:
• Pick a random number between 0 and 2 256 (1078 in decimals). This is your private key. • Do some
ECDSA maths on it to generate a public key

Although it is easy to convert a private key into a public key by doing some ECDSA maths on it, it is
mathematically impossible for someone to ’work backwards’ and derive your private key from your
public key.

ECDSA is used by Bitcoin to protect the bitcoins to be stolen in the blockchain.

A bitcoin wallet address is a hashed version of a public key (a mathematical transformation, to be


explained later).
The public key is used to ensure you are the owner of an address that can receive funds.
You can generate ECDSA keys with www.bitaddress.org (don’t use it to make real wallet addresses)

Digital Signatures
A signature is a mark that a person associates with a document as a proof of identity and content
(Wikipedia) .
This can be:
• a handwritten (and often stylized) depiction of someone’s name, nickname
• a stamp
• a fingerprint
• a digital signature

A digital signature is a mathematical scheme for verifying the authenticity of digital messages or
documents.

A valid digital signature gives a recipient very strong reason to believe that the message was created
by a known sender.

Digital signatures are used extensively in blockchains for creating valid transactions, that is by
’signing’ transaction messages ordering to move coins from your account to someone else’s.
We have seen that private keys decrypt the messages encrypted with the corresponding public key.
Here private keys encrypts messages that public key can decrypt!

Public keys are used as bitcoin addresses in the Blockchain. They can store and receive coins, like
bank accounts. A transaction is a transfer of coins from one public key to another.

When you make a Bitcoin transaction, you use your private key to sign, or authorize, the transaction
which moves bitcoins from your account to someone else’s:
1) encrypt your instruction to transfer x btc from address A to address B
2) send the encrypted message to the network of nodes which store the blockchain
3) if your message can be decrypted with your public address, the transaction is valid!

Online examples of bitcoin wallet addresses:


1FeexV6bAHb8ybZjqQMjJrcCrHGW9sb6uF
35hK24tcLEWcgNA4JxpvbkNkoAcDGqQPsP

Communications and transaction data are not encrypted and do not need to be encrypted to protect
the funds:
Pseudonymity of the users (pseudonym = wallet address) but full transparency of all transactions
executed on the blockchain.

Here the person who owns the private key associated with public key XYZ loses ownership of the
coins, while the person who owns the private key associated with public key ZRT gains ownership

Hashes
Hashing is a fundamental technique used in blockchains.

A hash function is a series of mathematical steps or algorithms that you can perform on some input
data, resulting in a fingerprint, or digest, or simply, a hash.

There are basic hash functions (not used in blockchains) and cryptographic hash functions (used in
blockchains). We need to understand basic hash functions before moving to cryptographic hash
functions.

Basic Hash Function

A really basic hash function might be ’Use the first character of the input’. Example:

Hash(‘What time is it?’) =⇒ ’W’


The input to this function is ’What time is it?’. The output of this function is ‘W’ and is the hash.
Hash functions are deterministic. They always produce the same output for any given input
Cryptographic Hash Functions:

The ideal cryptographic hash function has five main properties:

1. The same message always results in the same hash


2. It is quick to compute the hash value for any given message
3. It is not feasible to generate the message from its hash value except by trying all possible messages
4. A small change to a message should change the hash value so extensively that the new hash value
appears uncorrelated with the old hash value
5. We cannot find two different messages with the same hash.

Let’s see if our previous hash function is a good function:

1. Yes, it is deterministic 2. Yes, it is quick to compute the output 3. Yes, by knowing only ’W’ it is not
feasible to guess the original sentence 4. No, a small change in the message does not necessarily
change the output. 5. No, we can easily create loads of inputs that will all hash down to the same
output.
Our earlier hash function is not a good cryptographic hash function.

Examples of cryptographic hash functions that meet all the criteria:


• MD571 (Message Digest) • SHA-256 (Secure Hash Algorithm)
Their output is usually of a fixed length.

Hash functions can be used for proving that two things are the same without revealing the two things
(also called zero knowledge proof). Examples:
1) My guess for the winner of the French 2022 presidential election (name + arbitrary sequence
of characters) is :

6E03B25F9CD21E3715308269CC9E670ECA539C000319CB328E105E52F3655B2E

2) Hashes ensure that data (contract, dataset, software, patent, ...) has not been tampered.
3) Websites hash passwords before storing them in their dataset

Cryptographic hashes are used in Bitcoin in a number of places:


• In the mining process (proof of work)
• As identifiers for transactions
• As identifiers for blocks, in order to link them in a chain
• a bitcoin address is a hash of the public key
Blockchain’s first use case: timestamping

Clients create a hash of a digital document, which is then sent to the company where it is
timestamped, hashed and published in the New York Times. The hash is placed in a small ad in the
classified section under the heading ’Notices & Lost and Found’.
Problem: How to prevent someone from making a fake copy of the NYT with a different data and
hash?

Solution: create a chain of hashes = include the previous hash in the next block of data.

If one block is tampered (altéré), all successive blocks do not certify anymore its validity. The chain is
broken.

To tamper a block of data, the company or any malicious actor would need to fake not only the
newspaper in which it is published, but also all following newspapers with a different chain of hashes
and circulate them more widely.

Given that the New York Times has an average daily print circulation of about 570,000 copies, it is
impossible for to modify a seal.
The chain of blocks (’blockchain’) creates an immutable record of all the seals ever produced.
What about recording a chain of monetary transactions ?

Bitcoin:

Bitcoins are digital assets (’coins’) whose ownership is recorded on an electronic ledger (the
blockchain) that is updated (almost) simultaneously by about 10,000 independently operated
computers (nodes) around the world that connect with each other.

Each node (noeud) independently validates all pending transactions wherever they arise, and
updates its own record of the ledger with validated blocks of confirmed transactions.
Nodes gossip with each other. Gossip communication is similar to office workers spreading rumors.
Nodes share the latest gossip with a random set of nodes, which can now spread the gossip
themselves. (fil d’araigné)

Nodes are computers which run a software called ’Bitcoin Core’. The software is freely downloadable
(permissionless): https://bitcoin.org/. It contains the full range of functionalities to run the network:

• connect with other participants in the Bitcoin network


• create and send transactions
• listen for new transactions
• validate transactions
• relay valid transactions to other nodes
• listen for new blocks and validate those blocks
• relay valid blocks
• store the blockchain (list of blocks)

Miners

Specialist nodes, called miners, bundle together valid transactions into blocks, mine them, and
distribute those blocks to nodes across the network

Blocks are a way to control the data entry into the ledger. Transactions are not recorded one by one
but in batches, ’page by page’.

Individual pending transactions ( transaction individuelles en attente) stay in a waiting room, called
the memory pool (or mempool), duplicated in all the network’s nodes, before being added in a block
by a miner.

The double spending problem:


To understand mining and why valid transactions must be bundled into blocks, we need first to
understand the double spending problem.
With digital signature, Bob cannot ’steal’ the bitcoins of Alice by transferring them to a new address
that he controls. Only Alice, who owns the private key, can transfer the bitcoins from one address to
another
But imagine Alice transfers the same bitcoins to Bob and Charles at the same time. What would
happen?

(...) the payee can’t verify that one of the owners did not double-spend the coin. (...) We need a way
for the payee to know that the previous owners did not sign any earlier transactions. For our
purposes, the earliest transaction is the one that counts, so we don’t care about later attempts to
double-spend. The only way to confirm the absence of a transaction is to be aware of all transactions.
(...) To accomplish this without a trusted party, transactions must be publicly announced, and we
need a system for participants to agree on a single history of the order in which they were received.
The payee needs proof that at the time of each transaction, the majority of nodes agreed it was the
first received

The validity of a transaction is not sufficient to be included in the public ledger. Without the
additional step of confirmation by miners, some nodes could record:

 Alice =⇒ Bob (Bob is first and Charles cannot receive the bitcoins anymore since the
transaction would not be valid)

and other nodes could record:

 • Alice =⇒ Charles (and Bob receives nothing)

How to settle a disagreement in a decentralized network? How the network can reach a consensus
”on a single history of the order in which [transactions] were received“?

Consensus rule: the right transaction is the one confirmed by the miner who wins a special contest.
Prize of the contest: freshly minted bitcoins (currently 6.25 btc).

The contest: a guessing game

Rules of the game:

1. build a block with txs from the mempool (around 2 300 or 1.3 Mb of data per block) + the reward
(called a coinbase tx)
2. add to the block the hash of the last confirmed block
3. guess a nonce (number only used once)
4. hash the entire blocks (previous hash + txs + nonce)
5. if the hash begins by 19 zeros (as of September 2021), you win! (example)
6. else return to 3., and try another nonce.

Why finding a pattern in a hash?

Only brute force can be used.

Hard to find, easy to verify (digital puzzle)


The difficulty level of the task can be easily changed: ask more zeros (if too easy) or less zeros (if too
difficult)
Difficulty is changed every 2016 blocks (around two weeks) based on the time it took to discover the
2016 previous blocks. Average time of finding a single block = difficulty ×232 / hashrate where
hashrate is the amount of hashes a miner can compute per second.

Mining rewards:
Two types of rewards: coin creation and transaction fees. (frais de transaction)
For every block mined, miners got:
2009-2012: 50btc
2012-2016: 25btc
2016-2020: 12.5btc
Since May 2020: 7.25 btc

The reward is cut in half every 210 000 blocks mined (around 4 years). Except if the price doubles
every four year, miners will have to rely more and more on fees to be compensated for CPU spending

Proof-of-work consensus algorithm:


Once a miner finds a solution, the block is broadcast to the network. Other nodes check that the
block is valid, then add it to their copy of the blockchain and broadcast the block to other nodes.

As soon as miners receive a valid block, they stop mining the previous block and try to mine a new
block on the top of the just received mined block. A new contest begins.

This is the first consensus rule to prevent double spending: transactions are added to the ledger
block by block. Only blocks solving the guessing games are valid.

Forks:

Now, imagine that two miners solve the puzzle at the same time and simultaneously broadcast the
two blocks (say A and B) to the network. Fist come first in does not work in a decentralized network.
Which block to add to the ledger: A or B?
If nothing is done, a subset of the miners will try to mine the next block on top of block A, and the
rest on top of block B. The blockchain will experience a fork.
A new block extends one fork ( une fourche), reconverging the network.
Some nodes are forced to revise their view of the blockchain (chain reconvergence/reorganization)

Forks happens regularly and naturally (2 or 3 times per year). Usually resolved after 1 block.
This is the second consensus rule: always keep as legitimate the chain of blocks with the highest CPU
effort (i.e. the longest chain).

Malicious nodes

Can malicious nodes trick the network and still double spend?

1. transfer btc against dollars and withdraw the dollars from the exchange
2. then try to rewrite the blockchain (by forking) and cancel transaction x.
To succeed, the malicious nodes must catch up the legitimate chain built by honest nodes, mine
multiple alternative blocks and spend a lot of CPU power.

The malicious nodes must rehash not only block n but also all blocks forward!

The race for the longest chain

The nodes with the greatest hashrate are more likely to find the next block first and eventually to win
the race.
Attempting to rewrite the blockchain is called a 51% attack.

The is is why it is safe to consider a transaction confirmed only after several additional blocks mined.

Example: In May of 2018, Bitcoin Gold, at the time the 26th-largest cryptocurrency, suffered a 51%
attack. The attackers were able to double-spend for several days, eventually stealing more than $18
million worth of Bitcoin Gold.

Hard fork:
A hard fork is a software update of the protocol, with the intention to improve its functioning.
Suppose the community of developers write a software update to scale the payment system, for
example by increasing the block size or reducing the average mining time of 10 minutes. Now it is up
to the nodes to download and use the updated version.
If everyone in the network is on board with the change and they all implement it at a pre-agreed
time, they can all continue collectively maintaining the blockchain with the change in effect.
However, suppose that nodes disagree on the benefit of the update. Half update and half do not. Let
us call miners who update U and miners who did not update NU, and let us assume that the change is
an increase of the block size from 1.3Mb to 8 Mb.

8Mb blocks mined by U are not considered valid by NU, which continue to mine 1.3Mb blocks.

This causes a chain split, or a contentious hard fork. Two communities of nodes begin maintaining a
different blockchain.
If someone had 10 btc at the date of the fork, (s)he has now 10 btc in blockchain A and 10 btc in
blockchain B.

Soft forks/
Hard forks expose the network to the risk of split (RISQUE DE SCISSION). This is a bad outcome:
dividing the computing power and hashrate weakens the network by making 51% attacks more
profitable.
This is why soft forks are a preferred way to upgrade the protocol. With a soft fork, only the
blockchain with the the updated protocol can persist.

Suppose the new protocol reduces the block size from 1.3Mb to 0.5Mb. NU continue to mine 1.3Mb
blocks and to send them to both U and NU.
However, U discard blocks mined by NU and mine 0.5Mb blocks only on top of 0.5Mb blocks. To the
contrary, NU mine 1.3Mb blocks on top of either 1.3Mb or 0.5Mb blocks.

The asymmetry gives a decisive edge to U:


Let α ∈ (0,1) the CPU (or hashrate) share of U in the network. Suppose A from U and B from NU mine
and propagate a block at the same time.
The share of nodes who will mine on top of the block B is 0.5(1−α) and the share of nodes who will
mine on top of block A is 1−0.5(1−α) = 0.5(1 + α). U always wins the race for the longest chain
because the whole set is always bigger than any of its part: 0.5(1+α) > 0.5 or if α > 0.

To sum up:

• Temporary forks happen when two valid blocks propagate at the same time. The fork rapidly
resolves by adopting the longest chain.

• In soft forks, U discard blocks mined by NU but NU accept blocks mined by U. The new protocol is
forward compatible. NU are on the loosing fork and are forced to update.

• In hard forks, the new protocol is not forward compatible: NU discard blocks mined by U. U may or
may not accept blocks mined by NU, but they don’t want to. If contentious, the network splits and a
new cryptocurrency is going live.

Ethereum:

Ethereum is a decentralized, open source, and distributed computing platform that enables the
creation of smart contracts and decentralized applications, also known as dapps.

It is also a programming language running on the blockchain, helping developers to build and publish
distributed applications.
The nodes not only record the transactions in the blockchain (as does Bitcoin) but also store and
execute small programs (smart contracts) written in a complete programming language.
Ether:
Ether is the native digital currency of Ethereum.
The execution fees for any operation made on Ethereum is priced in Ethers.
The fees depend upon the amount of computational power and time required by a particular
process, request, or transaction.
The more computation power and time is needed by an app, the higher the ether fee (the gas) that is
charged for the action to be completed.

Smart contracts:
A smart contract ( un contrat intelligent) is a self-executing contract with the terms of the agreement
between buyer and seller being directly written into lines of code.
The code and the agreements contained therein exist across a distributed, decentralized blockchain
network. The code controls the execution, and transactions are trackable and irreversible.
Smart contracts permit trusted transactions and agreements to be carried out among disparate,
anonymous parties without the need for a central authority, legal system, or external enforcement
mechanism.
The current state of Ethereum is composed of accounts which are either externally owned accounts
(EOA) or contract accounts (CA).

Users can either send a transaction from one EOA to another EOA, or from an EOA to a CA. A
transaction sent from an EOA to a CA results in execution of the code within the smart contract.

When a transaction pokes at a smart contract and the criteria for execution are met, the contract is
processed. Whatever code existing inside is executed.

ERC-20
One of the most significant Ethereum tokens is known as ERC-20. They are used for interacting with
smart contracts.

They are blockchain-based assets that have value and can be sent and received. Instead of running
on their own blockchain, ERC-20 tokens are issued on the Ethereum network.

More than 200,000 ERC-20-compatible tokens exist on Ethereum’s main network.

Decentralized finance:

Decentralized finance (Defi) is a form of finance that does not rely on central financial intermediaries
such as brokerages, exchanges, or banks, and instead utilizes blockchains, the most common being
Ethereum.

DeFi platforms allow people lend or borrow funds from others, speculate on price movements of a
range of assets using derivatives, trade cryptocurrencies, insure against risks, and earn interest in
savings-like accounts.
Each DAI is backed by Ether (or other cryptocurrencies).
Investors deposit/send Ether to Maker’s smart contract, creating a Collateralised Debt Position (CDP).
The value in Ether must always be greater of the value of DAI minted. This is achieved through
overcollateralization.

Liquidation risk:
Suppose the price of ether drops, for example to 250.

The new debt ceiling is 10 × 2/3 × 250 = $1667.


The ETH are exposed to liquidation and can be immediately sold for 10 × 250 = $2500.
After the liquidation the borrower is left with 2500 - 2000 - × 0.13 2500 (liquidation fees) = $175.

Maintaining the peg with the dollar:

Borrowers pay an interest rate on their Dai, currently 2% (when collateralized with ethers). It is called
a stability fee.
If demand for DAI ¿ supply for DAI: 1 DAI > 1 dollar => stability fee decreases (e.g. from 2 to 1%) =>
More Dai are minted or less DAI are paid back => supply increases.

If demand for DAI < supply for DAI: 1 DAI < 1 dollar => stability fee increases (e.g. from 2 to 3%) =>
Less DAI are minted or more DAI are paid back => supply increases.

Leverage:

Suppose the price of ether is 400 and you expect it will increase to 500. You can borrow DAI and
leverage your ETH position:
Deposit 10 ETH
Mint 2000 DAI
Buy 2000/400 = 5 ETH
Deposit 5 ETH
Mint 1000 DAI
Buy 1000/400 = 2.5 ETH etc.
Total: 10 + 5 + 2.5 + 1.25 + ... = 20 ETH

Conclusion:
Management of private keys: If a malicious party accesses private keys, or if keys are lost, assets will
be forever inaccessible.
Money laundering: While ownership and crypto-to-crypto transfers are pseudonymous, it is not the
case of conversions crypto/fiat currencies. Financial regulators impose strict KYC (Know Your
Customers) to crypto exchanges.
Scalability: VISA handles 4,000 transactions per second on average. Bitcoin: 8, due to the fact that
block sizes are restricted to have a maximum size of 1.2 MB and a block is mined every 10 minutes on
average.

You might also like