# Unified Ciphertext-Policy Weighted Attribute-Based Encryption for Sharing Data in Cloud Computing
## 5 Proposed Unified Ciphertext-Policy Weighted Attribute-Based Encryption
### The Design of UCP-WABE  
UCP-WABE can be described as a collection of the following five algorithms:  
**Setup**(\(1^{\lambda},\mathcal{U}\)). This algorithm generates the public parameters (\(PP\)) and the master secret key (\(MSK\)). WAA runs **Setup**, which takes a security parameter \(\lambda\) and the set of all attributes \(\mathcal{U}\) in the system as input. Each attribute has a weight depending on its importance in the system, and let \(l_{i}\) be the maximum weight of attribute \(u_{i}\), where \(u_{i}\in\mathcal{U}\). WAA chooses a group \(\mathcal{G}_{1}\) of prime order \(p\) with generator \(g\) and random group elements \(\{h_{i,end},h_{i,j}\}_{\forall u_{i}\in\mathcal{U},j=0,\cdots,l_{i}}\). WAA also chooses a random exponent \(\alpha\in\mathbb{Z}_{p}\) and computes \(PP\) as:  
\[PP=\Big{\{}\mathcal{G}_{1},g,\widehat{e}(g,g)^{\alpha},\{h_{i,end},h_{i,j}\}_ {\forall u_{i}\in\mathcal{U},j=0,\cdots,l_{i}}\Big{\}}. \tag{1}\]  
The master key of the system MSK can be calculated as:  
\[MSK=g^{-\alpha}. \tag{2}\]  
PP is released to all the data providers and data consumers. **MutualInfoGen**(\(PP,\Gamma_{1},\Gamma_{2}\)). In [24], the cpabe toolkit [33] can transform an access policy into a stylized expression. Therefore, MIE is able to extract the mutual sub-policy when providers' access policies meet the two conditions. Then, MIE creates an access tree \(\Gamma_{e}\) according to the mutual sub-policy. Let \(Y_{\epsilon}\) denote the set of the leaf nodes in \(\Gamma_{\epsilon}\). Each element of \(Y_{\epsilon}\) represents an attribute (denoted by \(a_{i}\)) with a weight (denoted by \(\omega_{i}\)). The number of leaf nodes is denoted by \(k_{\epsilon}\). \(\forall a_{i}\in Y_{\epsilon}\). Let \((i,j)\) denote the \(j\)th part of \(a_{i}\), where \(j=1,\cdots,\omega_{i}\). MIE chooses a polynomial \(f_{c}(x)\) for every node of \(\Gamma_{\epsilon}\). Let the polynomial degree \(d_{c}=V_{c}-1\), as follows:  
\[f_{c}(x)=\sum_{i=0}^{d_{c}}b_{i}x^{i}, \tag{3}\]  
where \(b_{i}\) denotes the polynomial coefficient. Moreover, let \(N_{\epsilon}\) denote the root of \(\Gamma_{\epsilon}\). MIE picks a random quantity \(s=f_{\epsilon}(0)\in\mathbb{Z}_{p}\) and randomly chooses other \(d_{\epsilon}\) points of \(f_{\epsilon}(x)\) to determine \(f_{\epsilon}(x)\). MIE selects \(f_{q}(x)\) for the non-root node \(N_{q}\) of \(\Gamma_{\epsilon}\), where:  
Figure 3: The merging process of two weighted access trees. \[f_{q}(0)=f_{parent(N_{q})}(index(N_{q})). \tag{4}\]  
MIE randomly picks the other \(d_{q}\) points to determine \(f_{q}(x)\). Therefore, it can get the polynomials \(f_{c}(\cdot)\) for any \(N_{c}\in\Gamma_{c}\). MIE chooses random values \(s_{1,0},\cdots,s_{1,\omega_{1}-1},\cdots,s_{k_{c},0},\cdots,s_{k_{c},\omega_{k_ {c}}-1}\in\mathbb{Z}_{p}\), and creates the mutual information \(MI\) as follows:  
\(\forall a_{i}\in\gamma_{c},i=1,\cdots,k_{c}\), MIE first calculates:  
\[C_{(i,0),1}=g^{s_{i,0}},C_{(i,0),2}=(h_{i,0})^{s_{i,0}}. \tag{5}\]  
Then, for \(j=1\) to \(\omega_{i}-1\), MIE calculates:  
\[C_{(i,j),1}=g^{s_{i,j}},C_{(i,j),2}=(h_{i,j})^{s_{i,j}}\cdot\mathcal{H}(a_{i}) ^{s_{i,j}-1}. \tag{6}\]  
When \(j=\omega_{i}\), let \(s_{i,j}=f_{a_{i}}(0)\), where \(f_{a_{i}}(\cdot)\) is the polynomial of the node whose attribute is \(a_{i}\). MIE calculates:  
\[C_{(i,j),1}=g^{f_{a_{i}}(0)},C_{(i,j),2}=(h_{i,j})^{f_{a_{i}}(0)}\cdot\mathcal{ H}(a_{i})^{s_{i,j}-1}. \tag{7}\]  
Then, MIE calculates:  
\[C_{(i,end),1}=g^{f_{a_{i}}(0)},C_{(i,end),2}=(h_{i,end})^{f_{a_{i}}(0)}. \tag{8}\]  
Finally, MIE creates the mutual information \(MI\):  
\[MI=\Big{\{}\Gamma_{c},\{C_{(i,j),1},C_{(i,j),2}\}_{\forall a_{i}\in\gamma_{c},j=1,\cdots,\omega_{i},\prime}\{C_{(i,end),1},C_{(i,end),2}\}_{\forall a_{i} \in\gamma_{c}}\Big{\}}. \tag{9}\]  
Algorithm 1 shows the pseudocode of the **MutualInfoGen** algorithm. ```
0:\(PP\): The public parameter. \(\Gamma_{1}\): The weighted access tree of Provider A. \(\Gamma_{2}\): The weighted access tree of Provider B. 0:\(MI\): The mutual information.