# MedChain: Efficient Healthcare Data Sharing via Blockchain
## 3 MedChain Model
### Blockchain Service  
A blockchain is a distributed ledger recording the events of healthcare data generation and data sharing. It is composed of a growing number of blocks. In MedChain, each block contains one or more events identified by event hash. An event hash is computed by hashing the event content, as the event fingerprint. A block also has a block header, which contains:  
* Merkle Root. The root of the Merkle tree [37] constructed by all the event hashes in the block. * Timestamp: The time of when the block is created. * Block hash: The hash code computed based on the hash of the last block, the Merkle root, and the timestamp. The cascaded hash computing at the event level (event hash), the block level (Merkle root), and the chain level (block hash) ensures the content immutability of a blockchain. If someone wants to modify the block information, he/she has to modify the entire chain. Yet, any tampering with the content can be easily detected by re-generating the hash codes and comparing them with the original ones. Thus, the blockchain is effective with storage immutable information, but weak when storing mutable information. The MedChain blockchain structure is illustrated in Figure 4, which shows a block with two events. In MedChain, the blockchain service manages the immutable information of healthcare data. Two types of events are recorded on a blockchain: data generation event and session creation \begin{table}
\begin{tabular}{c c} \hline
**Notation** & **Description** \\ \hline \(:=\) & Definition \\ \(\langle\cdots\rangle\) & Tuple, representing data or message format \\ \(\{\cdots\}\) & Set, representing one or more items of the same type \\ \((\cdots)\) & Optional element(s) \\ \(|\) & Exclusive disjunction (XOR) \\ \(\|\) & String concatenation operation \. & Membership \\ \(\rightarrow\) & Message transmission \\ \(\leftarrow\) & Assignment \\ \hline \end{tabular}
\end{table} 
Table 1: Notations. Figure 4: An illustration of the MedChain blockchain structure with a digest chain. event. The immutable information and the format of events will be elaborated in detail in the following paragraphs. **Data Generation Event (\(Event_{DG}\))**. A data generation event is created when a healthcare record file or a data chunk file is generated. It contains \(DID\), chunk index, patient public key, healthcare provider public key and signature (\(Sign_{sp}\)), data digest, and the reference (\(Ref_{L}\)) to the last chunk location (identified by the block hash (\(BH_{L}\)) and the event hash (\(EH_{L}\))) on the blockchain (for data stream only) and event type. As shown in Def. (1), the privacy-sensitive items, including \(DID\), chunk index, and \(PK_{pat}\), are encrypted with \(PK_{pat}\) for disassociating a patient with a healthcare provider. The data digest is created by hashing the data file for data integrity check. See the sub-section below for the details of the digest chain. \[ \begin{array}{l}Event_{DG}\big{<}Content,PK_{sp},\ Digest,Sign_{sp}(,Ref_{L}),\ Type\big{>}\\ ContentE_{PK_{pat}}(DID(,\ Index),PK_{pat})\\ DigestH(Data)\mid H(Chunk(i)\parallel Digest_{i-1})\\ Ref_{L}(BH_{L},EH_{L})\\ Type\leftarrow\textit{``AddData''}\end{array}  \tag{1}\]  
**Session Creation Event (\(Event_{SC}\))**. A session creation event is created when a patient grants the access of some of the healthcare data to a requester. It contains a list of \(DIDs\). For the data stream, the start time (\(st\)) and end time (\(et\)) can be specified as an access constraint. It also contains the public key of the patient and the requester for identifying the session participants, as well as the signature of the patient (\(Sign_{pat}\)). The formal definition of the session creation event is shown in Def. (2). For de-identification, \(DID\), \(st\), \(et\), and \(PK_{pat}\) are encrypted with \(PK_{pat}\). The session digest is generated by hashing the \(DIDs\) and the time constraints of the shared data and the session participants' public keys. \[