BLOCKCHAIN TECHNOLOGY IN HEALTH CARE A PROJECT REPORT Submitted in partial fulfillment of the requirements for the award of the degree of
Bachelor of Technology in
COMPUTER SCIENCE AND ENGINEERING BY P. Manasa Komali
M. Sethu Pavan
(Roll No: 15331A05B4)
(Roll No: 15331A05A5)
M. Naveen Kumar
L. Sudheer
(Roll No: 15331A0589)
(Roll No: 15331A0584)
Under the Supervision of Dr. P. Satheesh Kumar Associate Professor
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MVGR COLLEGE OF ENGINEERING (Autonomous) VIZIANAGARAM-535005, AP (INDIA) (Accredited by NBA, NAAC, and Permanently Affiliated to Jawaharlal Nehru Technological University Kakinada) APRIL, 2019
BLOCKCHAIN TECHNOLOGY IN HEALTH CARE A PROJECT REPORT Submitted in partial fulfillment of the requirements for the award of the degree of
Bachelor of Technology in
COMPUTER SCIENCE AND ENGINEERING BY P. Manasa Komali
M. Sethu Pavan
(Roll No: 15331A05B4)
(Roll No: 15331A05A5)
M. Naveen Kumar
L. Sudheer
(Roll No: 15331A0589)
(Roll No: 15331A0584)
Under the Supervision of Dr. P. Satheesh Kumar Associate Professor
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MVGR COLLEGE OF ENGINEERING (Autonomous) VIZIANAGARAM-535005, AP (INDIA) (Accredited by NBA, NAAC, and Permanently Affiliated to Jawaharlal Nehru Technological University Kakinada) APRIL, 2019
CERTIFICATE
This is to certify that the project report entitled “BLOCKCHAIN TECHNOLOGY IN HEALTH CARE” being submitted by P. Manasa Komali,M.Sethu Pavan, M.Naveen Kumar, L.Sudheer bearing registered numbers
15331A05B4, 15331A05A5, 15331A0589,
15331A0584 respectively, in partial fulfillment for the award of the degree of “Bachelor of Technology” in Computer Science and Engineering is a record of bonafide work done by them under my supervision during the academic year 2018-2019.
HOD CSE
Supervisor
Name and Designation
External Examiner
ACKNOWLEDGEMENTS I owe a great lot of thanks to many people who have helped me and supported me during the course of my project.
I am very grateful to our beloved HOD Dr. M. Kalyan Chakaravarthi, Professor and my guide Dr.P. Sateesh , Associate Professor who spent a lot of their precious time with me on my work in spite of being very busy with the academic works of the department, for their background knowledge and patience in the completion of my project. I extend my sincere thanks for their esteemed guidance and support during the entire project. Their constant encouragement and suggestions helped me a lot. I have whole heartedly enjoyed the challenge of examining and researching a controversial issue that might make an impact on the Design instead of performing another educational study.
I am grateful to Adil Moujahid for implementation of blockchain using python with the reference of the application we have implemented our project.
I am grateful to our beloved Dr. K. V. L. Raju, Principal, for giving me access to all the facilities in the college at any odd hour.
I thank my parents for their great support during the whole work of my project.
I am also thankful to Dr. N. Aruna kumari, Associate professor for his guidance and help by contributing us blockchain technology in health care which is the heart of the project.
I am also thankful to P.K.Santosh Naidu, professor who helped me and gave valuable suggestions in order to accomplish smooth running of my project.
I also thank all the other faculty and support staff of the Computer Science Department who have helped me in doing work with ease and perfection.
ABSTRACT A decentralized and secured database which is consistently held up to date presents many advantages to the Healthcare industry. These advantages become especially interesting, when many different parties need access to the same information. Health Network is built based on the Blockchain technology . Through this shared network infrastructure, different Healthcare specialists can access the same information. The Health Network represents a Healthcare ecosystem that combines Specialists, individuals and experts and which, at the same time, improve patient-centered care while address operational efficiency issues.
Table of contents Acknowledgement Abstract Table of contents List of Abbreviations List of Tables List of Figures 1. Introduction 1.1 About Block Chain 1.2 History of Blockchain 1.3 Structure 1.4 Decentralization 1.5 Uses 1.6 Types of Blockchain 2. Literature Survey 3. Theoretical Background 3.1Blockchain 3.1.1 Introduction 3.1.2 Double Spending Problem 3.1.3 A Decentralized solution for Double spending problem 3.1.4 Public key Cryptography 3.2 Uses of Blockchain for health data 3.3 Health care industry on security 4. Design and Implementaion (Methods/Techniques) 4.1 Hashing Function and Mining 4.2 Hashing and Blockchain’s Cryptographic Puzzle 4.2.1 Basic Blockchain Structure 4.2.2 Block hash 4.3 Cryptographic hash function SHA-256 4.3.1 General description 4.3.2 Basic Operations 4.3.3 Functions and constants 4.3.4 Padding 4.3.5 Block decomposition 4.3.6 Hash computation 4.3.7 Implemetation signatures 4.3.8 Test values 4.4 RSA Algorithm 4.4.1 Why RSA is secure 4.5 Nonces Algorithm
Page No i ii iii
1
5. Experimental Results and Discussion 5.1 Patient Dashboard 5.2 Patient Details 5.3 Patient Transaction Details 5.4 Patient Blockchain 5.5 Patient’s Mined Blockchain 5.6 Doctors Dashboard 5.7 Doctors Details 5.8 Docotrs Transaction Details 5.9Doctors Blockchain 5.10 Doctors Mined Blockchain 5.11 Hospital Dashboard 5.12 Hospital Blockchain 5.13 Central Blockchain 6. Conclusion
References
Appendix A
List of Abbreviations 4.1 SHA-Secure Hash Algorithm 4.2 RSA- Rivest, Shamir, Adleman
List of Figures 3.1 Double Spending Problem 3.2 Decentralized solution 3.3 Public key Cryptography 4.2 Block Structure 4.5 Building Blocks with Nonces 4.5.1 Working of Nonce Algorithm
List of Tables
4.3.8 Test Values
INTRODUCTION 1.1About Blockchain: A blockchain, originally block chain,is a growing list of records, called blocks, which are linked using cryptography.Each block contains a cryptographic hash of the previous block,a timestamp, and transaction data (generally represented as a merkle tree root hash). By design, a blockchain is resistant to modification of the data. It is "an open, distributed ledger that can record transactions between two parties efficiently and in a verifiable and permanent way".For use as a distributed ledger, a blockchain is typically managed by a peerto-peer network collectively adhering to a protocol for inter-node communication and validating new blocks. Once recorded, the data in any given block cannot be altered retroactively without alteration of all subsequent blocks, which requires consensus of the network majority. Although blockchain records are not unalterable, blockchains may be considered secure by design and exemplify a distributed computing system with high Byzantine fault tolerance. Decentralized consensus has therefore been claimed with a blockchain. Blockchain was invented by a person using the name Satoshi Nakamoto in 2008 to serve as the public transaction ledger of the cryptocurrency bitcoin. The identity of Satoshi Nakamoto is unknown. The invention of the blockchain for bitcoin made it the first digital currency to solve the double-spending problem without the need of a trusted authority or central server. The bitcoin design has inspired other applications,and blockchains which are readable by the public are widely used by cryptocurrencies. Blockchain is considered a type of payment rail.Private blockchains have been proposed for business use.
1.2 History of Block Chain: The first work on a cryptographically secured chain of blocks was described in 1991 by Stuart Haber and W. Scott Stornetta. They wanted to implement a system where document timestamps could not be tampered with. In 1992, Bayer, Haber and Stornetta incorporated Merkle trees to the design, which improved its efficiency by allowing several document certificates to be collected into one block.
The first blockchain was conceptualized by a person (or group of people) known as Satoshi Nakamoto in 2008. Nakamoto improved the design in an important way using a Hashcashlike method to add blocks to the chain without requiring them to be signed by a trusted party. The design was implemented the following year by Nakamoto as a core component of the cryptocurrency bitcoin, where it serves as the public ledger for all transactions on the network. In August 2014, the bitcoin blockchain file size, containing records of all transactions that have occurred on the network, reached 20 GB (gigabytes). In January 2015, the size had grown to almost 30 GB, and from January 2016 to January 2017, the bitcoin blockchain grew from 50 GB to 100 GB in size. The words block and chain were used separately in Satoshi Nakamoto's original paper, but were eventually popularized as a single word, blockchain, by 2016. Smart contracts which run on a blockchain, for example ones which "create invoices that pay themselves when a shipment arrives or share certificates which automatically send their owners dividends if profits reach a certain level." require an off-chain oracle to access any "external data or events based on time or market conditions that need to interact with the blockchain." IBM opened a blockchain innovation research center in Singapore in July 2016. A working group for the World Economic Forum met in November 2016 to discuss the development of governance models related to blockchain. According to Accenture, an application of the diffusion of innovations theory suggests that blockchains attained a 13.5% adoption rate within financial services in 2016, therefore reaching the early adopters phase. Industry trade groups joined to create the Global Blockchain Forum in 2016, an initiative of the Chamber of Digital Commerce.
1.3 Structure: A blockchain is a decentralized, distributed and public digital ledger that is used to record transactions across many computers so that any involved record cannot be altered retroactively, without the alteration of all subsequent blocks.This allows the participants to verify and audit transactions independently and relatively inexpensively. A
blockchain database is managed autonomously using a peer-to-peer network and a distributed timestamping server.
They are authenticated by mass collaboration powered by collective selfinterests. Such a design facilitates robust workflow where participants' uncertainty regarding data security is marginal. The use of a blockchain removes the characteristic of infinite reproducibility from a digital asset. It confirms that each unit of value was transferred only once, solving the long-standing problem of double spending. A blockchain has been described as a value-exchange protocol. A blockchain can maintain title rights because, when properly set up to detail the exchange agreement, it provides a record that compels offer and acceptance.
A blockchain is a decentralized, distributed and public digital ledger that is used to record transactions across many computers so that any involved record cannot be altered retroactively, without the alteration of all subsequent blocks. This allows the participants to verify and audit transactions independently and relatively inexpensively. A blockchain database is managed autonomously using a peer-to-peer network and a distributed timestamping server. They are authenticated by mass collaboration powered by collective self-interests. Such a design facilitates robust workflow where participants' uncertainty regarding data security is marginal. The use of a blockchain removes the characteristic of infinite reproducibility from a digital asset. It confirms that each unit of value was transferred only once, solving the long-standing problem of double spending. A blockchain has been described as a value-exchange protocol. A blockchain can maintain title rights because, when properly set up to detail the exchange agreement, it provides a record that compels offer and acceptance.
1.4 Decentralization: By storing data across its peer-to-peer network, the blockchain eliminates a number of risks that come with data being held centrally. The decentralized blockchain may use ad-hoc message passing and distributed networking.
Peer-to-peer blockchain networks lack centralized points of vulnerability that computer crackers can exploit; likewise, it has no central point of failure. Blockchain security methods include the use of public-key cryptography. A public key (a long, random-looking string of numbers) is an address on the blockchain. Value tokens sent across the network are recorded as belonging to that address. A private key is like a password that gives its owner access to their digital assets or the means to otherwise interact with the various capabilities that blockchains now support. Data stored on the blockchain is generally considered incorruptible.
Every node in a decentralized system has a copy of the blockchain. Data quality is maintained by massive database replication and computational trust. No centralized "official" copy exists and no user is "trusted" more than any other.Transactions are broadcast to the network using software. Messages are delivered on a best-effort basis. Mining nodes validate transactions, add them to the block they are building, and then broadcast the completed block to other nodes. Blockchains use various time-stamping schemes, such as proof-of-work, to serialize changes. Alternative consensus methods include proof-of-stake. Growth of a decentralized blockchain is accompanied by the risk of centralization because the computer resources required to process larger amounts of data become more expensive. 1.5Uses: Blockchain technology can be integrated into multiple areas. The primary use of blockchains today is as a distributed ledger for cryptocurrencies, most notably bitcoin. There are a few operational products maturing from proof of concept by late 2016. As of 2016, some observers remain skeptical. Steve Wilson, of Constellation Research, believes the technology has been hyped with unrealistic claims. To mitigate risk, businesses are reluctant to place blockchain at the core of the business structure. Cryptocurrencies Main article: Cryptocurrency Most cryptocurrencies use blockchain technology to record transactions. For example, the bitcoin network and Ethereum network are both based on blockchain. On May 8, 2018 Facebook confirmed that it is opening a new blockchain group which will be headed by David Marcus who previously was in charge of Messenger. According to The Verge
Facebook is planning to launch its own cryptocurrency for facilitating payments on the platform. Smart contracts Main article: Smart contract Blockchain-based smart contracts are proposed contracts that could be partially or fully executed or enforced without human interaction. One of the main objectives of a smart contract is automated escrow. An IMF staff discussion reported that smart contracts based on blockchain technology might reduce moral hazards and optimize the use of contracts in general. But "no viable smart contract systems have yet emerged." Due to the lack of widespread use their legal status is unclear. Financial Services Major portions of the financial industry are implementing distributed ledgers for use in banking, and according to a September 2016 IBM study, this is occurring faster than expected. Banks are interested in this technology because it has potential to speed up back office settlement systems. Banks such as UBS are opening new research labs dedicated to blockchain technology in order to explore how blockchain can be used in financial services to increase efficiency and reduce costs. Berenberg, a German bank, believes that blockchain is an "overhyped technology" that has had a large number of "proofs of concept", but still has major challenges, and very few success stories. Blockchain with video games Some video games are based on blockchain technology. The first such game, Huntercoin, was released in February, 2014.Another blockchain game is CryptoKitties, launched in November 2017. The game made headlines in December 2017 when a cryptokitty character - an-in game virtual pet - was sold for US$100,000. CryptoKitties illustrated scalability problems for games on Ethereum when it created significant congestion on the Ethereum network with about 30% of all Ethereum transactions being for the game
Cryptokitties also demonstrated how blockchains can be used to catalog game assets (digital assets). The Blockchain Game Alliance was formed in September 2018 to explore alternative uses of blockchains in video gaming with support of Ubisoft and Fig, among others. Other uses Blockchain technology can be used to create a permanent, public, transparent ledger system for compiling data on sales, tracking digital use and payments to content creators, such as wireless users or musicians. In 2017, IBM partnered with ASCAP and PRS for Music to adopt blockchain technology in music distribution. Imogen Heap's Mycelia service has also been proposed as blockchain-based alternative "that gives artists more control over how their songs and associated data circulate among fans and other musicians." Everledger is one of the inaugural clients of IBM's blockchain-based tracking service. Walmart and IBM are running a trial to use a blockchain-backed system for supply chain monitoring — all nodes of the blockchain are administered by Walmart and are located on the IBM cloud. New distribution methods are available for the insurance industry such as peer-to-peer insurance, parametric insurance and microinsurance following the adoption of blockchain.The sharing economy and IoT are also set to benefit from blockchains because they involve many collaborating peers. Online voting is another application of the blockchain. Other designs include: Hyperledger is a cross-industry collaborative effort from the Linux Foundation to support blockchain-based distributed ledgers, with projects under this initiative including Hyperledger Burrow (by Monax) and Hyperledger Fabric (spearheaded by IBM) Quorum – a permissionable private blockchain by JPMorgan Chase with private storage, used for contract applications Tezos, decentralized voting. Proof of Existence is an online service that verifies the existence of computer files as of a specific time
1.6 Types of blockchains: Currently, there are three types of blockchain networks — public blockchains, private blockchains and consortium blockchains. Public blockchains A public blockchain has absolutely no access restrictions. Anyone with an internet connection can send transactions to it as well as become a validator (i.e., participate in the execution of a consensus protocol).[84][self-published source?] Usually, such networks offer economic incentives for those who secure them and utilize some type of a Proof of Stake or Proof of Work algorithm. Some of the largest, most known public blockchains are Bitcoin and Ethereum. Private blockchains A private blockchain is permissioned.[42] One cannot join it unless invited by the network administrators. Participant and validator access is restricted. This type of blockchains can be considered a middle-ground for companies that are interested in the blockchain technology in general but are not comfortable with a level of control offered by public networks. Typically, they seek to incorporate blockchain into their accounting and record-keeping procedures without sacrificing autonomy and running the risk of exposing sensitive data to the public internet. Consortium blockchains A consortium blockchain is often said to be semi-decentralized. It, too, is permissioned but instead of a single organization controlling it, a number of companies might each operate a node on such a network. The administrators of a consortium chain restrict users' reading rights as they see fit and only allow a limited set of trusted nodes to execute a consensus protocol.
2.Literature Survey: TITLE OF PAPER: Blockchain Technology in Healthcare By.Matthias Mettler. M.A.HSG
Abstract: A decentralized database which is consistently held up to date presents many advantages to the healthcare industry.These advantages become especially interesting, when many different parties need access to the same information.The Gem Health Network based on the Ethereum Blockchain technology . Through this shared network infrastructure, different healthcare specialists can access the same information. The Gem Health Network represents a healthcare ecosystem that combines both businesses, individuals and experts and which, at the same time, improve patient-centered care while address operational efficiency issues.
TITLE OF PAPER: A Peer-to-peer Electronic cash system by Satoshi Nakamoto Abstract: A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution. Digital signatures provide part of the solution, but the main benefits are lost if a trusted third party is still required to prevent double-spending. We propose a solution to the double-spending problem using a peer-to-peer network. The network timestamps transactions by hashing them into an ongoing chain of hash-based proof-of-work, forming a record that cannot be changed without redoing the proof-of-work. The longest chain not only serves as proof of the sequence of events witnessed, but proof that it came from the largest pool of CPU power. As long as a majority of CPU power is controlled by nodes that are not cooperating to attack the network, they'll generate the longest chain and outpace attackers. The network itself requires minimal structure. Messages are broadcast on a best effort basis, and nodes can leave and rejoin the network at will, accepting the longest proof-of-work chain as proof of what happened while they were gone.
TITLE OF PAPER: MedRec:- Using Blockchain for Medical Data Access and Permission Management Abstract: Years of heavy regulation and bureaucratic inef-ficiency have slowed innovation for electronic medical records(EMRs). In this paper, we propose MedRec: a novel, decentralized record management system to handle EMRs, using blockchain technology. Our system gives patients a comprehensive, immutable log and easy access to their medical information across providers and treatment sites. Leveraging unique blockchain properties, MedRec manages authentication, confidentiality, accountability and data sharing– crucial considerations when handling sensitive information. We incentivize medical stakeholders (researchers, public health authorities, etc.) to participate in the network as blockchain “miners”. This provides them with access to aggregate, anonymized data as mining rewards, in return for sustaining and securing the network via Proof of Work.
TITLE OF PAPER: Blockchain Solutions for Big Data Challenges Abstract: This paper describes our blockchain architecture as a new system solution to supply a reliable mechanism for secure and efficient medical record exchanges. The Advanced BlockChain (ABC) approach was designed to meet the demands in healthcare growth as well as in the new form of social interactive norms. It is going to revolutionize the eHealth industry with greater efficiency by eliminating many of the intermediates as we know them today.
Problem Definition: Decentralized electronic health record(EHR) system which manages authentication, confidentiality, accountability and data sharing using blockchain technology.
Source of data:
Inputs:- Patient details,Patient reports,Doctors details,Hospital details.
Outputs:- A decentralized Electronic Health record with contains all the details of patients and their diseases.
3. Theoritical Background 3.1 Blockchain 3.1.1.Introduction: In the original Bitcoin white paper, Satoshi described how to build a peer-to-peer electronic cash system that allows online payments to be sent directly from one party to another without going through a centralized institution. This system solves an important problem in digital money called double-spending.
3.1.2 Double Spending Problem: Suppose that Alice wants to pay Bob 1$. If Alice and Bob use physical cash, then Alice will not longer have the 1$ after the transaction is executed. If Alice and Bob use digital money, then the problem gets more complicated. Digital money is in digital form and can be easily duplicated. If Alice sends a digital file worth 1$ to Bob by email for example, Bob cannot know for sure if Alice has deleted her copy of the file. If Alice still has the 1$ digital file, then she can choose to spend the same file to Carol. This problem is called double-spending.
Fig:3.1 Double Spending Problem
3.1.3 A Decentralized solution for Double Spending Problem: Bitcoin’s blockchain to keep track of all transactions in the network. Bitcoin’s blockchain has the following characteristics:
Distributed: The ledger is replicated across a number of computers rather than being stored on a central server. Any computer with an internet connection can download a full copy of the blockchain.
Cryptographic: Cryptography is used to make sure that the sender owns the bitcoin that she's trying to send, and to decide how the transactions are added to the blockchain.
Immutable: The blockchain can be changed in append only fashion. In other words, transactions can only be added to the blockchain but cannot be deleted or modified.
Uses Proof of Work (PoW): A special type of participants in the network called miners compete on searching for the solution to a cryptographic puzzle that will allow them to add a block of transactions to Bitcoin’s blockchain. This process is called Proof of Work and it allows the system to be secure.
Fig 3.2 Decentralized solution
3.1.4 Public Key Cryptography: Public-key cryptography, or asymmetrical cryptography, is any cryptographic system that uses pairs of keys: public keys which may be disseminated widely, and private keys which are known only to the owner. This accomplishes two functions: authentication, where the public key verifies a holder of the paired private key sent the message, and encryption, where only the paired private key holder can decrypt the message encrypted with the public key.
Fig 3.3 Public Key Cryptography
3.2 Uses of Blockchain for health data: Blockchain technology is a game-changer with the potential to impact not one or two industries, but the complete landscape of how business is done. When 200 healthcare executives were surveyed, 16 percent expect to have a commercial blockchain solution at scale sometime this year. The key players for blockchain adoption will be regulators, industry groups and market makers. Managing and securing data within healthcare and supply chain
management are two great examples of principal concepts influencing and being impacted by possible blockchain adoption. Let’s take a brief look at each one:
Healthcare: Better data sharing between healthcare providers means a higher probabaility of accurate diagnoses, more effective treatments, and the overall increased ability of healthcare organizations to deliver cost-effective care. Blockchain technology can allow various stakeholders in the healthcare value-chain to share access to their networks without compromising data security and integrity, by allowing them to track data provenance as well as any changes made.
Supply Chain Management: One of the most universally appilicable aspects of blockchain technology is that it enables more secure and transparent monitoring of transactions. With blockchain, the transactions can be documented in a permanent decentralized record reducing time delays, added costs and human errors.
Data managed by medical organizations includes:
Patient health information (PHI);
Electronic health records;
Data collected from monitoring systems.
3.3 Health care industry on security: In the current system, security and trust are the most common concerns shard by businesses regarding the information shared between different entities. Information can be entered anywhere along the line of communication and this leads to trust issues, especially in the healthcare industry. There are also concerns where multiple vendors hold different versions of the same patient record that are not validated, resulting in various errors, inconsistency and incompleteness. Add to that reports of security breaches, tampering of personal data and the ever-present hacking threat, it’s not surprising healthcare officials are concerned.
Since blockchain are cryptographically secure and the data present there can be authenticated using digital signature that are unique to each person, this technology could be the answer to most of these concerns.
4. Design and Implementaion (Methods/Techniques):
4.1 Hashing Function and Mining:
All Bitcoin transactions are grouped in files called blocks. Bitcoin adds a new block of transactions every 10 minutes. Once a new block is added to the blockchain, it becomes immutable and can't be deleted or modified. A special group of participants in the network called miners (computers connected to the blockchain) are responsible for creating new blocks of transactions. A miner has to authenticate each transaction using the sender's public key, confirm that the sender has enough balance for the requested transaction, and add the transaction to the block. Miners are completely free to choose which transactions to include in the blocks, therefore the senders need to include a transaction fee to incentivise the miners to add their transactions to the blocks. For a block to be accepted by the blockchain, it needs to be "mined". To mine a block, miners need to find an extremely rare solution to a cryptographic puzzle. If a mined block is accepted by the blockchain, the miner receive a reward in bitcoins which is an additional incentive to transaction fees. The mining process is also referred to as Proof of Work (PoW), and it's the main mechanism that enables the blockchain to be trustless and secure.
4.2 Hashing and Blockchain's Cryptographic Puzzle: To understand the blockchain's cryptographic puzzle, we need to start with hash functions. A hash function is any function that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are called hashes. Hash functions are usually used to accelerate database lookup by detecting duplicated records, and they are also widely used in cryptography. A cryptographic hash function allows one to easily verify that some input data maps to a given hash value, but if the input data is unknown, it is deliberately Difficult to reconstruct it by knowing the stored hash value.
Bitcoins uses a cryptographic hash function called SHA-256. SHA-256 is applied to a combination of the block's data (bitcoin transactions) and a number called nonce. By changing the block data or the nonce, we get completely different hashes. For a block to be considered valid or "mined", the hash value of the block and the nonce needs to meet a certain condition. For example, the four leading digits of the hash needs to be equal to "0000". We can increase the mining complexity by making the condition more complex, for example we can increase the number of 0s that the hash value needs to start with.
4.2.1Basic Blockchain Structure: A Distributed database that maintains a continuously growing list of ordered records. The basic functionalities of blockchain:
A defined block and blockchain structure.
Methods to add new blocks to the blockchain with arbitrary data.
Blockchain nodes that communicate and sync the blockchain with other nodes.
A simple HTTP API to control the node.
Block Structure:
Index: The height of the block in the blockchain.
Data: Any data that is included in the block.
Time stamp: A time stamp.
Hash: A SHA-256 hash taken from the content of the block.
Previous hash: A reference to the hash of the previous block. This value explicity defines the previous block.
Fig:4.2 Block Structure Block0:
Block1:
Index:
Index:
TimeStamp:
TimeStamp:
Data:
Data:
Hash:
Hash:
Prev hash:
Prev hash:
4.2.2Block Hash:
The Block hash is one of the most important property of the block.
The hash is calculated over all data of the block.This menas that if anything in the block changes ,the original hash is no longer valid.
The blockchain can also be thoigh as the unique identifier of the block. For instance blocks with same index can apper biut they all have unique hashes.
We use Block hashes to preserve integrity of the block.
1) Generating a Block: To generate a block we must know the hash of the previous block and create the rest i.e; index,hash,data and time stamp. The main block that is the first block does not contain any previous hash key. 2) Validating the integrity of block: We must be able to validate if a block or a chain of blocks are valid in terms of integrity for a block to be valid the following must apply:
The index of the block must be one number larger than the previous hash.
The previous hash of the block match the hash of the prev block.
The hash of the block itself must be valid.
3) Storing a block: The data will not be persisted when the node is terminated.
4.3 Cryptographic hash function SHA-256: 4.3.1General description: SHA-256 (secure hash algorithm, FIPS 182-2) is a cryptographic hash function with digest length of 256 bits. It is a keyless hash function; that is, an MDC (Manipulation Detection Code). A message is processed by blocks of 512 = 16 × 32 bits, each block requiring 64 rounds.
4.3.2 Basic operations:
Boolean operations AND, XOR and OR, denoted by ∧, ⊕ and ∨, respectively.
Bitwise complement, denoted by ¯
Integer addition modulo 232, denoted by A + B.
Each of them operates on 32-bit words. For the last operation, binary words are interpreted as integers written in base 2.
RotR(A, n) denotes the circular right shift of n bits of the binary word A.
ShR(A, n) denotes the right shift of n bits of the binary word A.
A||B denotes the concatenation of the binary words A and B.
4.3.3 Functions and constants: The algorithm uses the functions: Ch(X, Y, Z) = (X ∧ Y ) ⊕ (X ∧ Z), M aj(X, Y, Z) = (X ∧ Y ) ⊕ (X ∧ Z) ⊕ (Y ∧ Z), Σ0(X) = RotR(X, 2) ⊕ RotR(X, 13) ⊕ RotR(X, 22), Σ1(X) = RotR(X, 6) ⊕ RotR(X, 11) ⊕ RotR(X, 25), σ0(X) = RotR(X, 7) ⊕ RotR(X, 18) ⊕ ShR(X, 3), σ1(X) = RotR(X, 17) ⊕ RotR(X, 19) ⊕ ShR(X, 10), and the 64 binary words Ki given by the 32 first bits of the fractional parts of the cube roots of the first 64 prime numbers.
3.3.4 Padding: To ensure that the message has length multiple of 512 bits:
first, a bit 1 is appended,
next, k bits 0 are appended, with k being the smallest positive integer such that l+ 1 + k ≡ 448 mod 512, where l is the length in bits of the initial message,
finally, the length l < 2 64 of the initial message is represented with exactly 64 bits, and these bits are added at the end of the message.
The message shall always be padded, even if the initial length is already a multiple of 512.
4.3.5 Block decomposition: For each block M ∈ {0, 1} 512, 64 words of 32 bits each are constructed as follows: • the first 16 are obtained by splitting M in 32-bit blocks M = W1kW2k · · · kW15kW16
• the remaining 48 are obtained with the formula: Wi = σ1(Wi−2) + Wi−7 + σ0(Wi−15) + Wi−16,
17 ≤ i ≤ 64.
4.3.6 Hash computation:
First, eight variables are set to their initial values, given by the first 32 bits of the fractional part of the square roots of the first 8 prime numbers:
H 1(0) = 0x6a09e667
H2 (0) = 0xbb67ae85
H5 (0) = 0x510e527f
H 6(0) = 0x9b05688c H 7(0) = 0x1f83d9ab H 8(0) = 0x5be0cd19
H3 (0) = 0x3c6ef372 H 4(0) = 0xa54ff53a
Next, the blocks M(1) , M(2), . . . , M(N) are processed one at a time:
For t = 1 to N
construct the 64 blocks Wi from M(t) , as explained above
set
(a, b, c, d, e, f, g, h) = (H 1(t−1) , H2(t−1), H3(t−1) , H4(t−1) , H5(t−1) , H6(t−1) , H7(t−1) , H8(t−1))
do 64 rounds consisting of: T1 = h + Σ1(e) + Ch(e, f, g) + Ki + Wi T2 = Σ0(a) + M aj(a, b, c) h=g g=f f=e e = d + T1 d=c c=b b=a a = T1 + T2
compute the new value of H j(t) H 1(t) = H 1(t−1) + a H 2(t) = H 2(t−1) + b H 3(t) = H 3(t−1) + c
H 4(t) = H 4(t−1) + d H 5(t) = H 5(t−1) + e H 6(t) = H 6(t−1) + f H 7(t) = H 7(t−1) + g H 8(t) = H 8(t−1) + h End for
The hash of the message is the concatenation of the variables H iN after the last block has been processed
H = H 1(N) ||H 2(N) || H3 (N) || H 4(N) || H5 (N) || H 6(N) || H 7(N) || H 8(N) .
4.3.7 Implementation: signatures Implement the cryptographic hash function just described. Define the class sha256 with the method: public static BigInteger hash(byte[] M) input: M is a chain of bytes of arbitrary length; output: a positive integer in the interval [0, 2 256), the value of the hash of M.
4.3.8 Test values: To check the implementation, you can use the following values, given in hexadecimal notation. Input
61 62 63
hash
ba7816bf 8f01cfea 414140de 5dae2223 b00361a3 96177a9c b410ff61 f20015ad
Input
61 62 63 64 62 63 64 65 63 64 65 66 64 65 66 67 65 66 67 68 66 67 68 69 67 68 69 6a 68 69 6a 6b 69 6a 6b 6c 6a 6b 6c 6d 6b 6c 6d 6e 6c 6d 6e 6f 6d 6e 6f 70 6e 6f 70 71
hash
248d6a61 d20638b8 e5c02693 0c3e6039 a33ce459 64ff2167 f6ecedd4 19db06c1
Input
One million of 61
hash
cdc76e5c 9914fb92 81a1c7e2 84d73e67 f1809a48 a497200e 046d39cc c7112cd0
4.4 RSA ALGORITHM: RSA involves a public key and private key. The public key can be known to everyone, it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key. The keys for the RSA algorithm are generated the following way: 1. Key Generators:
Generate large primes p, q – At least 2048 bits each… need primality testing!
Compute n=pq – Note that ϕ(n)=(p-1)(q-1)
Choose small e, relatively prime to ϕ(n) – Typically, e=3 (may be vulnerable) or e=216+1=65537 (why?)
Compute unique d such that ed ≡ 1 mod ϕ(n) Public key = (e,n); private key = d
2. Encryption of m: c = me mod n 3. Decryption of c: cd mod n = (me)d mod n = m
.
4.4.1 Why RSA is secure: RSA problem: given c, n=pq, and e such that gcd(e,(p-1)(q-1))=1, find m such that me=c mod n
In other words, recover m from ciphertext c and public key (n,e) by taking eth root of c modulo n
There is no known efficient algorithm for doing this
Factoring problem: given positive integer n, find primes p1, …, pk such that n=p1 e1p2 …pk ek
e2
If factoring is easy, then RSA problem is easy, but may be possible to break RSA without factoring n
4.5 Nonces Algorithm: The nonce is a 32-bit number. It stays in the block header along with other key data, such as the difficulty target and timestamp. When miners build blocks, they randomly choose a nonce and input it into the block header, creating a new block header hash. The hash is a 256-bit number and has to start with a huge number of zeros, i.e. have an incredibly small value. If it does not have the sufficient number of zeros, then the miner discards the hash and tries a new nonce. This process is repeated until a miner discovers a nonce that produces a hash with a value less than or equal than that set by the difficulty. Fig:4.5 Building Blocks with Nonce
The 32-bit size of the nonce means that there are four billion possible combinations. Although technically, it is much higher due to something called the extra nonce. This is additional space for a longer nonce, meaning you can have tens of billions of combinations. The nonce is the only parameter that the miner changes, all others remaining static. If the miner finds the golden nonce they add that block to the blockchain and receive the block reward. Currently, there is no way to speed up the process of finding the correct nonce. This means miners are just operating in trial and error until they find a golden nonce. This process is what constitutes the work, in proof of work.
Fig 4.5.1 Working of Nonce Algorithm
5. Experimental Results and Discussion: 5.1Patient Dashboard
5.2Patient Details
5.3 Patient Details Transaction
5.4Patients Blockchain
5.5Patient’s Mined Blockchain
5.6 Doctors Dashboard
5.7Doctors Details
5.8 Doctors Transaction Details
5.9 Doctors Blockchain:
5.10 Doctor’s Mined Blockchain:
5.11 Hospital Dashboard:
5.12 Hospital Blockchain:
5.13 Central Blockchain:
Conclusion