Bitcoin Internal

1,492 views

Published on

Bitcoin internal (transaction, block, mining, proof-of-work, ...)

Published in: Technology
1 Comment
6 Likes
Statistics
Notes
No Downloads
Views
Total views
1,492
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
1
Likes
6
Embeds 0
No embeds

No notes for slide
  • IntroFiat & Digital Currency:List some currency nowadaysDescribe simple online payment> disadvantage and how bitcoin solve itBitcoin internalGo from user view to technical viewHow bitcoin workTheory it based on
  • 3 Functions of money:Medium of exchange – money is used to intermediate the exchange of goods and services, thusly avoiding the problems connected with barter system Unit of account – money is used as a unit of market value of goods and services Store of value – money can be stored and spent in a later point of time reliably fiat currency:Inflation
  • How it worksStep1: User go to the ecommerce site (eg: tiki.vn), choose books.Step2: User input card info, go to payment site.Bank validate the transaction and update account value-> It has some problems. See next slides
  • It involves a trusted third party and implies some cost. transaction fails but $ gone away -> it take time & cost to process.It store all information & transaction histories. Easy tracingCompletely non-reversible transactions Eg: risk for tiki when the transaction is reversible
  • How to solve them with bitcoinIn November 2008, a paper was posted on the internet under the name Satoshi Nakamoto titled Bitcoin: A Peer-to-Peer Electronic Cash System. This paper detailed methods of using a peer-to-peer network to generate what was described as "a system for electronic transactions without relying on trust“In January 2009, the Bitcoin network came into existence with the release of the first open source Bitcoin client and the issuance of the first bitcoins,[9][12][13][14] with Satoshi Nakamoto mining the first block of bitcoins ever (known as the "genesis block"), which had a reward of 50 bitcoins.Source code: https://github.com/bitcoin/bitcoin - public from 2010What Characteristic of Bitcoin[No]On 6 August 2010, a major vulnerability in the Bitcoin protocol was spotted. Transactions weren't properly verified before they were included in the transaction log or "block chain" which let users bypass Bitcoin's economic restrictions and create an indefinite number of bitcoins.[15][16] On 15 August, the vulnerability was exploited; over 184 billion bitcoins were generated in a transaction, and sent to two addresses on the network. Within hours, the transaction was spotted and erased from the transaction log after the bug was fixed and the network forked to an updated version of the Bitcoin protocol.[17][18] This was the only major security flaw found and exploited in Bitcoin's history
  • Commodity: like goldEmission is programmed: every 10 min. 50 coins are created. It number decrease twice every 4 years.theory: cryptographic how to verify transaction, mining…You can see the characteristic clearly when go deep in bitcoiniternal
  • Safe usage require basic knowledge
  • First one, you need a account for receive or send bitcoin to others. It is address in bitcoin view.Address: - No personal info - create online or offline - can use temporaryClient like website bank for perform operationStandard client: peer 2 peerIn cryptography, the Elliptic Curve Digital Signature Algorithm (ECDSA) offers a variant of the Digital Signature Algorithm (DSA) which uses elliptic curve cryptography.Pool – A Pool is a website that allows Miners to collaborate together in creating new Blocks. How to create Bitcoin Address https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses0 - Having a private ECDSA key 18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725 1 - Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate) 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 2 - Perform SHA-256 hashing on the public key 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408 3 - Perform RIPEMD-160 hashing on the result of SHA-256 010966776006953D5567439E5E39F86A0D273BEE 4 - Add version byte in front of RIPEMD-160 hash (0x00 for Main Network) 00010966776006953D5567439E5E39F86A0D273BEE 5 - Perform SHA-256 hash on the extended RIPEMD-160 result 445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094 6 - Perform SHA-256 hash on the result of the previous SHA-256 hash D61967F63C7DD183914A4AE452C9F6AD5D462CE3D277798075B107615C1A8A30 7 - Take the first 4 bytes of the second SHA-256 hash. This is the address checksum D61967F6 8 - Add the 4 checksum bytes from stage 7 at the end of extended RIPEMD-160 hash from stage 4. This is the 25-byte binary Bitcoin Address. 00010966776006953D5567439E5E39F86A0D273BEED61967F6 9 - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the most commonly used Bitcoin Address format 16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
  • \
  • How bitcoin define coin (eg: 1 bitcoin)Coin = list of transaction. It store history usage of the coins. Transactions: A transaction is a record of where is money coming from, where it is going and how much is being transferred. Ex: 1. System send to A 50 BTCs2. A send 50BTCs to B3. B send 50BCs to CThe transactions chain is public. Everyone know it.Given a transaction chain, how to know who ownership?Base on last transaction in chain. given by digital signature of transaction by last ownerEveryone has public key of owner, every know owner of specific bitcoinsWho can send the coin?Only owner have suitable private key to sign and send to othersOutput of transaction chainit is chain in user view. It computer, it has fix length.
  • A transaction has many input or output.Input: previous transactionWhy it has many input?Eg: A has 20 coins. Because coins is in bitcoin is transaction chain.(Note: It does not means that a bit coin is a transaction chain. Transaction chain has a variable indicate coin amount.)A has 2 transaction chains. 15 and 5. So if A want to spend 17coins?-> 2 inputs make sense.Why it has many output?Above example, How to receive back 3 coins? In bitcoin, It do add one output as address of owner.
  • Imagine that: if transaction exists solo. Who sure owner don’t use a transaction chain to spend many times for many products?The problem of course is the payee can't verify that one of the owners did not double-spendthe coin. A common solution is to introduce a trusted central authority, or mint, that checks everytransaction for double spending.
  • Bitcoin solution:It will build a public transaction log that called block chain. All transactions in the block chain are all valid. Everyone want to validate a transaction valid or not, double spending or not. They only check it has pre-transaction comes from the block chain.How to implement? Build a block chain - publicGiven a existent chainCollect info: new transaction, … to build a new block, add into the chainVery difficult to build a similar chain?SolutionIt will base on crypt theory make very difficult to build a block chain has same length. It take a lot of effort of computers.-> every one build it.Difficult -> base on proof-of-work
  • Bitcoin solution:It will build a public transaction log that called block chain. All transactions in the block chain are all valid. Everyone want to validate a transaction valid or not, double spending or not. They only check it has pretransaction comes from the block chain.How to implement?Build a chain and everyone know it.Very difficult to build a similar chain?SolutionIt will base on crypt theory make very difficult to build a block chain has same length. It take a lot of effort of computers.
  • To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof-of-work systemA proof of work is a piece of data which was difficult (costly, time-consuming) to produce so as to satisfy certain requirements.The work is try and tryOnce the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the workSteps:Init none = 0Calculate block header hashCompare to TargetSmaller -> Send to networkNot, try to increase none
  • To implement a distributed timestamp server on a peer-to-peer basis, we will need to use a proof-of-work systemA proof of work is a piece of data which was difficult (costly, time-consuming) to produce so as to satisfy certain requirements.The average work required is exponential in the number of zero bits required and can be verified by executing a single hash.Once the CPU effort has been expended to make it satisfy the proof-of-work, the block cannot be changed without redoing the work
  • If network accept, the miner get awardsIf no, another one aldready build new block first, no award. Re-mining with new transactions.Target: The target is a 256-bit number (extremely large) that all Bitcoin clients sharedifficulty = difficulty_1_target / current_targetHow often does the network difficulty change?Every 2016 blocks. At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to findCurrent target: 15 leading zeros0000000000000001A36E00000000000000000000000000000000000000000000
  • Why need Merkle Root tree?The idea (as I understand it) is that the Merkle tree allows for you to verify transactions as needed and not include the body of every transaction in the block header, while still providing a way that the entire blockchain (and therefore proof of work) on every transaction.See http://bitcoin.stackexchange.com/questions/10479/what-is-the-merkle-root
  • Bitcoin Internal

    1. 1. Bitcoin Internal Lưu Tuấn Cường
    2. 2. Agenda 1. Fiat and Digital Currency 2. Bitcoin Internals  Transaction  Block Chain  Mining & Proof-of-work 3. Future Research Bitcoin 2
    3. 3. Fiat Currency   The currency we use today is at fiat currency: its value is entirely determined by government policy and law. It is not a commodity (like gold). Any amount of money could be created without limits. Bitcoin 3 functions of money:  Medium of exchange  Unit of account  Store of value 3
    4. 4. Digital Currency  Digital Currency: Digital currency is a form of money or script that is only executed electronically. Typically, this involves the use of computer networks, the Internet and digital stored value systems.  Electronic funds transfer, direct deposit, digital gold currency and virtual currency are all examples of electronic money. Bitcoin 4
    5. 5. Online Payment Bitcoin 5
    6. 6. Online Payment Problems:  It involves a trusted third party and implies some cost.  Not Anonymous.  Completely non-reversible transactions are not really possible. More risks for merchants. Bitcoin 6
    7. 7. Bitcoin Bitcoin is the name of the project started by Satoshi Nakamoto to create the world’s first decentralized digital crypto-currency in 2009.  Digital: it is just a record of transactions (a ledger).  Decentralized: the ledger is public; validation of the ledger is made by a peer-to-peer network. Bitcoin is the name of a single unit of the Bitcoin currency (BTC). 1 BTC = 100.000.000 Satoshis. Bitcoin 7
    8. 8. Characteristic of Bitcoin      Commodity: Hard limit of about 21 million BTCs Based on cryptographic proof instead of trust Non-reversible transactions Transactions are cheap, and mostly free Anonymous Bitcoin 8
    9. 9. Characteristic of Bitcoin - - - Degree of acceptance: Many people are still unaware of Bitcoin Ongoing development: Bitcoin software is still in beta with many in complete features in active development Take time to verify transactions. Require basic knowledge when use bitcoin. Bitcoin 9
    10. 10. Some terms (1) Address (account): 160-bit hash of the public portion of a public/private ECDSA key pair Ex: 31uEbMgunupShBVTewXjtqbBv5MndwfXhb  Wallet: Bitcoin addresses (the public keys) and their associated private keys are stored in the wallet data file  Client: an application used by the users to perform operations on the Bitcoin Network.  Standard Client: an application developed by the original developers working on the Bitcoin project. It sets the standards of how Clients should work and communicate with each other.  Bitcoin 10
    11. 11. Some terms (2)  Miner: A Miner is a computer machine and accompanying application dedicated to creating new Blocks. Bitcoin 11
    12. 12. Transaction Satoshi Nakamato, 1998: “We define a digital coin as a chain of digital signatures" A coin is defined by the list of its transactions.  Proof of ownership is given by digital signature of transaction by last owner  Bitcoin 12
    13. 13. Transaction hash: 9c809ffd57fe160b7a5504f0ff9ec2beb3f491fd3eb88d548d56399b7b8bd4db inputs (1): amount: 100 from (address): 1PgMst4c11hPpuYQeqRPTCjMv9Z8CmLus4 scriptSig: 30450221008044adfa98b5bd83f2ec0852e8c5aa7b5e226924b475b . . . outputs (1): amount: 100 to (address): 16MgZaATWXrAgDB3Q9evULCHATWrmbxmUt scriptPubKey: . . . 3ac1f8f5cb7ab8ed6d2d5dc1d295ec3e1d00dbd6 . . . Bitcoin 13
    14. 14. Transaction - Problem Double-Spending: The payee can't verify that one of the owners did not double-spend Bitcoin 14
    15. 15. Timestamp Server A timestamp server takes a hash of a block of items to be timestamped and widely publishing the hash. The timestamp proves that the data must have existed at the time in order to get into the hash. Each timestamp includes the previous timestamp in its hash, forming a chain , with each additional timestamp reinforcing the ones before it. Bitcoin 15
    16. 16. Timestamp Server Bitcoin 16
    17. 17. Proof-of-work Bitcoin miners find a random number (called a "Nonce") that when inserted into the current block makes the hash (SHA-256)2 be below the current target. The average work required is exponential in the number of zero bits required and can be verified by executing a single hash Bitcoin 17
    18. 18. Proof-of-work Example Hash of the last block (shortened to 30 characters): 00000000000001adf44c7d69767585 Hash of a few valid transactions waiting for inclusion (shortened): 5572eca4dd4 Db7d0c0b845 One special transaction - mining award: 916d849af76 Target: 001ae0000000000000000000000000 Bitcoin (2 leading zeros) 18
    19. 19. Proof-of-work Example Nonce = 0 Block Hash: 8b9b994dcf57f8f90194d82e234b72ac -> No luck! No leading zeros?  Nonce = 1 Block Hash : 5b7ce5bcc07a2822f227fcae7792fd90 -> No luck! No leading zeros? …..  Nonce = 1000: Block Hash : 0005e55df5758517c9bed0981b52ce4a -> Ok  Send the block to the Bitcoin network. Bitcoin 19
    20. 20. Block Bitcoin 20
    21. 21. Bitcoin Mining 1. 2. Block Award Transaction fee Bitcoin 21
    22. 22. Network The steps to run the network are as follows: 1) New transactions are broadcast to all nodes. 2) Each node collects new transactions into a block. 3) Each node works on finding a difficult proof-of-work for its block. 4) When a node finds a proof-of-work, it broadcasts the block to all nodes. 5) Nodes accept the block only if all transactions in it are valid and not already spent. 6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash. Bitcoin 22
    23. 23. Future Research Security Issues:  Anonymity  Non-Professional Programming  Wallet Is Vulnerable  Wallet-Thief Countermeasure  Sybil Attack  DoS Attack Bitcoin 23
    24. 24. Thank you Bitcoin 24

    ×