demysitifying bitcoin and blockchain

32
Demystifying Bitcoin and Blockchain Ganesh Kondal

Upload: ganesh-kondal

Post on 13-Jan-2017

358 views

Category:

Internet


2 download

TRANSCRIPT

Page 1: Demysitifying Bitcoin and Blockchain

Demystifying Bitcoin and Blockchain

Ganesh Kondal

Page 2: Demysitifying Bitcoin and Blockchain

IntentIntent is to understand bitcoin and take a deeper look at blockchain – the technology that is enabling bitcoin

What I cannot cover• Bitcoin – is more than technology; it is economics• Leaving few basics, cannot cover details on bitcoin adoption• Leaving few basics on cryptography, will not be able to cover the internals

Page 3: Demysitifying Bitcoin and Blockchain

AgendaSegment 1 : Currency• Currency Economics • Money Creation

Segment 2 : Bitcoin • Bitcoin – buy BTC, how to transact with BTC

// wallets• Digital Signing – Wallet • Cryptography Basics• Transaction Ordering

Segment 3 : Blockchain • Some basics

• Hash function, partial hash inversion, • Proof of work systems

• Blockchain Internals• Block Difficulty & Mining• Blockchain Threats

• Dispute Resolution • Double Spend Attack [Security Hole /

Threat]

Segment 4 : Common Questions• Common Questions we get

Segment 5 : Blockchain Usage• Block chain usage across industries

Page 4: Demysitifying Bitcoin and Blockchain

Segment 1 : Currency Economics

Page 5: Demysitifying Bitcoin and Blockchain

Trading & Currency

• Medium of exchange started with grains to the $$ notes we have now• $$ / INR notes we have is physical money; Bitcoins are the converse – is non-physical digital

money• Physical money is governed by central entities – like our RBI in India; Treasury Department in

USA• Money in flow ≠ Country’s gold deposits [ Nixon took this out in 1971 post Vietnam war]• Physical money < Money in circulation

• Financial institution that holds the central ledger for its customers & Enable transfer of money

• Trusted by the customers• Provides loans and there by creating more

money• Money spent outside of the banks (cash) are

untraceable to a large extent• Transaction honoring is based on the time a

check is presented to the bank

Banks100 100

John1000 – 100 = 900 (balance)

Joe100 + 100 = 200 (balance)

BANK

Central body owning the ledger and the transactions

Page 6: Demysitifying Bitcoin and Blockchain

Currency Economics – Money Creation• Money creation is two ways –

• Fractional Reserve banking that relies on Credit Reserve Ratio

• Treasury/RBI/Central Bank created money

• FRR- Fractional Reserve Banking• Customers deposit money • Banks can loan to 90% at the max (ie.

CRR – is 10%)• Banks loan and make money out of

what they get

T  =  A*(1 – R)1 + A*(1 – R)2 + A*(1 – R)3 + …A = 1000R = 10% (reserve ratio)T = Total amount

1000 INR 100 INR

900 INR

900 INR

810 INR

90 INR

810 INR

729 INR

810 INR

10,000 INR in circulation

Bank Liability Kept Loaned Total Assets

Bank 1 1000 100 900 900Bank 2 900 90 810 810Bank 3 810 81 729 729.. ..Bank N 0 0 0 0Total 10000 1000 9000 10000

Page 7: Demysitifying Bitcoin and Blockchain

Treasury created Money

Treasury Bonds

Creates/sells

Government

Buys

Money [already exists] used to buy these bonds / treasury bills

Federal Reserve (US)

RBI (in India)

Buys Bonds

Buys Bonds

Large banks – like Chinese central bank

Prints Rupee

Prints $$

Money creation is based on pure debt. We are running on a debt based system

Page 8: Demysitifying Bitcoin and Blockchain

Currency Economics – Key Takeaways

• Money is created via debt instruments ; two ways money is created • Via banks giving out loans – there by extending the original money• By RBI / US Fed, who create money (from nothing) for a bond /t-bill issued by the Govt

• So bitcoin created by “miners” is not something that is radically different than what happens in our economy today

• PAPER MONEY HAS NO INTRINSIC VALUE – so called FIAT money; depends on expectation & social convention

• Few key points to note: • Country's money flow is not equated to GOLD deposits anymore

• Ex: USD $$ was equated to a portion of GOLD till Nixon in 1971 (post Vietnam war) nullified it

• Now US Fed creates $$ for bonds (debt) issued by the US Treasury• Because of the above reason, US debt (post 1971) has skyrocketed to 21 trillion (and

above) now !!!

http://www.usdebtclock.org/current-rates.html

Page 9: Demysitifying Bitcoin and Blockchain

Segment 2: Bitcoin

Page 10: Demysitifying Bitcoin and Blockchain

Bitcoin

• Bitcoin is a digital asset (currency) – invented by Satoshi Nakamoto*• Launched in January 2009; https://bitcoin.org/bitcoin.pdf – white paper that originated bitcoin • Peer to peer payment system (like torrent)• Transactions are verified by the nodes in the bitcoin network (not by a bank)• Instead of a bank – the entire transactions are held across nodes; a public ledger called blockchain• Bitcoin is nothing more than a digital file that holds the accounts; transaction happen by updating this

file

Account Holder

Balance

John 10Bob 5Alice 6Dave 3… …

-5+5

Bitcoin network – each node having a copy of the ledger

Page 11: Demysitifying Bitcoin and Blockchain

11

Bitcoin – Transactions• Users are identified by large strings (address)• Private key is with the user• In below example – Alice signs the transaction

she creates (of sending 10 BTC to Bob) with her private key

• Nodes in the network verify that with her public key; on validation they confirm it

• Confirmed transactions are distributed across the nodes

• Bob can share his address• Via email Or Messaging • Or via pairing of phones

Digitally signed Trx

Bitcoin Node

Bitcoin Node

Bitcoin NodeTransaction digitally signed by Alice with her private keyAlice

Bob

Simplified Bitcoin network

Wallets• Software that helps manage the funds

(BTCs)• Hold the private keys (user can hold

many)• Helps you sign a transaction • Install wallet - https://

blockchain.info/wallet• Online wallet services :

• www.circle.com | www.coinbase.com …

Bitcoin Add / Private key

Bitcoin Balance

asdfas23524taasdasfWEFSDsdf..

12.31000

4454575kjhdhghfdsgSDFSDFq989..

0.23

Sadfa243525243q34d… 1.99Total Wallet Balance 14.53

Page 12: Demysitifying Bitcoin and Blockchain

Cryptography – Basics Symmetric key cryptography•One key is used to encrypt the message•Same key is used to decrypt the message, as it is received

Public key – Private key cryptography•Public key is used to lock the message•Private key is used to unlock the message // private key alone needs to be safe

•Public and Private key pairs are mathematically linkedDigital Signatures• Intent is similar to handwritten signature; ensure the message was

generated by the signerElliptic Curve Cryptography• Elliptic Curve Cryptography is used to generate the public / private

key pair in bitcoin • It ensures – finding a public key with a private key is easier; and the

converse is near impossible

Bitcoin address• Bitcoin addresses are hash of public key generated by the wallet

Page 13: Demysitifying Bitcoin and Blockchain

Bitcoin – Transactions cont.

• Ordering of payment is critical – in every mode of transaction

• New transactions created are put in a pending pool • Participating bitcoin nodes – will help in confirming**

the transaction • As transaction gets confirmed, it gets added to the

transaction chain

Bitcoin Mining• Nodes that help confirm the transaction, by contributing

their computational power – are granted with few bitcoins; this is the act of MINING (creating) new Bitcoins

• Such mining grant will end by 2140; post which only transaction fee can be paid as mining fee

Account Balance• All unspent transactions of a user is summed up to

determine the account balance of a user• Balance is calculated to approve a spending (like Alice sending 5 BTC to Bob)

SALT

Bitcoin Wallet

Alice BobFred Alice

John Alice

Output: 3.0 BTC

Output: 3.0 BTC

refers

refers5.0 BTC

Txn # 323

Txn # 412

Txn # 412Txn # 323

Inputs

Page 14: Demysitifying Bitcoin and Blockchain

Bitcoin cont.• Purchasing using bitcoins

• http://spendbitcoins.com/ - lists all places where you can use bitcoins and buy items• http://www.overstock.com/bitcoin - sells 2.3 Billion $ per year

• Bitcoin transaction cost – is by far the most cheapest than any other mode (Paypal, Master/Visa card – transaction fees)

• Unlike the current money creation, the inflation in case of bitcoin will be well contained • Bitcoins clients are available across – desktop, mobile.,

Bitcoin clients• Multibit – Desktop• Electrum – Desktop• Blockchain.info – Browser• Bitcoin wallet – mobile

client• …

Page 15: Demysitifying Bitcoin and Blockchain

Alternates

• There are many variations of bitcoins out there in the market. Some of them are • Litecoin

• Introduced in 2011• has 5% marketshare of bitcoin; does transactions faster; relies on memory intensive

computation• Peercoin

• Introduced in 2012• Namecoin• Auroracoin• Primecoin• Dogecoin

• Bitcoin source can be forked to create a modified coin• Marketcap of various coins as of Q2 2014

• Litcoin – 325 million• Peercoin – 52 million • Namecoin – 20 million • …

• Bitcoins present market cap – 7 billion (as of Apr 2016)

Page 16: Demysitifying Bitcoin and Blockchain

Segment 3 : Blockchain

Page 17: Demysitifying Bitcoin and Blockchain

Some basics – before the ‘Blockchain’• Cryptographic Hash function

• Takes an arbitrary length of input and outputs a fixed length output• Even a small variation in input (like a space added to the input) drastically changes the output• One way-ness : computationally infeasible to find the input value from the hash value• Strong collision resistance : Given an input, it is almost computationally infeasible** to find another input

that will create the same hash value• Uses SHA 256^2 – using SHA256 hashing twice

** - means that there is no known algorithm that can figure out the input supplied. Only option in such a case is the brute force of guessing; in case of SHA 256, such a guess takes an exponential (impractical) amount of time.

How are you

How are you?

9c7d5b046878838da72e40ceb3179580958df544b240869b80d0275cc0

7209cc

df287dfc1406ed2b692e1c2c783bb5cec97eac53151ee1d9810397aa0af

a0d89

SHA256 hashing

Note: Output hash value is significantly different for a single character addition (?) in the input string

INPUT TEXT HASH OUTPUT

Page 18: Demysitifying Bitcoin and Blockchain

BlockchainKey Facets• Most important innovation by bitcoin• Missing link that makes the whole peer to peer digital

currency feasible• Holds all bitcoin transactions starting Jan 3, 2009

[ distributed transaction database ]

What is it?• Transactions are grouped into blocks – called the block

chain• Transactions are grouped based on time; • Each block points to the previous block• Keeps the entire transactions secure• Each block contains *new* confirmed transactions• Each block has a link to the previous block (single parent)• Old transactions / Old Blocks are never removed; block

chain keeps growing• Blocks – can be created by anyone• Bitcoin generation algorithm is immutable

Hash of prev block

Trx 1Trx 2Trx 3

Nonce

BLOCK

Nonce helps solve the partial hash inversion problem

Block #1 Block # 2 Block # 310 min

10 min

Parent Block of Block # 3

Genesis Block

First ever blockCreated on Jan 3,2009 BLOCK HEIGHT

Last BlockBlockchain head

Page 19: Demysitifying Bitcoin and Blockchain

Blockchain cont. – Proof of Work SystemProof of Work• Blockchain is a proof-of-work system [PoW]• Captcha is a simplistic PoW system, where it is making the end user do work before it authenticates

f( prev block reference + entire block text + random guess ) < target

Partial hash inversion – proof of work

Block Creation• Each node in the bitcoin network takes a list of PENDING transactions & will try creating a block• Ordering of blocks happens via solving a puzzle• Puzzle is to find the ‘random_guess’ (number) which when supplied to the hashing function gets a hash that is less than

the target set for that block

• Random guess ensures no two nodes cannot compute (identify) a subsequent block at the same time• 10 minutes to solve the problem with so many computers guessing it• Hacker has to outpace entire list of participating nodes to ensure he/she wins, which is improbable

[wiki]

Page 20: Demysitifying Bitcoin and Blockchain

Blockchain - Details• Block Difficulty

• 271,076 block mined on Nov 23, 2013 had 61 zero bits • Such a target is coded into every bitcoin client. This is to ensure, it takes the computational power to

compute / solve the puzzle in 10 minutes or so• Block target is set at a global level• With every 2016 block mined, the block difficulty gets incremented• This is to ensure, it takes a higher computational power (considering tons of nodes in the network) to solve

the puzzle and add a block to the chain• Persons who are contributing their computation power – are called MINERS

Hash of prev block

Coinbase

Nonce

BLOCK

Trx InTrx In

Trx Out

Trx NTrx InTrx In

Trx Out

Trx N-1Trx InTrx In

Trx Out

• Coinbase• First transaction in a block is called coinbase• Coinbase transactions have no input but all outputs• All outputs combined denotes the block reward

• Mining Reward• 50 bitcoins per block• Every 210k blocks (or every 4 years) block reward is halved• Now its 25 bitcoins for every block (partial hash inversion) being

solved

Page 21: Demysitifying Bitcoin and Blockchain

Blockchain – Dispute Resolution• Fork

• When two miners mine a block at the same time, we will get a fork

• Orphan• Only one can be in the chain – the other is called

Orphan• Orphan gets back to the pending pool

• Fork / Dispute Resolution• Protocol automatically selects the longest running

branch that has the highest difficulty

Blockchain head New block

New block

Unconfirmed transaction pool

Moved to transaction pool

Block # 6

Block # 5

Block # 7 Block # 7

Block # 8

Block Height

Time progression

Orphaned transactions that has already got into any confirmed blocks are discarded

AMERICA EU - RUSSIA

APAC / AUS

T1

T2

T3

T3

T4

# 5

# 6

# 7

# 7

# 8

Page 22: Demysitifying Bitcoin and Blockchain

• End of chain insecurity – opens up the possibility of Alice the hacker to spend her BTC twice – once to the real seller and one back to her (refund)

Last confirmed block

Trx to you the seller

Alice new fork

Alice second block

Contains the transaction paying her back

Step Description Result

1 Alice pays Bob to buy a bookOrange block above gets created with that transaction

Bob’s system ships the item

2 Alice with her computing power creates another block at the same time; in that she refunds the money (used to pay Bob)

Alice gets back the money

3 Alice creates another block on top of her block; Orange block with Bobs transaction is cancelled and that transaction gets back to the pending pool

Double Spend Attack

Page 23: Demysitifying Bitcoin and Blockchain

Double Spend Attack cont.• For Alice to create two blocks before anyone else needs CPU power more than most of the nodes in

the network• Even if she has the CPU power of more than half the nodes – it just gives her 0.5 probability

Last confirmed block

Trx to you the sellerAlice Bob

Alice created block [to create the fork]

Alice Alice

Alice created block [to create the fork]Some transactions

PENDING POOLTrx to you the seller

Alice BobWhen a block miner tries to create a block with this transaction, it will not go through

Alice created block [to create the fork]Some transactions

Page 24: Demysitifying Bitcoin and Blockchain

Miners’ – tries f( #23A, trx1, trx2, .. Random # 1) = x > targetf( #23A, trx1, trx2, .. Random # 2) = x > targetf( #23A, trx1, trx2, .. Random # 3) = x > targetf( #23A, trx1, trx2, .. Random # 4) = x < target

Double Spend Attack – Defense • Finding the nonce (random guess) is CPU

intensive; brute force; cannot be done faster

Replacement of an older block is impossible• Blocks hash value is the fingerprint of that

block• There is no way to change the block (insert or

replace a block at a later time)

Hash value of this block. Even a small change in the blocks’ content will result in a completely different value

348EF348EF5436UI

ROGUE BLOCK

5436UI

Page 25: Demysitifying Bitcoin and Blockchain

25

Common Questions

Page 26: Demysitifying Bitcoin and Blockchain

1) How a 10 minute transaction confirmation be accepted• Sampling a set of miners and accepting a transaction is what the bitcoin industry is moving towards; which

are in seconds compared to the 10 minutes of block creation• Credit card systems has a 90 day reversal possibility; whereas it is just an hour for bitcoin• Propagation vs. confirmation time

• In ~10 seconds the transaction reaches 99% miners; if the transaction used is(are) double spent, you will get a rejection. If you have not, accept the transaction

• Multi-Sig-transaction is another solution, where you pay a thirdparty, where you (as the buyer) and the seller have a relationship with (similar to visa/mastercard model but with a very less transaction fee)

2) What are the advantages of using bitcoin• Freedom – from bank holidays to bureaucracy • Secure than any other form of payment• Transparent – once it is in blockchain; there is no worry of data loss

3) What are the disadvantages of using bitcoin • Acceptance • Volatility – from 1 BTC worth 1 USD to 1200 USD to 420 USD (now)• Still under development • 1MB limit & possibility of confirmation time getting higher (some reported 43 minutes once)

Common Questions

Please refer https://bitcoin.org/en/faq

Page 27: Demysitifying Bitcoin and Blockchain

27

Usage

Page 28: Demysitifying Bitcoin and Blockchain

Blockchain Usage• Healthcare

• Electronic health records in blockchain• Digitally secure• Encrypted and stored• Payers sending personal medical suggestions to members, which they can (only) open with their

private keys• Bitcoin payments

• Direct use-case• Anti counterfiet

• Each drug gets a unique key which is then verified at the time of distribution by comparing it against the key stored in blockchain, which cannot be tampered

• Other Arenas• Private / Public equities/ Bonds / Derivatives• Mortgage / Trading / Transaction Records• Public records - passports, vehicle information, license information, birth/death certs, voter IDs, patents• Voter information• Contracts and escrows across• Ownership records – of painting, music, escrows to antiques that can be verified

Page 29: Demysitifying Bitcoin and Blockchain

29

Thank You !!!

Feel free to send me questions; will try to respond to the best of my knowledge

[email protected]

Page 30: Demysitifying Bitcoin and Blockchain

30

Appendix

Page 31: Demysitifying Bitcoin and Blockchain

31

Reference• Currency

• https://www.rbi.org.in/currency/FAqs.html• https://www.youtube.com/watch?v=KuIFz7Qzryg

• Books• Understanding bitcoin - http://goo.gl/rUp4BY

• Wiki • https://en.wikipedia.org/wiki/Indian_rupee• https://en.wikipedia.org/wiki/Money_creation

• Money Creation• https://www.youtube.com/watch?v=qIxhsF6JLEA• http://positivemoney.org/how-money-works/how-banks-create-money/• http://blog.karthiksankar.com/moneycreation/

• Bitcoin videos• https://www.youtube.com/watch?v=ArMq6sXp0ek• https://www.youtube.com/watch?v=Lx9zgZCMqXE

• RBI / T-bills• http://

articles.economictimes.indiatimes.com/2016-02-04/news/70343823_1_open-market-operation-omo-government-bonds

• http://www.gktoday.in/blog/key-facts-about-treasury-bills-in-india/• http://

articles.economictimes.indiatimes.com/2016-03-18/news/71630794_1_lakh-crore-borrowing-calendar-market-borrowing

• Preimage Resistant• http://www.denimgroup.com/know_artic_secure_hash_functions.html• http://hashcash.org/

Page 32: Demysitifying Bitcoin and Blockchain

32

Reference cont.• Blockchain – Dispute Resolution

• http://orm-chimera-prod.s3.amazonaws.com/1234000001802/images/msbt_0806.png• Bitcoin difficulty

• https://en.bitcoin.it/wiki/Difficulty• Bitcoin wiki

• https://en.bitcoin.it/wiki/Main_Page• Blockchain & Cognizant

• http://investors.cognizant.com/2016-02-16-Mizuho-Financial-Group-Partners-with-Cognizant-to-Develop-a-Blockchain-Solution-for-Secure-Record-Keeping-and-Improved-Customer-Experience

• Blockcypher – 10min – barrier • https://blog.blockcypher.com/we-broke-the-10-minute-bitcoin-confirmation-barrier-a9d53a505b05#

.8iax89a6i