MasteringBlockchainSecondEdition code

965 496 0
MasteringBlockchainSecondEdition code

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Mastering Blockchain Second Edition Distributed ledger technology, decentralization, and smart contracts explained Imran Bashir BIRMINGHAM - MUMBAI Mastering Blockchain Second Edition Copyright © 2018 Packt Publishing All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information Acquisition Editors: Ben Renow-Clarke, Suresh M Jain Project Editor: Suzanne Coutinho Content Development Editor: Alex Sorrentino Technical Editor: Bhagyashree Rai Indexer: Tejal Daruwale Soni Graphics: Tom Scaria Production Coordinator: Aparna Bhagat First published: M arch 2017 Second edition: M arch 2018 Production reference: 1290318 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78883-904-4 www.packtpub.com mapt.io Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career For more information, please visit our website Why subscribe? Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals Improve your learning with Skill Plans built especially for you Get a free eBook or video every month Mapt is fully searchable Copy and paste, print, and bookmark content PacktPub.com Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@packtpub.com for more details At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks Contributors About the author Imran Bashir has an M.Sc in Information Security from Royal Holloway, University of London, and has a background in software development, solution architecture, infrastructure management, and IT service management He is also a member of the Institute of Electrical and Electronics Engineers (IEEE) and the British Computer Society (BCS) Imran has sixteen years' of experience in the public and financial sectors He worked on large scale IT projects in the public sector before moving to the financial services industry Since then, he has worked in various technical roles for different financial companies in Europe's financial capital, London He is currently working for an investment bank in London as Vice President in the Technology department I would like to thank the talented team at Packt, including Ben Renow-Clarke, Suzanne Coutinho, Alex Sorrentino, Gary Schwartz, and Bhagyashree Rai, who provided prompt guidance and valuable feedback throughout this project I am also extremely thankful to the reviewer, Pranav Burnwal, who provided constructive and very useful feedback that helped me tremendously to improve the material in this book I thank my wife and children for putting up with my all-night and weekend-long writing sessions Above all, I would like to thank my parents, whose blessings have made everything possible for me Miscellaneous tools Some tools that have not been discussed previously are listed in the following subsections and introduced briefly to make readers aware of the myriad of development options available for blockchains This list includes platforms, utilities, and tools that can be used for blockchain development Solidity extension for Microsoft Visual Studio This extension provides IntelliSense, autocompletion, and templates for DApps, and works within the familiar Visual Studio IDE, making it easier for developers to familiarize themselves with Ethereum development You can download this extension from: https://marketplace.visualstudio.com/items?itemName=ConsenSys.Solidity MetaMask This is a DApp browser that is similar to Mist from a DApp browsing point of view but allows users to run Ethereum DApps within the browser without the requirement of running a full Ethereum node This is available from https://metamask.io/ and can be installed as a Chrome plugin Stratis This is a blockchain development platform that allows the creation of custom private blockchains and works in conjunction with the main Stratis blockchain (Stratis chain) for security reasons It allows provisioning of major blockchains such as Bitcoin, Ethereum, and Lisk easy Also, it allows development using C# NET technologies It is also available via Microsoft Azure as BaaS This is available at https://stratisplatform.com/ Embark This is a development framework for Ethereum which allows similar functionality to Truffle, which is discussed in Chapter 14, Introducing Web3 It allows automatic deployment of smart contracts, easier integration with JavaScript, and, especially, easier integration with IPFS This is a very feature-rich framework, and many more functionalities are available It can be installed via npm This framework is available at GitHub: https://github.com/iurimatias/embark-framework DAPPLE This is another framework for Ethereum that allows easier development and deployment of smart contracts by taking care of more complex tasks It can be used for package management, contract building, and deployment scripting This is also available via npm It is also available via GitHub at https://github.com/nexusdev/dapple Meteor This is a full-stack development framework for single-page applications It can be used for Ethereum DApp development There is a development environment available in meteor, and it allows easier and easy development of complex DApps It is available at https://www.meteor.com/ and Ethereum-specific DApp building information is available at m/ethereum/wiki/wiki/Dapp-using-Meteor https://github.co uPort This platform is built on Ethereum and provides a decentralized identity management system This allows users to have full control over their identity and personal information This is based on the idea of reputation systems enables users to attest each other and build trust This is available at https://www.uport.me/ INFURA This project aims to provide enterprise-level Ethereum and IPFS nodes INFURA consists of Ethereum nodes, IPFS nodes, and a service layer named Ferryman which provides routing and load balancing services Convergence with other industries Convergence of blockchain with IoT has been discussed at length in Chapter 18, Scalability and Other Challenges Briefly, it can be said that due to the authenticity, integrity, privacy, and shared nature of blockchains, IoT networks will benefit greatly from blockchain technology This can be realized in the form of an IoT network that runs on a blockchain and makes use of a decentralized mesh network for communication to facilitate Machine-to-Machine (M2M) communication in real time All this data which is generated as a result of M2M communication can be used in the machine learning process to augment the functionality of Artificially Intelligent DAOs or simple AAs AAs can act as agents in a Distributed Artificial Intelligence (DAI) environment provided by a blockchain and can learn over time using machine learning processes AI is a field of computer science that endeavors to build intelligent agents that can make rational decisions based on the scenarios and environment that they observe around them Machine learning plays a vital role in AI by making use of raw data as a learning resource A key requirement in AIbased systems is the availability of authentic data that can be used for machine learning and model building The explosion of data coming out IoT devices, smartphone's, and other data acquisition means that AI and machine learning is becoming more and more powerful There is, however, a requirement of authenticity of data Once consumers, producers, and other entities are on a blockchain, the data that is generated as a result of interaction between these entities can be readily used as an input to machine learning engines with a guarantee of authenticity This is where AI converges with blockchains It could be argued that if an IoT device is hacked, it can send malformed data to the blockchain This issue is mitigated because an IoT device is part of the blockchain (as a node) and has all security properties applied to it as a standard node in the blockchain network These properties include incentivization of good behavior, rejection of malformed transactions, and strict verification of transactions and various other checks that are part of blockchain protocol Therefore, even if an IoT device is somehow hacked, it would be treated as a Byzantine node by the blockchain network and would not cause any adverse impact on the network Moreover, the possibility of combining intelligent Oracles, intelligent, smart contracts, and AAs will give rise to Artificially Intelligent Decentralized Autonomous Organizations (AIDAOs) that can act on behalf of humans to run entire organizations on their own This is another side of AI that can become norm in the future However, more research is required to realize this vision Also, convergence of blockchain technology with other fields such as 3D printing, virtual reality, augmented reality, and the gaming industry is also envisaged For example, in a multiplayer online game, blockchain's decentralized approach allows for more transparency and can ensure that no central authority is gaining unfair advantage by manipulating the game rules All these topics are active areas of research currently and more interest and development are expected in these areas soon Future The year 2017 was predicted to be the year when blockchain technology is implemented in realworld production environments and move from the Proof of Concept (PoC) and theoretical stage of previous years It is true to some extent that companies have implemented some pilot projects but large-scale production implementations are yet to be seen It is expected that within year 2018 we will see some organization implementing full scale blockchain based projects In 2019, it is expected that almost 20% of central banks will be using blockchain Original research is available here https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3040224 In years to come, this trend is only expected to grow There are few careful predictions being made in the section that is based on the current advancement and speed of progress in the concerned field All of these predictions are likely to come true between the years 2020 and 2050: The IoT will run on multiple blockchains and will give rise to an M2M economy This can include energy devices, autonomous cars, and house hold accessories Medical records will be shared securely while preserving the privacy of patients between various private blockchains run by consortia of health providers It may well be a single private blockchain shared among all service providers including pharmacies, hospitals, and clinics Elections will be held via decentralized web applications with a backend of blockchains transparently and securely Financial institutions will be running many private blockchains to share data between participants and for internal processes Financial institutions will be making use of semiprivate blockchains that will provide identity information for AML and KYC functions and will be shared between many or all of the financial institutions around the world Immigration and border control related activities will be recorded on the blockchain and passport control will be conducted via a blockchain shared between all ports of entries and border agencies around the world Governments will run interdepartmental blockchain to provide government services such as pension disbursement, benefit disbursement, land ownership records, birth registrations and other citizen services This way auditability, trust and sense of security will develop among citizens Research in cryptography and distributed systems will reach new heights and universities, and educational establishment will offer dedicated courses on cryptoeconomics, cryptocurrencies, and blockchains Artificially Intelligent DAOs will prevail on blockchains that will make rational decisions on behalf of humans A publicly available regulated blockchain run by the government will be used on day-to-day basis by citizens to perform their day-to-day activities, for example tax payments, TV license registration and marriage registrations BaaS will be provided as standard to anyone who wishes to run their business or day-to-day transactions on a blockchain In fact, it could be envisaged that just like the Internet, blockchains will seamlessly integrate into our daily lives and people will be using them without knowing much about the underlying technology and infrastructure Blockchains will normally be used to provide Digital Rights Management (DRM) services for arts and media and can be used to deliver content to the consumers, enabling direct communication between consumer and the producer This will eliminate the need for any central party to govern the licensing and rights managing of valuable goods Existing cryptocurrencies such as Bitcoin will continue to grow in value, and with the availability of state channels and scalability efforts, this trend is only expected to grow Cryptocurrency investment will greatly increase, and a new cryptoeconomic society will emerge Bitcoin value will reach tens of thousands of dollars per coin Digital identities will be routinely managed on the blockchain, and different government functions such as voting, taxation, and funds disbursement will be conducted via blockchainenabled platforms Financial institutions and clearing houses will start to introduce blockchain-based solutions for their customers in 2018 Summary Blockchains are going to change the world The revolution has already started, and it is only expected to grow at an exponential scale This chapter has explored various projects and the current state of blockchain technology First, a few trends were discussed that are expected to continue as the technology progresses further There is deep research interest in blockchain technology by many researchers and organizations around the world, and some research topics have also been introduced in this chapter Furthermore, convergence with other fields such as the IoT and AI has also been discussed Finally, some predictions regarding the growth of blockchain technology have been made Most of these predictions are likely to come true within the next decade or so, while some may take a longer time Blockchain technology has the potential to change the world, and a few positive signs have already been seen in the form of successful PoC implementations and a growing number of enthusiasts and developers taking an interest in this technology Very soon, blockchains will be intertwined with our lives just as the Internet is now This chapter is just a modest overview of the vast and tremendous potential of blockchains, and in the near future, exponential growth and further adoption of this technology is expected Another Book You May Enjoy If you enjoyed this book, you may be interested in another book by Packt: Building Blockchain Projects Narayan Prusty ISBN: 978-1-78712-214-7 Walk through the basics of the Blockchain technology Implement Blockchain's technology and its features, and see what can be achieved using them Build DApps using Solidity and Web3.js Understand the geth command and cryptography Create Ethereum wallets Explore consortium blockchain Leave a review – let other readers know what you think Please share your thoughts on this book with others by leaving a review on the site that you bought it from If you purchased the book from Amazon, please leave us an honest review on this book's Amazon page This is vital so that other potential readers can see and use your unbiased opinion to make purchasing decisions, we can understand what our customers think about our products, and our authors can see your feedback on the title that they have worked with Packt to create It will only take a few minutes of your time, but is valuable to other potential customers, our authors, and Packt Thank you! ... Smart contracts Native contracts Summary 11 Further Ethereum Programming languages Runtime bytecode Opcodes and their meaning Arithmetic operations Logical operations Cryptographic operations Environmental... primitives Symmetric cryptography Stream ciphers Block ciphers Block encryption mode Electronic Code Book Cipher Block Chaining Counter mode Keystream generation mode Message authentication mode... Design of SHA-256 Design of SHA-3 (Keccak) OpenSSL example of hash functions Message Authentication Codes MACs using block ciphers Hash-based MACs Merkle trees Patricia trees Distributed Hash Tables

Ngày đăng: 06/03/2019, 10:35

Mục lục

  • Title Page

  • Copyright and Credits

    • Mastering Blockchain Second Edition

    • Packt Upsell

      • Why subscribe?

      • PacktPub.com

      • Contributors

        • About the author

        • About the reviewer

        • Packt is searching for authors like you

        • Preface

          • Who this book is for

          • What this book covers

          • To get the most out of this book

            • Download the example code files

            • Download the color images

            • Conventions used

            • Get in touch

              • Reviews

              • Blockchain 101

                • The growth of blockchain technology

                • Distributed systems

                • The history of blockchain and Bitcoin

                  • Electronic cash

                  • Blockchain

                    • Blockchain defined

                      • Peer-to-peer

                      • Distributed ledger

                      • Cryptographically-secure

                      • Append-only

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan