# Blockchain-Based Multiple Authorities Attribute-Based Encryption for EHR Access Control Scheme
## 5 Scheme Implementation
### System Initialization Phase  
As shown in Figure 3, the CA is responsible for global setup, and the AMC is responsible for managing attributes. AAs calculate the public attribute key segmentation off-chain, and PAKGC reconstructs the public attribute keys on-chain. DU is responsible for the data user setup. _Attribute Management Contract (AMC)._ To enable cross-domain attributes management, CA assigns multiple AAs and threshold \(t_{\omega}\) to each attribute by invoking the AMC. As shown in Algorithm 1, each attribute has two parameters: the number of AAs \(n_{\omega}\) and the threshold \(t_{\omega}\) for managing attribute \(\omega\). The data user must obtain \(t_{\omega}\) authorizations from the \(n_{\omega}\) attribute authorities to access the attribute. Figure 3: System initialization phase. Figure 2: The overall flow of VO-PH-MAABE. ```
1://CA invokes the contract to assign a set of authorities and thresholds to attributes
2:if\(Assignment(\omega,AAs,t)\) = true then
3:\(n_{\omega}\leftarrow\) a set of authorities;
4:\(t_{\omega}\leftarrow\) threshold;
5:endif
```  
**Algorithm 1** Attribute management  
\(GlobalSetup(1^{\lambda})\to GP\): CA Select two prime p-order bilinear groups \(G_{1},G_{2}\), and \(g\) is the generating element of G1. \(e:G_{1}\times G_{1}\to G_{2}\) is a bilinear map. Then CA defines one-way hash function functions \(H:\{0,1\}^{*}\to G_{1}\), \(H^{\prime}:G_{2}\to Z_{p}^{*}\) and chooses random numbers \(y\in Z_{p}^{*}\) to count \(g^{y}\). The global parameters \(GP=\{G_{1},G_{2},e,g,H,H^{\prime},g^{y}\}\). \(AASetup(GP)\to(pk_{i},sk_{i})\): The AAs collaborate using the Shamir secret sharing scheme to obtain a key partition \(\{pk_{i,\omega},sk_{i,\omega}\}_{\omega\in S_{i}}\) for each attribute jointly managed using a list of AAs, where \(S_{i}\) is the set of attributes managed by \(AA_{i}\). For an attribute \(\omega\) managed by \(n_{\omega}\) AAs, \(AA_{i}\) randomly chooses \(\alpha_{i},\beta_{i}\in Z_{p}^{*}\) to generate two \((t_{\omega}-1)\) order random polynomials \(F_{i}(x)\) and \(H_{i}(x)\), and the master secret is defined as  
\[s_{1}=\alpha_{\omega}=\sum_{i=1}^{n_{\omega}}\alpha_{i},\quad s_{2}=\beta_{ \omega}=\sum_{i=1}^{n_{\omega}}\alpha_{i} \tag{1}\]  
where \(\alpha_{i}=F_{i}(0)\), \(\beta_{i}=H_{i}(0)\). For each of the other \(AA_{j}\) with identity \(aid_{j}\), \(AA_{i}\) computes the subpartition of the master secret \(s_{ij,1}=F_{i}(aid_{j}),s_{ij,2}=H_{i}(aid_{j})\), and sends \((s_{ij,1},s_{ij,2})\) to \(AA_{j}\). \(AA_{i}\) receives \(n_{\omega}-1\) subsegments \((s_{ji,1},s_{ji,2})\) and then computes the main segmentation of the main secret. \[s_{i,1}=sk_{a_{\omega},i}=\sum_{i=1}^{n_{\omega}}s_{ji,1},\quad s_{i,2}=sk_{a_ {\omega},i}=\sum_{i=1}^{n_{\omega}}s_{ji,2} \tag{2}\]  
The segmentation of the public attribute key \(pk_{i,\omega}=(e(g,g)^{sk_{a_{\omega},i}},g^{sk_{a_{\omega},i}})\). Then \(AA_{i}\) sends the \(pk_{i,\omega}\) to the contract. _Public Attribute Key Generation Contract\((PAKGC)\)_. AAs collaborate using the Shamir secret sharing scheme to generate the attribute public key for each attribute and upload it to the blockchain. Since multiple AAs jointly manage each attribute, the system needs a contract to collect the public attribute key slice generated by AAs. As shown in Algorithm 2, after the system initialization phase, the PAKGC collects \(t_{\omega}\) public attribute key segmentation \(pk_{i,\omega}\) from AAs and automatically invokes Lagrangian interpolation to calculate the public attribute key \(PAK_{\omega}\) for encryption of data.