Advanced Blockchain Development

Book description

Explore distributed ledger technology, decentralization, and smart contracts, and develop real-time decentralized applications with Ethereum and Solidity

Key Features

  • Get to grips with the underlying technical principles and implementations of blockchain
  • Build powerful applications using Ethereum to secure transactions and create smart contracts
  • Gain advanced insights into cryptography and cryptocurrencies

Book Description

Blockchain technology is a distributed ledger with applications in industries such as finance, government, and media. This Learning Path is your guide to building blockchain networks using Ethereum, JavaScript, and Solidity.

You will get started by understanding the technical foundations of blockchain technology, including distributed systems, cryptography and how this digital ledger keeps data secure. Further into the chapters, you’ll gain insights into developing applications using Ethereum and Hyperledger. As you build on your knowledge of Ether security, mining, smart contracts, and Solidity, you’ll learn how to create robust and secure applications that run exactly as programmed without being affected by fraud, censorship, or third-party interference. Toward the concluding chapters, you’ll explore how blockchain solutions can be implemented in applications such as IoT apps, in addition to its use in currencies. This Learning Path also highlights how you can increase blockchain scalability, and discusses the future scope of this fascinating and powerful technology.

By the end of this Learning Path, you'll be equipped with the skills you need to tackle pain points encountered in the blockchain life cycle and confidently design and deploy decentralized applications.

What you will learn

  • Understand why decentralized applications are important
  • Discover the mechanisms behind bitcoin and alternative cryptocurrencies
  • Master how cryptography is used to secure data with the help of examples
  • Maintain, monitor, and manage your blockchain solutions
  • Create Ethereum wallets
  • Explore research topics and the future scope of blockchain technology

Who this book is for

This Learning Path is designed for blockchain developers who want to build decentralized applications and smart contracts from scratch using Hyperledger. Basic familiarity with any programming language will be useful to get started with this Learning Path.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Advanced Blockchain Development
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the authors
    2. 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 of this book
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Blockchain 101
    1. The growth of blockchain technology
    2. Distributed systems
    3. The history of blockchain and Bitcoin
      1. Electronic cash
      2. Blockchain
        1. Blockchain defined
          1. Peer-to-peer
          2. Distributed ledger
          3. Cryptographically-secure
          4. Append-only
          5. Updateable via consensus
      3. Generic elements of a blockchain
        1. How blockchain works
        2. How blockchain accumulates blocks
      4. Benefits and limitations of blockchain
      5. Tiers of blockchain technology
      6. Features of a blockchain
    4. Types of blockchain
      1. Distributed ledgers
      2. Distributed Ledger Technology
      3. Public blockchains
      4. Private blockchains
        1. Semiprivate blockchains
        2. Sidechains
        3. Permissioned ledger
      5. Shared ledger
      6. Fully private and proprietary blockchains
      7. Tokenized blockchains
      8. Tokenless blockchains
    5. Consensus
      1. Consensus mechanism
      2. Types of consensus mechanisms
      3. Consensus in blockchain
    6. CAP theorem and blockchain
    7. Summary
  7. Decentralization
    1. Decentralization using blockchain
    2. Methods of decentralization
      1. Disintermediation
      2. Contest-driven decentralization
    3. Routes to decentralization
      1. How to decentralize
      2. The decentralization framework example
    4. Blockchain and full ecosystem decentralization
      1. Storage
      2. Communication
      3. Computing power and decentralization
    5. Smart contracts
    6. Decentralized Organizations
      1. Decentralized Autonomous Organizations
      2. Decentralized Autonomous Corporations
      3. Decentralized Autonomous Societies
      4. Decentralized Applications (DApps)
      5. Requirements of a Decentralized Application
      6. Operations of a DApp
        1. DApp examples
          1. KYC-Chain
          2. OpenBazaar
          3. Lazooz
    7. Platforms for decentralization
      1. Ethereum
      2. MaidSafe
      3. Lisk
    8. Summary
  8. Understanding How Ethereum Works
    1. Overview of Ethereum
    2. Ethereum accounts
    3. Transactions
    4. Consensus
    5. Timestamp
    6. Nonce
    7. Block time
    8. Forking
    9. Genesis block
    10. Ether denominations
    11. Ethereum virtual machine
    12. Gas
    13. Peer discovery
    14. Whisper and Swarm
    15. Geth
      1. Installing geth
        1. OS X
        2. Ubuntu
        3. Windows
      2. JSON-RPC and JavaScript console
      3. Sub-commands and options
        1. Connecting to the mainnet network
        2. Creating a private network
      4. Creating accounts
        1. Mining
        2. Fast synchronization
    16. Ethereum Wallet
    17. Mist
    18. Weaknesses
      1. Sybil attack
      2. 51% attack
    19. Serenity
      1. Payment and state channels
      2. Proof-of-stake and casper
      3. Sharding
    20. Summary
  9. Smart Contracts
    1. History
    2. Definition
    3. Ricardian contracts
      1. Smart contract templates
      2. Oracles
      3. Smart Oracles
      4. Deploying smart contracts on a blockchain
      5. The DAO
    4. Summary
  10. Symmetric Cryptography
    1. Working with the OpenSSL command line
    2. Introduction
      1. Mathematics
        1. Set
        2. Group
        3. Field
        4. A finite field
        5. Order
        6. An abelian group
        7. Prime fields
        8. Ring
        9. A cyclic group
        10. Modular arithmetic
      2. Cryptography
      3. Confidentiality
      4. Integrity
      5. Authentication
        1. Entity authentication
        2. Data origin authentication
      6. Non-repudiation
      7. Accountability
    3. Cryptographic primitives
      1. Symmetric cryptography
        1. Stream ciphers
        2. Block ciphers
          1. Block encryption mode
          2. Electronic Code Book
          3. Cipher Block Chaining
          4. Counter mode
          5. Keystream generation mode
          6. Message authentication mode
          7. Cryptographic hash mode
      2. Data Encryption Standard
      3. Advanced Encryption Standard
        1. How AES works
    4. Summary
  11. Public Key Cryptography
    1. Asymmetric cryptography
      1. Integer factorization
      2. Discrete logarithm
      3. Elliptic curves
    2. Public and private keys
      1. RSA
        1. Encryption and decryption using RSA
        2. Elliptic Curve Cryptography
          1. Mathematics behind ECC
          2. Point addition
          3. Point doubling
      2. Discrete logarithm problem in ECC
        1. RSA using OpenSSL
        2. RSA public and private key pair
          1. Private key
          2. Public key
          3. Exploring the public key
        3. Encryption and decryption
          1. Encryption
          2. Decryption
        4. ECC using OpenSSL
          1. ECC private and public key pair
          2. Private key
          3. Private key generation
      3. Hash functions
        1. Compression of arbitrary messages into fixed-length digest
        2. Easy to compute
        3. Preimage resistance
        4. Second preimage resistance
        5. Collision resistance
        6. Message Digest
        7. Secure Hash Algorithms
          1. Design of Secure Hash Algorithms
          2. Design of SHA-256
          3. Design of SHA-3 (Keccak)
          4. OpenSSL example of hash functions
          5. Message Authentication Codes
          6. MACs using block ciphers
          7. Hash-based MACs
        8. Merkle trees
        9. Patricia trees
        10. Distributed Hash Tables
        11. Digital signatures
      4. RSA digital signature algorithm
        1. Sign then encrypt
        2. Encrypt then sign
      5. Elliptic Curve Digital Signature Algorithm
        1. How to generate a digital signature using OpenSSL
        2. ECDSA using OpenSSL
        3. Homomorphic encryption
        4. Signcryption
        5. Zero-Knowledge Proofs
        6. Blind signatures
        7. Encoding schemes
    3. Financial markets and trading
      1. Trading
      2. Exchanges
        1. Orders and order properties
        2. Order management and routing systems
        3. Components of a trade
        4. The underlying instrument
        5. General attributes
        6. Economics
        7. Sales
        8. Counterparty
      3. Trade life cycle
      4. Order anticipators
      5. Market manipulation
    4. Summary
  12. Getting Started with web3.js
    1. Introduction to web3.js
      1. Importing web3.js
      2. Connecting to nodes
      3. The API structure
      4. BigNumber.js
      5. Unit conversion
      6. Retrieving gas price, balance, and transaction details
      7. Sending ether
      8. Working with contracts
      9. Retrieving and listening to contract events
    2. Building a client for an ownership contract
      1. The project structure
      2. Building the backend
      3. Building the frontend
      4. Testing the client
    3. Summary
  13. Introducing Bitcoin
    1. Bitcoin
      1. Bitcoin definition
      2. Bitcoin – a bird's-eye view
        1. Sending a payment to someone
    2. Digital keys and addresses
      1. Private keys in Bitcoin
      2. Public keys in Bitcoin
      3. Addresses in Bitcoin
        1. Base58Check encoding
        2. Vanity addresses
          1. Multisignature addresses
    3. Transactions
      1. The transaction life cycle
        1. Transaction fee
        2. Transaction pools
      2. The transaction data structure
        1. Metadata
        2. Inputs
        3. Outputs
        4. Verification
        5. The script language
        6. Commonly used opcodes
      3. Types of transactions
        1. Coinbase transactions
        2. Contracts
      4. Transaction verification
        1. Transaction malleability
    4. Blockchain
      1. The structure of a block
      2. The structure of a block header
      3. The genesis block
    5. Mining
      1. Tasks of the miners
      2. Mining rewards
      3. Proof of Work (PoW)
      4. The mining algorithm
      5. The hash rate
      6. Mining systems
        1. CPU
        2. GPU
        3. FPGA
        4. ASICs
      7. Mining pools
    6. Summary
  14. Building a Wallet Service
    1. Difference between online and offline wallets
    2. hooked-web3-provider and ethereumjs-tx libraries
    3. What is a hierarchical deterministic wallet?
    4. Introduction to key derivation functions
    5. Introduction to LightWallet
      1. HD derivation path
    6. Building a wallet service
      1. Prerequisites
      2. Project structure
      3. Building the backend
      4. Building the frontend
      5. Testing
    7. Summary
  15. Alternative Coins
    1. Theoretical foundations
      1. Alternatives to Proof of Work
        1. Proof of Storage
        2. Proof of Stake (PoS)
      2. Various stake types
        1. Proof of coinage
        2. Proof of Deposit (PoD)
        3. Proof of Burn
        4. Proof of Activity (PoA)
        5. Nonoutsourceable puzzles
      3. Difficulty adjustment and retargeting algorithms
        1. Kimoto Gravity Well
        2. Dark Gravity Wave
        3. DigiShield
        4. MIDAS
    2. Bitcoin limitations
      1. Privacy and anonymity
        1. Mixing protocols
        2. Third-party mixing protocols
        3. Inherent anonymity
      2. Extended protocols on top of Bitcoin
        1. Colored coins
        2. Counterparty
      3. Development of altcoins
        1. Consensus algorithms
        2. Hashing algorithms
        3. Difficulty adjustment algorithms
        4. Inter-block time
        5. Block rewards
        6. Reward halving rate
        7. Block size and transaction size
        8. Interest rate
        9. Coinage
        10. Total supply of coins
    3. Namecoin
      1. Trading Namecoins
      2. Obtaining Namecoins
      3. Generating Namecoin records
    4. Litecoin
    5. Primecoin
      1. Trading Primecoin
      2. Mining guide
    6. Zcash
      1. Trading Zcash
      2. Mining guide
        1. Address generation
        2. GPU mining
          1. Downloading and compiling nheqminer
      3. Initial Coin Offerings (ICOs)
      4. ERC20 tokens
    7. Summary
  16. Development Tools and Frameworks
    1. Languages
      1. Compilers
        1. Solidity compiler (solc)
          1. Installation on Linux
          2. Installation on macOS
        2. Integrated Development Environments (IDEs)
          1. Remix
        3. Tools and libraries
          1. Node version 7
          2. EthereumJS
        4. Ganache
        5. MetaMask
        6. Truffle
          1. Installation
        7. Contract development and deployment
          1. Writing
          2. Testing
    2. Solidity language
      1. Types
        1. Value types
          1. Boolean
          2. Integers
          3. Address
        2. Literals
          1. Integer literals
          2. String literals
          3. Hexadecimal literals
        3. Enums
        4. Function types
          1. Internal functions
          2. External functions
        5. Reference types
          1. Arrays
          2. Structs
          3. Data location
          4. Mappings
        6. Global variables
        7. Control structures
          1. Events 
          2. Inheritance
          3. Libraries
          4. Functions
        8. Layout of a Solidity source code file
          1. Version pragma
          2. Import
          3. Comments
    3. Summary
  17. Building a Betting App
    1. Introduction to Oraclize
      1. How does it work?
      2. Data sources
      3. Proof of authenticity
      4. Pricing
      5. Getting started with the Oraclize API
        1. Setting the proof type and storage location
        2. Sending queries
        3. Scheduling queries
        4. Custom gas
        5. Callback functions
        6. Parsing helpers
        7. Getting the query price
      6. Encrypting queries
        1. Decrypting the data source
      7. Oraclize web IDE
    2. Working with strings
    3. Building the betting contract
    4. Building a client for the betting contract
      1. Projecting the structure
      2. Building the backend
      3. Building the frontend
      4. Testing the client
    5. Summary
  18. Hyperledger
    1. Projects under Hyperledger
      1. Fabric
      2. Sawtooth Lake
      3. Iroha
      4. Burrow
      5. Indy
      6. Explorer
      7. Cello
      8. Composer
      9. Quilt
    2. Hyperledger as a protocol
    3. The reference architecture
      1. Requirements and design goals of Hyperledger Fabric
        1. The modular approach
        2. Privacy and confidentiality
        3. Scalability
        4. Deterministic transactions
        5. Identity
        6. Auditability
        7. Interoperability
        8. Portability
        9. Rich data queries
    4. Fabric
      1. Hyperledger Fabric
        1. Membership services
        2. Blockchain services
        3. Consensus services
        4. Distributed ledger
          1. The peer to peer protocol
          2. Ledger storage
          3. Chaincode services
          4. Components of the fabric
          5. Peers
          6. Orderer nodes
          7. Clients
          8. Channels
          9. World state database
          10. Transactions
          11. Membership Service Provider (MSP)
          12. Smart contracts
          13. Crypto service provider
          14. Applications on blockchain
          15. Chaincode implementation
          16. The application model
          17. Consensus in Hyperledger Fabric
          18. The transaction life cycle in Hyperledger Fabric
      2. Sawtooth Lake
        1. PoET
        2. Transaction families
        3. Consensus in Sawtooth
        4. The development environment – Sawtooth Lake
      3. Corda
        1. Architecture
          1. State objects
          2. Transactions
          3. Consensus
          4. Flows
        2. Components
          1. Nodes
          2. The permissioning service
          3. Network map service
          4. Notary service
          5. Oracle service
          6. Transactions
          7. Vaults
          8. CorDapp
        3. The development environment – Corda
    5. Summary
  19. Alternative Blockchains
    1. Blockchains
      1. Kadena
      2. Ripple
        1. Transactions
          1. Payments related
          2. Order related
          3. Account and security-related
        2. Interledger
          1. Application layer
          2. Transport layer
          3. Interledger layer
          4. Ledger layer
      3. Stellar
      4. Rootstock
        1. Sidechain
        2. Drivechain
      5. Quorum
        1. Transaction manager
        2. Crypto Enclave
        3. QuorumChain
        4. Network manager
      6. Tezos
      7. Storj
      8. MaidSafe
      9. BigchainDB
      10. MultiChain
      11. Tendermint
        1. Tendermint Core
        2. Tendermint Socket Protocol (TMSP)
    2. Platforms and frameworks
      1. Eris
    3. Summary
  20. Blockchain - Outside of Currencies
    1. Internet of Things
      1. Physical object layer
      2. Device layer
      3. Network layer
      4. Management layer
      5. Application layer
      6. IoT blockchain experiment
        1. First node setup
        2. Raspberry Pi node setup
          1. Installing Node.js
        3. Circuit
      7. Government
        1. Border control
        2. Voting
        3. Citizen identification (ID cards)
        4. Miscellaneous
      8. Health
      9. Finance
        1. Insurance
        2. Post-trade settlement
        3. Financial crime prevention
      10. Media
    2. Summary
  21. Scalability and Other Challenges
    1. Scalability
      1. Network plane
      2. Consensus plane
      3. Storage plane
      4. View plane
      5. Block size increase
      6. Block interval reduction
      7. Invertible Bloom Lookup Tables
      8. Sharding
      9. State channels
      10. Private blockchain
      11. Proof of Stake
      12. Sidechains
        1. Subchains
        2. Tree chains (trees)
        3. Block propagation
        4. Bitcoin-NG
        5. Plasma
    2. Privacy
      1. Indistinguishability Obfuscation
      2. Homomorphic encryption
      3. Zero-Knowledge Proofs
      4. State channels
      5. Secure multiparty computation
      6. Usage of hardware to provide confidentiality
      7. CoinJoin
      8. Confidential transactions
      9. MimbleWimble
      10. Security
        1. Smart contract security
          1. Formal verification and analysis
          2. Oyente tool
    3. Summary
  22. Building a Consortium Blockchain
    1. What is a consortium blockchain?
    2. What is Proof-of-Authority consensus?
    3. Introduction to parity
      1. Understanding how Aura works
      2. Getting parity running
        1. Installing rust
          1. Linux
          2. OS X
          3. Windows
        2. Downloading, installing and running parity
      3. Creating a private network
        1. Creating accounts
        2. Creating a specification file
        3. Launching nodes
        4. Connecting nodes
      4. Permissioning and privacy
    4. Summary
  23. Current Landscape and What's Next
    1. Emerging trends
      1. Application-specific blockchains (ASBCs)
      2. Enterprise-grade blockchains
      3. Private blockchains
      4. Start-ups
      5. Strong research interest
      6. Standardization
      7. Enhancements
      8. Real-world implementations
      9. Consortia
      10. Answers to technical challenges
      11. Convergence
      12. Education of blockchain technology
      13. Employment
      14. Cryptoeconomics
      15. Research in cryptography
      16. New programming languages
      17. Hardware research and development
      18. Research in formal methods and security
      19. Alternatives to blockchains
      20. Interoperability efforts
      21. Blockchain as a Service
      22. Efforts to reduce electricity consumption
    2. Other challenges
      1. Regulation
      2. Dark side
    3. Blockchain research
      1. Smart contracts
      2. Centralization issues
      3. Limitations in cryptographic functions
      4. Consensus algorithms
      5. Scalability
      6. Code obfuscation
    4. Notable projects
      1. Zcash on Ethereum
      2. CollCo
      3. Cello
      4. Qtum
      5. Bitcoin-NG
      6. Solidus
      7. Hawk
      8. Town-Crier
      9. SETLCoin
      10. TEEChan
      11. Falcon
      12. Bletchley
      13. Casper
    5. Miscellaneous tools
      1. Solidity extension for Microsoft Visual Studio
      2. MetaMask
      3. Stratis
      4. Embark
      5. DAPPLE
      6. Meteor
      7. uPort
      8. INFURA
    6. Convergence with other industries
    7. Future
    8. Summary
  24. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Advanced Blockchain Development
  • Author(s): Imran Bashir, Narayan Prusty
  • Release date: May 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781838823191