Foundations of Blockchain

Book Description

Learn the foundations of blockchain technology - its core concepts and algorithmic solutions across cryptography, peer-to-peer technology, and game theory.

Key Features

  • Learn the core concepts and foundations of the blockchain and cryptocurrencies
  • Understand the protocols and algorithms behind decentralized applications
  • Master how to architect, build, and optimize blockchain applications

Book Description

Blockchain technology is a combination of three popular concepts: cryptography, peer-to-peer networking, and game theory. This book is for anyone who wants to dive into blockchain from first principles and learn how decentralized applications and cryptocurrencies really work.

This book begins with an overview of blockchain technology, including key definitions, its purposes and characteristics, so you can assess the full potential of blockchain. All essential aspects of cryptography are then presented, as the backbone of blockchain. For readers who want to study the underlying algorithms of blockchain, you'll see Python implementations throughout.

You'll then learn how blockchain architecture can create decentralized applications. You'll see how blockchain achieves decentralization through peer-to-peer networking, and how a simple blockchain can be built in a P2P network. You'll learn how these elements can implement a cryptocurrency such as Bitcoin, and the wider applications of blockchain work through smart contracts. Blockchain optimization techniques, and blockchain security strategies are then presented. To complete this foundation, we consider blockchain applications in the financial and non-financial sectors, and also analyze the future of blockchain. A study of blockchain use cases includes supply chains, payment systems, crowdfunding, and DAOs, which rounds out your foundation in blockchain technology.

What you will learn

  • The core concepts and technical foundations of blockchain
  • The algorithmic principles and solutions that make up blockchain and cryptocurrencies
  • Blockchain cryptography explained in detail
  • How to realize blockchain projects with hands-on Python code
  • How to architect the blockchain and blockchain applications
  • Decentralized application development with MultiChain, NEO, and Ethereum
  • Optimizing and enhancing blockchain performance and security
  • Classical blockchain use cases and how to implement them

Who this book is for

This book is for anyone who wants to dive into blockchain technology from first principles and build a foundational knowledge of blockchain. Familiarity with Python will be helpful if you want to follow how the blockchain protocols are implemented. For readers who are blockchain application developers, most of the applications used in this book can be executed on any platform.

Publisher Resources

Download Example Code

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Foundations of Blockchain
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Introduction
    1. What blockchain is
    2. What blockchain isn't
    3. Blockchain definitions
    4. How are blockchains different from databases?
    5. History of blockchain
      1. Blockchain 2.0
    6. The motivations behind blockchain
    7. Characteristics of blockchain
    8. Background of DLT
    9. The different types of blockchain
      1. Public blockchain (permissionless)
      2. Private blockchain (permissioned)
      3. Consortium blockchain
    10. Overview of blocks
      1. Block attributes
      2. Structure of the block
      3. Block header
      4. Linking blocks
    11. Influence of Moore's law on blockchain technology
    12. Summary
  7. A Bit of Cryptography
    1. Cryptography in blockchain
    2. Classical cryptography
    3. Cryptographic primitives
    4. Symmetric key cryptography
      1. Stream cipher
      2. Block cipher
        1. Data Encryption Standard
        2. Advanced Encryption Standard
          1. An example implementation of AES
    5. Asymmetric key cryptography
      1. Prime factorization
      2. Discrete logarithm
      3. Elliptic-curve
      4. RSA cryptosystem
        1. RSA parameter generation
        2. Encryption and decryption using RSA
        3. An example implementation of RSA
      5. Elliptic-curve cryptography
        1. Operations on elliptic curves
          1. Point addition
          2. Point doubling
        2. Computing the public key
        3. Technical details of secp256k1
      6. Digital signatures
        1. How does it work?
          1. Signing process
          2. Verification process
        2. Elliptical Curve Digital Signature Algorithm (ECDSA)
        3. ECDSA example to create and verify a digital signature
    6. Cryptographic hashing
      1. Hashing algorithms
        1. Message Digest
        2. Secure Hash Algorithms (SHA)
        3. Hashing example using an SHA-256 algorithm
      2. Merkle hash trees
    7. Encoding schemes
    8. Summary
  8. Cryptography in Blockchain
    1. Hashing in blockchain
      1. Linking blocks in a blockchain
      2. Linking blocks using an SHA256 hashing algorithm
        1. Block structure
        2. Blockchain functionality
        3. Creating a blockchain
      3. Byzantine failure problem in blockchain
        1. How does Proof of Work ensure Byzantine fault tolerance?
        2. How does Proof of Work use cryptography?
        3. An example implementation of Proof of Work
          1. Example of finding a nonce to solve Proof of Work
    2. Digital signatures in blockchain
      1. Creating an identity
      2. Signatures in transaction
      3. Asset ownership in blockchain
        1. Transferring an asset
        2. Transmitting the transaction
        3. Claiming the asset
      4. Blockchain wallets
    3. Summary
  9. Networking in Blockchain
    1. Peer-to-peer (P2P) networking
      1. History of P2P network
      2. P2P networking architecture
    2. Network discovery
    3. Block synchronization
    4. Building a simple blockchain in a P2P network
      1. Validating a new block
      2. Selecting the longest chain
        1. Conflict resolution
      3. Block exchange between peers
        1. Initial block synchronization
        2. Broadcasting scenarios
      4. Application interfaces
      5. Diving into the code
        1. The server interface
        2. Block and blockchain interface
        3. Running the blockchain nodes
    5. Summary
  10. Cryptocurrency
    1. Bitcoin basics
      1. Getting started with Bitcoin Core
        1. Setting up a Bitcoin full node
          1. Installing a Bitcoin full node
          2. Compiling from source code
        2. Running the Bitcoin node
        3. Communicating with the Bitcoin node
        4. Communicating using scripting language through the JSON-RPC implementation
    2. Keys and addresses
      1. Public and private keys
      2. Bitcoin public addresses
    3. Transactions
      1. Transactions at a high level
      2. Transaction input and output
      3. Transaction output
      4. Transaction input
      5. Transaction verification
        1. Script
          1. Script example
        2. Locking and unlocking scripts
          1. Types of transaction script
    4. Mining and consensus
      1. Mining a block
        1. Verification of transactions
        2. Aggregating transactions into a block
          1. Coinbase transactions
        3. Mining a block using the Proof of Work algorithm
      2. Mining pool
    5. Blockchain
      1. Block structure
        1. Block header
      2. The genesis block
      3. Merkle trees
    6. Blockchain networks
      1. Testnet
      2. Regtest
    7. Bitcoin hard forks and altcoins
    8. A simple cryptocurrency application
      1. Transactions
        1. Transaction output
        2. Transaction input
        3. Transaction structure
        4. UTXO
        5. Transaction validation
        6. Transaction signing
      2. Wallet
        1. Key management
        2. Wallet balance
        3. Creating transactions
          1. Consuming UTXOs
          2. Constructing a transaction
      3. Transaction management
        1. Transaction pool
        2. Broadcasting
      4. Blockchain
      5. Application endpoints
    9. Summary
  11. Diving into Blockchain - Proof of Existence
    1. MultiChain blockchain platform
      1. Why choose MultiChain?
      2. The basics of MultiChain
      3. MultiChain functionalities
        1. Permission management
        2. Asset management
        3. Stream management
    2. Setting up a blockchain environment
      1. Running MultiChain nodes
    3. Getting started with MultiChain
      1. Creating a chain
      2. Connecting to an existing chain
      3. Checking the blockchain
      4. Working with streams
    4. Proof of Existence architecture
      1. Publishing the document
      2. Verifying the document
    5. Building the Proof of Existence application
      1. MultiChain JSON-RPC driver
      2. Proof of Existence library
      3. Proof of Existence web server
        1. Publishing the document
        2. Verifying the document
      4. Executing and deploying the application
    6. Summary
  12. Diving into Blockchain - Proof of Ownership
    1. Digital assets and identity
    2. Proof of ownership
    3. Smart contracts
    4. Choosing the smart contract platform
    5. NEO blockchain
      1. Building blocks of a NEO blockchain
      2. NEO technology
        1. Consensus algorithm
        2. NEO smart contract
        3. Additional NEO projects
      3. NEO nodes
        1. Getting started
          1. Setting up a full node
          2. Setting up a neo-python environment
          3. Setting up a JSON-RPC interface for the node
      4. NEO network
        1. Test network
        2. Private network
      5. NEO transactions
        1. Transferring an asset
      6. Creating a decentralized application
        1. Basic smart contract
        2. Proof of ownership application
          1. Creating the smart contract
          2. Executing the smart contract
          3. Interface for the application
    6. Ethereum blockchain
      1. Ethereum nodes
      2. Getting started
        1. Setting up a node
        2. Setting up a development environment
      3. Creating a decentralized application
        1. Basic smart contract
        2. Proof of ownership application
          1. Creating the smart contract
          2. Executing the smart contract
          3. Interface for the application
    7. Summary
  13. Blockchain Projects
    1. Categorizing the blockchain projects
      1. Financial projects
      2. Non-financial projects
    2. Financial blockchain projects
      1. Cryptocurrencies
        1. Traceable cryptocurrencies
        2. Untraceable cryptocurrencies
          1. Zcash
      2. Crypto tokens
        1. Coin offerings
      3. Ripple payment network
        1. Ripple use cases
          1. Cross-border payments
          2. Ripple tokens as a currency bridge
        2. Ripple network
          1. Ripple consensus algorithm
          2. Ripple token (XRP)
      4. Cryptocurrency exchanges
        1. Decentralized exchanges
          1. Kyber Network
    3. Non-financial blockchain projects
      1. Asset management
        1. Factom
          1. Design
          2. Factom products
      2. Social media platforms
        1. Steem
          1. Voting model in Steem
          2. Steem tokens
          3. Consensus in Steem
      3. Digital identity
        1. ShoCard Identity Management
          1. ShoCard architecture
      4. Blockchain in the Internet of Things (IoT)
        1. IOTA
          1. Design
          2. IOTA in IoT
      5. Data storage
        1. Filecoin
          1. IPFS
          2. Filecoin consensus
          3. Filecoin's decentralized storage network (DSN)
          4. Filecoin markets
        2. BigchainDB
          1. Features of BigchainDB
          2. The life cycle of BigchainDB transactions
          3. Use cases
      6. Distributed computing
        1. Golem
          1. Golem ecosystem
      7. Blockchain platforms
        1. Ethereum
          1. Ethereum token
          2. EVM
          3. Blockchain consensus
          4. DApp development
          5. Ethereum network
    4. Links for the projects
    5. Summary
  14. Blockchain Optimizations and Enhancements
    1. Blockchain optimizations
      1. Transaction exchange
        1. Blockchain relay networks
        2. Invertible bloom lookup tables
      2. Off-chain transactions
        1. Off-chain state channels
          1. The Lightning Network
          2. Routed payment network
        2. Sidechains
      3. Block size improvements
        1. Motivations to increase the block size
        2. Concerns on increasing the block size
        3. Proposed solutions
    2. Blockchain enhancements
      1. Sharding
        1. The motivation for database sharding
        2. Sharding in blockchain
          1. Components in a shard
          2. Design of a sharded blockchain
          3. Cross-shard communication
      2. Evolution of the consensus algorithm
        1. Proof of Stake (PoS)
        2. Proof of Activity (PoA)
        3. Byzantine Fault Tolerance (BFT) consensus models
          1. Practical Byzantine Fault Tolerance (PBFT)
          2. Federated Byzantine Fault Tolerance (FBFT)
        4. Proof of Elapsed Time (PoET)
      3. Cross-chain protocol
        1. Interledger protocol (ILP)
          1. Interledger components
          2. Design of Interledger
      4. Privacy enhancement
        1. Zero-knowledge proof
          1. General examples
        2. zk-SNARKs
        3. Zcash transactions
        4. Private transactions
    3. Summary
  15. Blockchain Security
    1. Transaction security model
      1. Risks of the security model
    2. Decentralized security model
      1. Centralization due to cryptocurrency exchanges
        1. Mt. Gox
        2. Bitfinex
        3. Coinrail
      2. Centralization in mining pools
    3. Attacks on the blockchain
      1. Double-spend attacks
        1. Double-spending in Bitcoin transactions
          1. Creating the first transaction
          2. Creating the transaction to double-spend
      2. 51% attack
        1. Implications of the attack
        2. Avoiding the attack
      3. Eclipse attacks
        1. Eclipsing the node
        2. Implications and analysis of the attack
        3. Vulnerabilities and countermeasures
    4. Threats of quantum computing
    5. Summary
  16. When Shouldn't We Use Blockchain?
    1. Distributed databases versus distributed ledger technology (DLT)
      1. Decentralized control of information
      2. Confidentiality of information
      3. Robustness
      4. Performance
    2. What can we store on a blockchain?
      1. Storing data as transactions
      2. Storing minimal data
      3. Storing data that requires minimal changes
    3. Centralized versus decentralized application architecture
    4. Properties of blockchain
      1. Immutability
      2. Non-repudiation
      3. Security
      4. Redundancy
      5. Reduced cost
      6. Transparency
    5. Decision models for blockchain
      1. Karl Wüst and Arthur Gervais
      2. Birch-Brown-Parulava model
      3. Framework to evaluate the suitability of blockchain
      4. Generalized decision model
    6. Summary
  17. Blockchain Use Cases
    1. Tracking provenance in the supply chain
      1. Pain points in a supply chain
      2. Blockchain as a solution
      3. Blockchain implementation of the supply chain
    2. Financial system
      1. Pain points in the payment system
      2. Blockchain as a solution
      3. Blockchain implementations of a payment system
        1. Ripple
        2. Stellar
    3. Crowdfunding
      1. Pain points in crowdfunding
      2. Blockchain as a solution
      3. Blockchain implementation of crowdfunding using an ICO
    4. Non-profit autonomous organizations
      1. Pain points in non-profit autonomous organizations
      2. Blockchain as a solution
      3. Blockchain implementation of a non-profit DAO
    5. Summary
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product Information

  • Title: Foundations of Blockchain
  • Author(s): Koshik Raj
  • Release date: January 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789139396