Bitcoin and The Blockchain
Bitcoin and The Blockchain
Session 1
What is money?
-Money is memory
-More precisely, it is collective memory
-What both examples—and numerous additional ones that could be listed—illustrate is how
important “myth,” unquestioned belief, is in monetary matters.
-Bitcoin can be thought of as a virtual gold - money that requires minimal trust
Byzantine failures are defined as arbitrary deviations of a process from its assumed behavior
based on the algorithm it is supposed to be running and the inputs it receives. Such failures
can occur, e.g., due to a software bug, a (transitional or permanent) hardware malfunction, or a
malicious attack
Features of Blockchain:
-Organizationally decentralized but logically centralized
-A full audit trail is available to everyone: every node verifies this trail
-Cryptographic integrity checks make the blockchain tamper proof
Anonymity - “Across the middle of it a single sentence had been formed by the expedient of
pasting printed words upon it: As you value your life or your reason keep away from the moor”. -
Hound of Baskervilles
Cryptographic Primitives
● Encryption
● Public Key Infrastructure
● Cryptographic hashes
● Digital signatures
● Cryptographically secure pseudo random number generators (CSPRNG).
● Caesar cipher
○ Encryption Algorithm: Shift every letter 3 places to the left
○ Decryption Algorithm: Shift every letter 3 places to the right
● Caesar cipher + keys = Vigenere cipher
● Modern cryptography conforms to Kerchoffs’s principle that the keys are secret but the
cryptographic system is not secret.
Session 3
12th September, 2018
● DNS - Deferred Net Settlement (e.g. NEFT and it operates in hourly batches). It solves
the liquidity problem. Credit Risk.
Session 4
14th September, 2018
Fx payments:
● Dollar settles on dollar RTGS and EURO settles on Euro RTGS, problem is with time
zones.
● There is a time window when all Central bank RTGS globally is open. 7 am to 9 am
central Europe time.
● CLS Bank (Continuous Link Settlement) - Their sole purpose is Fx transactions. CLS
receives money from both parties in different currencies and only and only when it
receives payment from both parties it transfers it to respective parties simultaneously.
Exposed to trade risk between transaction and settlement time but not exposed to
principal risk. This is called PvP.
○ Both transacting parties have accounts at CLS. It also has account at FED and
ECB. Example being trade between J.P. Morgan and Deutsche Bank of Dollars
and EURO.
○ A has no account at the FED. A uses a correspondent bank which has account
with CLS.
○ Distinction between Funding and Settlement: CLS bank asks for funding on net
basis but settlement is gross. This creates huge liquidity requirement for CLS
Bank. So CLS has Liquidity arrangements through Swap arrangements which
exposes it to market risk. Gross settlements are happening through liquidity
arrangements.
○ In/Out Swap
● Securities Settlement:
○ Trading - Matching buyer and seller, happens at extremely low latency
○ Clearing - a lot of Netting happens in multiple ways, obligation is bunch of Pay-In
(funds and securities) and Pay-out obligations, works in a similar fashion as CLS.
■ At Exchange level
■ At broker level
■ Delivery vs Payment
● Gross
● Net
○ Settlement
■ Funds via Central Bank or Commercial Bank
■ Securities via Depository
■ Operational issues can be involved
● Derivatives Settlement
○ Mark to Market (issues: Price feed and computations)
○ Collateral management
■ Pricing
■ Haircuts
○ Risk Management System
Session 5
19th September, 2018
Bitcoin doesn’t maintain an account. It maintains transactions. Inputs and Outputs (Spent and
Unspent). Only transactions reside on blockchain.Transactions are processed from genesis
block onwards to form UTXO database and the software which is running it can store UTXO
Database anywhere it prefers such as Oracle or Spreadsheet. Bitcoin is not fungible.
For every input is checked against UTXO database to see if input is unspent.
Bitcoin public key is not a key but its a script. In general, this is what the script says ‘Verify this
public key against this.’
Scripts allow flexibility to form different rules such as joint accounts or authority check.
Programming language is different from other languages, it is not a turing complete language.
Ethereum is a turing complete language.
Signature Script Data will contain Public Key and Digital Signature.
● Blocks are chained using hashes → Not blocks but blockheaders are chained using
hashes. How is integrity of the blockheaders ensured? Merkle tree is used.
○ Uses Binary Hash Tree.
○ Contains root hash of Merkle Tree of transaction
○ Contains hash of previous block header
Block Header:
● Merkle Root
● Previous block header
● Nonce - It doesn’t mean anything, its there only to meet some other requirement.
When the blockheader is hashed, it must begin with ‘x’ no. of zeroes. Keep changing the nonce
such that the condition is met. First miner who finds the right nonce wins or validates the
transaction. This requires huge computational power.
X depends on every block is created every 10 mins. X is dynamic. Every two weeks it is
recalibrated based on flow of computing into bitcoin network.
ASIC bitcoin mining chips are used to mine bitcoin. Arrival of transactions is a Poisson
distribution.
Session 6
20th September, 2018
Lightning Network - Really fast and low transaction cost called SegWit in Bitcoin.
m of n signatures - Bob is going to buy from Charlie and the problem is that Bob would of
course like to get the goods and verify that goods are of good quality and Charlie would like to
first get the BTC. Supposed transactions don’t happen simultaneously and they do not trust
each other. Alice is the arbitrator. Bob says that he will put money in 2 of 3 multi-sig (Alice, Bob
and Charlie). At least two signatures required to get payment.
Locktime: Similar to a post dated cheque, transaction will accepted only pre mentioned time.
Session 8
27th September, 2018
Smart Contracts: They are not restricted to blockchain. Can be implemented without even
computers. When put on open internet then requirement of following comes into picture:
-Secure Data/Trust
-Secure Computing/Trust
It's more a question of trust than security. Because trust is primary prerequisite before people
start using it. Bitcoin scripting language is crippled on purpose to remove any kind codes which
run loops. Ethereum has turing complete scripting language.
Smart Contracts should receive Money and Messages. Smart contracts are self-enforced which
means ‘Code is Law’.
Auction Process:
-Bid Start Time
-Bid Stop Time
-Open Bid or Closed Bid (have to check if someone is bidding has money or not then you ask
them deposit money along with the bid, then question of trust arises about safe return of money,
built in towards end of the bid)
Hash of the bid is sent between bid start and bid end time.
At the end of bid time, a time window is provided to submit bid in plain text.
Session 9
28th September, 2018
Fuel for ethereum is gas. You have to burn gas to run a computation and store data. Cost
everything in terms of gas, for every operation there is cost involved expressed in terms of units
of gas.
Ether is currency on the chain to pay for gas. Link between Ether and gas (?) Don’t know cost of
computation will evolve. This cost will be market determined cost. Each miner will say how ether
and gas equate, so market determined cost of gas.
Transaction stops when fees associated with it gets over. So you would estimate for gas
required plus also cost of gas in ether that day. You are always better paying estimating slightly
higher so that operation is complete and balance of gas is refunded otherwise gas gets wasted
without operation being completed.
Storage(variables)
“State”
Accounts & Balances (instead of UTXOs for Bitcoin)
-Two kinds of accounts
-Normal Accounts
-Contracts
Idea of account is that some human being owns the account. External owned accounts.
Contract can also have an Ether balance. It is completely autonomous as in once it is set up, it
is just the code and only code is the law.
1. Merkle - Patricia Trie (for each account and for a global account which has values
pointing to individual accounts):
a. Key = value pairs
b. Hashed → Root Hash
● 10 mins too long(problem with bitcoin idea implementation for Ether because messages
will be exchanged frequently)
● block every 15 secs ( a lot of blocks will be orphaned, Uncle/Ommer: a child of a parent
of a parent of a block that is not the parent, or more generally a child of an ancestor
that is not an ancestor. If A is an uncle of B, B is a nephew of A. To help reward
miners for when duplicate block solutions are found because of the shorter block
times of Ethereum (compared to other cryptocurrency). An uncle is a smaller reward
than a full block. (And if they are submitted later than the next block, the reward
rapidly diminishes, ending at zero after seven blocks later.))
Miner of ommer block gets 7/8th of ommer reward if it gets placed on the new block
being created on top accepted block by network and the guy who includes hash of
ommer block gets 1/8th of the ommer reward.
Inclusion of ommer blocks doesn’t alter the length of the chain but changes its weight
as it includes orphaned blocks. Heaviest chain instead of longest is the most
validated one called GHOST (Greedy heaviest observed subtree).