ebook img

R3 Corda for Architects and Developers: With Case Studies in Finance, Insurance, Healthcare, Travel, Telecom, and Agriculture PDF

224 Pages·2019·4.935 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview R3 Corda for Architects and Developers: With Case Studies in Finance, Insurance, Healthcare, Travel, Telecom, and Agriculture

R3 Corda for Architects and Developers With Case Studies in Finance, Insurance, Healthcare, Travel, Telecom, and Agriculture — Debajani Mohanty R3 Corda for Architects and Developers With Case Studies in Finance, Insurance, Healthcare, Travel, Telecom, and Agriculture Debajani Mohanty R3 Corda for Architects and Developers Debajani Mohanty Noida, Uttar Pradesh, India ISBN-13 (pbk): 978-1-4842-4531-6 ISBN-13 (electronic): 978-1-4842-4529-3 https://doi.org/10.1007/978-1-4842-4529-3 Copyright © 2019 by Debajani Mohanty This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Celestin Suresh John Development Editor: Siddhi Chavan Coordinating Editor: Aditee Mirashi Cover designed by eStudioCalamar Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www.apress. com/rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-4531-6. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper Table of Contents About the Author ���������������������������������������������������������������������������������xi About the Technical Reviewer �����������������������������������������������������������xiii Acknowledgments ������������������������������������������������������������������������������xv Introduction ��������������������������������������������������������������������������������������xvii Chapter 1: Barter to Blockchain �����������������������������������������������������������1 History of Money ���������������������������������������������������������������������������������������������������1 Barter System ��������������������������������������������������������������������������������������������������2 Metal Currency ������������������������������������������������������������������������������������������������3 Paper Money ����������������������������������������������������������������������������������������������������3 Banks ���������������������������������������������������������������������������������������������������������������4 Issue with Centralized Authority in Banking ����������������������������������������������������4 2008 Financial Crisis: A Pathbreaker ���������������������������������������������������������������5 Bitcoin Was Born ���������������������������������������������������������������������������������������������������6 Bitcoin White Paper �����������������������������������������������������������������������������������������7 Why Bitcoin Took the Market by Storm ������������������������������������������������������������8 Introduction to Blockchain ������������������������������������������������������������������������������������9 Business Problem �����������������������������������������������������������������������������������������������10 Fully Distributed Model ����������������������������������������������������������������������������������11 Fully Centralized Model ���������������������������������������������������������������������������������12 DLT, the Decentralized Peer-to-Peer Model ���������������������������������������������������14 Benefits of Blockchain ����������������������������������������������������������������������������������������17 iii TTaabbllee ooff CCoonnTTeennTTss DLT vs� Blockchain ����������������������������������������������������������������������������������������������17 Similarities ����������������������������������������������������������������������������������������������������18 Differences ����������������������������������������������������������������������������������������������������18 Blockchain Business Value ���������������������������������������������������������������������������������18 Blockchain Internals ��������������������������������������������������������������������������������������19 Different Types of Blocks �������������������������������������������������������������������������������20 Block Header �������������������������������������������������������������������������������������������������21 Merkle Tree ����������������������������������������������������������������������������������������������������21 Dealing with Double Spending ����������������������������������������������������������������������23 Blockchain Hashing ���������������������������������������������������������������������������������������24 Public and Private Keys ���������������������������������������������������������������������������������25 How Bitcoin Works ����������������������������������������������������������������������������������������������26 Transactions ��������������������������������������������������������������������������������������������������������29 Possible Attacks on Bitcoin Network ������������������������������������������������������������������30 Double Spending �������������������������������������������������������������������������������������������30 DDoS Attack ���������������������������������������������������������������������������������������������������32 Sybil or 51% Attack ���������������������������������������������������������������������������������������32 Eclipse Attack ������������������������������������������������������������������������������������������������32 MitM Attack ���������������������������������������������������������������������������������������������������33 Consensus �����������������������������������������������������������������������������������������������������33 Fork in Blockchain ����������������������������������������������������������������������������������������������37 Soft Fork ��������������������������������������������������������������������������������������������������������37 Hard Fork �������������������������������������������������������������������������������������������������������38 Types of Visibilities in Blockchain Networks �������������������������������������������������������39 Public Blockchain ������������������������������������������������������������������������������������������39 Private Blockchain �����������������������������������������������������������������������������������������39 iv TTaabbllee ooff CCoonnTTeennTTss Consortium or Federated Blockchain ������������������������������������������������������������40 Hybrid Blockchain ������������������������������������������������������������������������������������������40 Ethereum, the First Player �����������������������������������������������������������������������������������41 Limitations of Ethereum ��������������������������������������������������������������������������������42 Leading Blockchain and DLT Protocols ���������������������������������������������������������������42 Quorum ����������������������������������������������������������������������������������������������������������43 Ripple ������������������������������������������������������������������������������������������������������������43 Hyperledger Fabric ����������������������������������������������������������������������������������������43 R3 Corda ��������������������������������������������������������������������������������������������������������43 MultiChain �����������������������������������������������������������������������������������������������������44 Symbiont �������������������������������������������������������������������������������������������������������44 OpenChain �����������������������������������������������������������������������������������������������������45 Cardano ���������������������������������������������������������������������������������������������������������45 IOTA ���������������������������������������������������������������������������������������������������������������45 EOS ����������������������������������������������������������������������������������������������������������������45 HashGraph �����������������������������������������������������������������������������������������������������46 Quiz ���������������������������������������������������������������������������������������������������������������������46 Answers ��������������������������������������������������������������������������������������������������������������47 Reference ������������������������������������������������������������������������������������������������������������47 Chapter 2: Corda Architecture ������������������������������������������������������������49 The Doorman, Network Service ��������������������������������������������������������������������������49 The Corda Ledger ������������������������������������������������������������������������������������������������50 Identity �����������������������������������������������������������������������������������������������������������50 State ��������������������������������������������������������������������������������������������������������������50 Contracts �������������������������������������������������������������������������������������������������������51 Ricardian Contract �����������������������������������������������������������������������������������������51 v TTaabbllee ooff CCoonnTTeennTTss Transaction ����������������������������������������������������������������������������������������������������51 Flow ���������������������������������������������������������������������������������������������������������������52 Consensus �����������������������������������������������������������������������������������������������������52 Notary ������������������������������������������������������������������������������������������������������������52 Time Window �������������������������������������������������������������������������������������������������53 Oracles ����������������������������������������������������������������������������������������������������������53 GDPR, the Blockchain Killer! �������������������������������������������������������������������������������53 Corda’s Compliance with GDPR ���������������������������������������������������������������������57 Corda’s Differentiators, a Recap �������������������������������������������������������������������������57 No Global Sharing and No Central Database �������������������������������������������������58 No Global Broadcast ��������������������������������������������������������������������������������������58 Blockchain Features and Yet No Blockchain �������������������������������������������������58 Real-Time Synchronous Transactions �����������������������������������������������������������58 GDPR Complaint ��������������������������������������������������������������������������������������������59 Quiz ���������������������������������������������������������������������������������������������������������������������59 Answers ���������������������������������������������������������������������������������������������������������60 References ����������������������������������������������������������������������������������������������������������60 Chapter 3: Installation, Development, Deployment, Unit, and Functional Testing ������������������������������������������������������������������������������61 States ������������������������������������������������������������������������������������������������������������������63 LinearState ����������������������������������������������������������������������������������������������������64 OwnableState ������������������������������������������������������������������������������������������������64 QueryableState ����������������������������������������������������������������������������������������������65 SchedulableState ������������������������������������������������������������������������������������������65 Contract ��������������������������������������������������������������������������������������������������������������66 Ricardian Contract �����������������������������������������������������������������������������������������66 requireThat ����������������������������������������������������������������������������������������������������66 vi TTaabbllee ooff CCoonnTTeennTTss Commands ����������������������������������������������������������������������������������������������������������66 Time Windows �����������������������������������������������������������������������������������������������������67 Attachment����������������������������������������������������������������������������������������������������������68 LedgerTransaction ����������������������������������������������������������������������������������������������68 Flow ��������������������������������������������������������������������������������������������������������������������68 FlowLogic ������������������������������������������������������������������������������������������������������69 InitiatingFlow �������������������������������������������������������������������������������������������������69 InitiatedBy �����������������������������������������������������������������������������������������������������69 StartableByRPC ���������������������������������������������������������������������������������������������69 FinalityFlow ���������������������������������������������������������������������������������������������������69 TransactionBuilder �����������������������������������������������������������������������������������������70 ProgressTracker���������������������������������������������������������������������������������������������70 Vault ��������������������������������������������������������������������������������������������������������������������70 Oracles ����������������������������������������������������������������������������������������������������������������70 Project Setup ������������������������������������������������������������������������������������������������������71 TDD in Corda: Unit Testing and More �������������������������������������������������������������������74 Corda API for Unit Testing ������������������������������������������������������������������������������74 Project Import Test�����������������������������������������������������������������������������������������75 Unit Testing of State ��������������������������������������������������������������������������������������76 Unit Testing of Contract ���������������������������������������������������������������������������������77 Unit Testing of Flow ���������������������������������������������������������������������������������������78 Deploy and Run ���������������������������������������������������������������������������������������������������80 Vault Query ����������������������������������������������������������������������������������������������������85 Exposing REST Endpoints for Integration with UI ������������������������������������������������89 Functional Testing������������������������������������������������������������������������������������������91 vii TTaabbllee ooff CCoonnTTeennTTss Troubleshooting ��������������������������������������������������������������������������������������������������95 Use Cases �����������������������������������������������������������������������������������������������������������95 Quiz ���������������������������������������������������������������������������������������������������������������������96 Answers ���������������������������������������������������������������������������������������������������������97 Reference ������������������������������������������������������������������������������������������������������������97 Chapter 4: Government and Real Estate ���������������������������������������������99 Solution �������������������������������������������������������������������������������������������������������������100 R3 Corda Advantages ����������������������������������������������������������������������������������������129 Live Implementation �����������������������������������������������������������������������������������������130 References ��������������������������������������������������������������������������������������������������������130 Chapter 5: Finance Domain— Real-Time e-Auction; Trade Finance and Letter of Credit ����������������������������������������������������131 Real-Time e-Auction �����������������������������������������������������������������������������������������131 Solution �������������������������������������������������������������������������������������������������������132 Advantages ��������������������������������������������������������������������������������������������������136 Live Use Cases ��������������������������������������������������������������������������������������������136 Trade Finance and Letter of Credit ��������������������������������������������������������������������137 Solution �������������������������������������������������������������������������������������������������������140 Advantages ��������������������������������������������������������������������������������������������������142 Live Implementations ����������������������������������������������������������������������������������143 References ��������������������������������������������������������������������������������������������������������144 Chapter 6: Insurance Domain—Car Insurance ���������������������������������147 Solution �������������������������������������������������������������������������������������������������������������148 Advantages ��������������������������������������������������������������������������������������������������151 Live Implementations ����������������������������������������������������������������������������������151 References ��������������������������������������������������������������������������������������������������������152 viii TTaabbllee ooff CCoonnTTeennTTss Chapter 7: Healthcare—Corda and Ethereum Hybrid Use Case ��������153 Solution �������������������������������������������������������������������������������������������������������������154 Attachment ��������������������������������������������������������������������������������������������������159 Advantages ��������������������������������������������������������������������������������������������������172 Live Implementations ����������������������������������������������������������������������������������173 References ��������������������������������������������������������������������������������������������������������174 Chapter 8: Travel Domain: Replacing GDS with Next-Generation Travel Platform ������������������������������������������������������175 Solution �������������������������������������������������������������������������������������������������������������178 Advantages ��������������������������������������������������������������������������������������������������179 Live Implementations ����������������������������������������������������������������������������������180 Reference ����������������������������������������������������������������������������������������������������������180 Chapter 9: Telecom Domain: Fraud Management �����������������������������181 Solution �������������������������������������������������������������������������������������������������������������182 Advantages ��������������������������������������������������������������������������������������������������182 Live Implementations ����������������������������������������������������������������������������������183 References ��������������������������������������������������������������������������������������������������������183 Chapter 10: Supply Chain in Agriculture ������������������������������������������185 Solution �������������������������������������������������������������������������������������������������������������186 Advantages ��������������������������������������������������������������������������������������������������190 Live Implementations ����������������������������������������������������������������������������������192 References ��������������������������������������������������������������������������������������������������������192 ix

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.