Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Blockchain: from 0 to 1

Blockchain: from 0 to 1

Ulugbek Miniyarov

March 01, 2018
Tweet

More Decks by Ulugbek Miniyarov

Other Decks in Technology

Transcript

  1. Agenda • A Brief • High level overview • Under

    the Hood ◦ Hash ◦ Proof-of-Work ◦ Block & Chain ◦ Transaction Inputs & Outputs ◦ Coinbase Transaction & Transaction fee • Demo • Private / Public Keys • Bitcoin Address • Demo • Smart Contracts & Tokens • Possibility of Banning • Use Cases • Advanced Topics
  2. A Brief about Blockchain • Essentially Blockchain is a distributed

    database of records • Serving as a ledger, Blockchain records are public & anyone can navigate through records • Main purpose of chaining blocks is to protect against double-spending & keep immutability of records • Each new block is added with a consent of all nodes on the network • After reaching consensus new coins are introduced to the network
  3. High level overview of Blockchain • This numbers does not

    represent anything in the physical world • They only have value since people trade with real goods & believe others will do too
  4. • While blockchain as a ledger resembles Bank ledger, it

    differ in operating. Rather than a single entity it is operated by group of nodes • Unlike Banks, in Blockchain anyone knows about anyone’s transactions
  5. • Banks can be held responsible for accounts • In

    Blockchain everyone is anonymous, so no trust is possible
  6. Hashing Key features of hashing: • Original data cannot be

    restored from a hash. Thus, hashing is not encryption. • Certain data can have only one hash and the hash is unique. • Changing even one byte in the input data will result in a completely different hash. • Bitcoin blockchain uses SHA-256 hashing algorithm • Main purpose of hashing is to check the consistency of blocks
  7. How big is 2 ^ 256? • A 2^256 is

    roughly equals to 10^76 • It is estimated that there are about 10^78 to 10^82 atoms in the observable universe
  8. Proof-of-Work Bitcoin uses Hashcash, a Proof-of-Work algorithm that was initially

    developed to prevent email spam. It can be split into the following steps: 1. Take some publicly known data (in case of email, it’s receiver’s email address; in case of Bitcoin, it’s block headers). 2. Add a counter to it. The counter starts at 0. 3. Get a hash of the data + counter combination. 4. Check that the hash meets certain requirements. 4.1. If it does, you’re done. 4.2. If it doesn’t, increase the counter and repeat the steps 3 and 4.
  9. Block & Chain Purpose of blocking & chaining: • Keep

    the ledger immutable • Prevent double-spending • Generate new coins (rewards) Notes: • Reward value is calculated based on the total number of blocks • Genesis Block Reward is 50 BTC • Every 210000 blocks reward amount is halved • Longest chain is considered the valid chain, orphaning the other chains with less blocks • Proof-of-Work target is calibrated according to network hashrate every 2016 blocks (~ 2 weeks)
  10. Transaction Inputs & Outputs Notice that: • There are outputs

    that are not linked to inputs. • In one transaction, inputs can reference outputs from multiple transactions. • An input must reference an output. • Transactions are indivisible meaning you should spend all amount or create a change transaction before spending your coins
  11. Transaction Inputs & Outputs Output schema: • Value (In Bitcoin

    value is stored as satoshis. 1 BTC = 100 000 000 satoshis). • ScriptPubKey (Address of Receiver) Input schema: • RefTxn (Referenced Output’s Transaction) • OutputId (Referenced Output’s Index Id in Transaction) • ScriptSig (Signature of Output’s Address Owner)
  12. UTXO (Unspent Transaction Output) • To locate unspent outputs Bitcoin

    implements UTXO index • UTXO is indexed once you join Bitcoin Network (Currently it takes about 24 hours to index) Mempool • Mempool is used to store transactions that are not yet in Blockchain
  13. Coinbase Transaction • Special transaction (Reward to Miner) • Creates

    new coins • Cannot be spent for at least 100 blocks (~16 hours) • No previous output thus input’s ScriptSig has arbitrary data
  14. Genesis Block & Coinbase Transaction In fact the very first

    coinbase created by Satoshi Nakamoto has arbitrary data of: ◦ The Times 03/Jan/2009 Chancellor on brink of second bailout for banks ◦ This is the headline of The Times published on that date Auto-generated by Satoshi Nakamoto to be the reference for next block. The glitch in bitcoin’s core does not allow coinbase to be spent
  15. Private / Public Keys (Public-Key Cryptography) • PK Cryptography uses

    pair of keys: Public & Private Keys • As names suggest Public Key can be given to anyone but Private Key should be kept only by the owner • Private Key generates Signature for a given data/message • Public Key is used to verify if the data/message is really signed by Private Key • PK Cryptography can also be used for data encryption but bitcoin blockchain does not use PKC for that purpose
  16. Bitcoin Address • Bitcoin uses Elliptic Curve Cryptography to generate

    Public / Private Keys and Elliptic Curve Digital Signature Algorithm to sign transactions • Since PK Keys are random sequences of numbers between 0 & 2^256, generated keys is not human-readable • To make it human-readable Satoshi Nakamoto used Base 58 (Modified version of Base64 i.e. 0 and O might be confusing)
  17. Smart Contracts & Token - ScriptPubKey & ScriptSig parameters in

    transaction I/O’s give possibility to write decentralized protocol to support Smart Contracts - With the help of Smart Contracts, it is possible to anyone create contacts with include Tokens for ICO
  18. Possibility of Banning Banning of Blockchains are still possible since

    Blockchain network uses DNS to connect to other nodes. But it can be easily bypassed using VPN.
  19. Use Cases of Blockchain other than Cryptocurrencies Identity: Securing against

    counterfeiting Identity Cards, Badges is costly. Instead open blockchains can be used as an identity verifier. Notary: Blockchain immutable transactions/records can be integrated in Notary uses Digital Assets: ICO Smart Contracts
  20. Advanced Topics on Blockchains - Mining (ASIC, FPGA, GPU/CPU, ASIC-Resistant,

    Post-Quantum Safe) - Mining Pools - Orphan Block / Hardfork / Softfork - 51% Attack - Blockchain Explorer (Blockchain.info) - Hashrate compared to fastest super computers - Hashrate calibration in every 2016 block
  21. Advanced Topics on Blockchains - Peer-to-Peer Network - Node Roles

    (Miner, Fullnode, SPV) - DNS Seeds - SVP & Merkle Tree - Bitcoin Script - Multi-sig Addresses - Block Limit
  22. Advanced Topics on Blockchains - Segwit - Segwit2x (Cancelled) -

    Proof-of-Stake - Lightning Network & Payment Channels